[Haskell-cafe] Re: Efficient or predictable Ord for Typeable
Ian.Stark at ed.ac.uk
Ian.Stark at ed.ac.uk
Tue Nov 30 07:47:01 EST 2004
On Tue, 30 Nov 2004, Lennart Augustsson wrote:
> George Russell wrote:
>> I suggest you implement
>>
>> hashTypeable :: Typeable -> IO Int32
>
> And/or
> mkHashTypeable :: IO (Typeable -> Int32)
And/or (you'll hate this):
mkHashTypeable :: ACIO (Typeable -> Int32)
After all, I'm sure you don't want hasTypeable / mkHashTypeable to give
different answers when used twice on the same run.
Simon Peyton-Jones wrote:
> 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.
Performing a dubious toplevel 'declare hashTypeable <- mkHashTypeable'
hits an odd middle ground here: you can indeed rely on the fact that
foo :: Int -> Int
will always give the same answer given the same input, anywhere in the
program. It just won't necessarily give the same answer next time you run
the program. No call-by-name rewrites are broken, but something is
certainly strange.
--
Ian Stark http://www.ed.ac.uk/~stark
LFCS, School of Informatics, The University of Edinburgh, Scotland
More information about the Haskell-Cafe
mailing list