[Haskell-cafe] A curios monad

Andrew Coppin andrewcoppin at btinternet.com
Thu Dec 11 16:26:54 EST 2008

Alberto G. Corona wrote:
> but because keys and data must be of the same type, you are restricted 
> to instances of Eq and Ord. Itsn´n true?
> 2008/12/11 Andrew Coppin <andrewcoppin at btinternet.com 
> <mailto:andrewcoppin at btinternet.com>>
>     Alberto G. Corona wrote:
>         Well, you have not to use typeable, but instead you need to
>         use instances of Eq and Ord. This is because the values and
>         the keys must be of the same type. this is the  tradeoff.
>     Not really, no. The *keys* need Eq and Ord, but the values I'm
>     storing don't. The values I'm storing don't need any specific
>     properties at all. That's what I like about it.

No. Keys are of type "Key v", where "v" can be anything. It's a phantom 
type, so it's not used for anything (except knowing what to coerce the 
value back to when it's looked up). "Key v" is just an alias to Int, 
which *is* in Eq and Ord, as required. There are no constraints on "v" 
at all.

More information about the Haskell-Cafe mailing list