Can containers depend on Template Haskell?

John Meacham john at repetae.net
Sat Nov 27 01:52:33 EST 2010


containers compiles cleanly with jhc right now, so if you make it depend on
non h2010 features then it would be good to protect them with an #ifdef or
some other mechanism.

     John

On Tue, Nov 23, 2010 at 1:25 AM, Johan Tibell <johan.tibell at gmail.com>wrote:

> Hi all,
>
> I'm working on a proposal for adding a Data.HashMap and Data.HashSet
> type to containers. These types could share most of their
> implementation with Data.IntMap (and Data.IntSet) but can be
> (somewhat) more efficiently implemented by specializing IntMap from
>
>    data IntMap a = Nil
>                  | Tip {-# UNPACK #-} !Key a
>                  | Bin {-# UNPACK #-} !Prefix {-# UNPACK #-} !Mask
> !(IntMap a) !(IntMap a)
>
> to
>
>    data FullList k v = FL !k v (List k v)
>
>    data List k v = Nil | Cons !k v (List k v)
>
>    data IntMap a = Nil
>                  | Tip {-# UNPACK #-} !Hash {-# UNPACK #-} !(FullList k v)
>                  | Bin {-# UNPACK #-} !Prefix {-# UNPACK #-} !Mask
> !(IntMap a) !(IntMap a)
>
> Unpacking the FullList into the Tip constructor saves one indirection
> and two words of overhead per key/value pair.
>
> One way to achieve this specialization would be to duplicate the
> implementation of Data.IntMap, but it would be nice to avoid the
> duplication. Template Haskell would allow most of the implementation
> to be shared without sacrificing performance.
>
> Can containers use Template Haskell? I think the answer is no, but I
> thought I'd check anyway.
>
> Johan
> --
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20101127/8a86ab7d/attachment.html


More information about the Libraries mailing list