[Haskell-cafe] deriving Data.HashTable - stack overflow
Lyle Kopnicky
lists at qseep.net
Fri Aug 9 08:18:48 CEST 2013
Ah, thanks, folks!
I'll just implement my own hashing by generating a string and calling the
hash function on that. That's what I was doing in the old version of my
code, anyway.
It's just that in the core Data.HashTable, you had to provide a hash
function, so the point where I used the hash table was able to call a
string conversion function that was defined elsewhere.
With the hashtable package, you have to define a Hashable instance in the
same package as your datatype definition - which is not where the string
conversion is implemented. Calling the string conversion function leads to
a cyclic dependency that I wanted to avoid. So I'll have to maybe move it
to live with the datatype definition, or duplicate it, or use some other
means of hashing.
In other words, package A defines datatype A. Package B defines A ->
String. Package C creates a HashTable that indexes by As, and also imports
package B, so it can build a hash function as the composition of the string
conversion and the provided string hashing.
But now I need to define the Hashable instance in A, which doesn't have
access to package B, since package B also depends on A, and I don't like
circular dependencies.
- Lyle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130808/2a7328fe/attachment.htm>
More information about the Haskell-Cafe
mailing list