[Haskell-cafe] Re: [Haskell] Re: Global Variables and IO initializers

Benjamin Franksen benjamin.franksen at bessy.de
Mon Nov 29 05:57:31 EST 2004

On Monday 29 November 2004 11:35, George Russell wrote:
> (indexing with TypeRep)
>  > This is yet another incidence where Robert Will's ByMaps would be
>  > very useful
> In fact GHC at least *already* generates a unique integer for each
> TypeRep. A good idea, since it means comparisons can be done in unit
> time. Thus indexing can be done trivially using this integer as a
> hash function.

Yes, I have seen this in the code, too. The Ord and Typeable instances 
should be trivial.

[off topic:]

There was a recent discussion about allowing to derive an instance from 
anywhere at the top-level, and not only in the type definition. This is 
one more example where such a feature would be very useful.

Another related example is the class Typeable itself. It has been noted 
by others that the current interface is not type safe, since mkTyCon 
gets an arbitrary string as argument. (Unfortunately this means that 
GlobalVariables.hs and ExecutionContext.hs aren't really type safe 

Typeable would be completely safe if the only way to declare instances 
would be to derive them, but this is only practical if it can be done 
from anywhere outside the data type definition.

Can anyone think of a situation where adding a derived instance to an 
abstract data type breaks one of its invariants?


More information about the Haskell-Cafe mailing list