[Haskell-cafe] Re: functional maps

Chad Scherrer chad.scherrer at gmail.com
Fri Dec 21 14:55:05 EST 2007

Chad Scherrer <chad.scherrer <at> gmail.com> writes:

> A while back I was playing with Data.Map was getting irritated about
> lookups that fail having the type of values, but wrapped in an extra
> monad. I decided to work around this by putting a default in the data
> type itself, so we have a "functional map"
> data FMap k a = FMap (k -> a) (Map k a)

Sorry to respond to my own message, but I think I might have figured it out.
This should be strict in the Map parameter, so this works better:

data FMap k a = FMap (k -> a) !(Map k a)

It still takes lots of memory for what I'm trying to do, but that's another
problem. At least the stack seems happy.


More information about the Haskell-Cafe mailing list