Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparison of atom libraries for Haskell, e.g. simple-atom and stringtable-atom

Tags:

haskell

I find myself needing a string table in a Haskell program I'm developing. In particular, I want a system which allows be to box any String into (say) an 'Atom'; given an Atom, you should be able to recover the original string it came from, and (critically) comparing two Atoms for equality should be as fast (or almost as fast) as a pointer compare.

(One can easily devise a referentially-transparent interface for this functionality; the implementation will use unsafePerformIO internally but the user of the library need not know about such details.)

Two libraries available on Hackage seem to be in the right ballpark: stringtable-atom and simple-atom. Does anyone have any experience using these libraries? In particular, are there any suggestions as to what the benefits of one over the other might be?

like image 695
circular-ruin Avatar asked Nov 04 '22 17:11

circular-ruin


1 Answers

Another nice choice would be ekmett's new intern package, which handles bytestrings as well as more complex recursive types: http://hackage.haskell.org/package/intern

He has assured me it is threadsafe.

like image 177
sclv Avatar answered Nov 09 '22 06:11

sclv