[Haskell-cafe] Re: [Haskell] Re: Global Variables and IOinitializers

Ian.Stark at ed.ac.uk Ian.Stark at ed.ac.uk
Tue Nov 30 07:36:38 EST 2004


On Mon, 29 Nov 2004, Simon Peyton-Jones wrote:
> 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

I was going to ask what was wrong with doing the tedious:

   class FiniteMappable key where
     listToFM :: [(key,elt)] -> FiniteMap key elt
     addToFM :: FiniteMap key elt -> key -> elt -> FiniteMap key elt

     ...etc etc...

with the possibility of:

   instance Ord key => FiniteMappable key where
     listToFM = listToFMoriginal

     ...etc etc...

where one would only export the fact that a particular type is 
FiniteMappable, not Ord.

But then I remembered that modules can't hide instance declarations, so 
that's no good. :-(

Is there some way to insert a newtype, so that just one instance becomes 
visible?

--
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