Re: FiniteMap

Ross Paterson <[email protected]> Tue, 5 Sep 2006 14:35:11 +0100
Newsgroups gmane.comp.lang.haskell.cvs.hugs
Message-ID <20060905133510.GB10633__24228.9734924727$1157463346$gmane$org@soi.city.ac.uk>
On Tue, Sep 05, 2006 at 02:13:33PM +0100, Malcolm Wallace wrote:
> > > So does anyone have any objections if I go ahead and commit the
> > > replacement (compatibility) implementation of Data.FiniteMap to the
> > > main repository for packages/base?
> > 
> > I'd rather see HaXml updated to use Data.Map, perhaps with a
> > compatibility layer for older GHCs.
> 
> OK, I've looked more closely at all uses of Data.FiniteMap in HaXml, and
> they are far from critical, so have reverted them to using simpler
> lookup structures.

Why not do it the other way round:

#if __GLASGOW_HASKELL__ >= 604 || __NHC__ >= 118 || defined(__HUGS__)
-- Data.Map, if it is available
import Prelude hiding (lookup)
import Data.Map (Map, lookup, fromList)
#else
-- otherwise, a very simple and inefficient implementation of a finite map
type Map k a = [(k,a)]
fromList :: [(k,a)] -> Map k a
fromList = id
-- Prelude.lookup :: k -> Map k a -> Maybe a
#endif