Proposal: Value strict versions of containers

Sebastian Fischer fischer at nii.ac.jp
Mon May 23 13:31:23 CEST 2011


On Mon, May 23, 2011 at 11:47 AM, Simon Marlow <marlowsd at gmail.com> wrote:

> I personally would rather have one IntMap with strict and lazy APIs.
>

I am also in favour of the "same type approach" because it seems it can help
to avoid duplicating the implementations. Would it be efficient to define a
type Data.IntMap.Strict.IntMap with strict fields (also for values) and then
define Data.IntMap.Lazy in terms of this implementation and a wrapper type?

data Lazy a = Lazy { getLazy :: a }

newtype IntMap a = LazyIntMap { getLazyIntMap :: Data.IntMap.Strict (Lazy a)
}

lookup :: Int -> IntMap a -> Maybe a
lookup n = fmap getLazy . Data.IntMap.Strict.lookup n . getLazyIntMap

...

Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20110523/174c1481/attachment.htm>


More information about the Libraries mailing list