[Haskell-cafe] RE: Efficient or predictable Ord for Typeable
Simon Peyton-Jones
simonpj at microsoft.com
Tue Nov 30 06:06:45 EST 2004
The trouble is that *any* "function" can now deliver unpredictable
results. Can I rely on the fact that
foo :: Int -> Int
will always give the same answer given the same input. Not any more.
I think the strongest argument here is that it's like a more benign
version of unsafePerformIO, whose existence also threatens foo's
predictability.
| -----Original Message-----
| From: George Russell [mailto:ger at informatik.uni-bremen.de]
| Sent: 30 November 2004 09:55
| To: haskell-cafe at haskell.org; Simon Peyton-Jones; John Meacham
| Subject: Efficient or predictable Ord for Typeable
|
| 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
mailing list