[Haskell-cafe] Efficient or predictable Ord for Typeable
ger at informatik.uni-bremen.de
Tue Nov 30 04:54:42 EST 2004
Simon PJ wrote (snipped):
> This unfortunate observabilty of an ordering (or hash value) that is
> needed only for efficient finite maps, is very annoying. I wish I knew
> a way round it. As it is we can pick
> a) expose Ord/Hash, but have unpredictable results
> b) not have Ord/Hash, but have inefficient maps
In this case there is a simple solution. Simply define
newtype FastUnpredictableInstances a = FastUnpredictableInstances a
and define the fast Ord and Hash only for FastUnpredictableInstances.
People who manage to type all that then have no grounds to grumble
if they get bitten. For something as basic as implementing execution
contexts, FastUnpredictableInstances is acceptable.
More information about the Haskell-Cafe