Using associated data types to create unpacked data structures

Johan Tibell johan.tibell at
Thu Aug 12 07:28:25 EDT 2010

On Thu, Aug 12, 2010 at 12:25 PM, Simon Marlow <marlowsd at> wrote:

> I'm not sure I want lookup (and other operations) to be inlined at every
> call site though.

That's a good point. If inlining isn't a the right option in every case we
would have to duplicate the implementation.

I had a look at how C++ compilers deals with this problem. They do so by
duplicating the implementation in each module that instantiates the
template, at least according to this document:

As I understand it the generated code is not exported from the translation
unit so there are no collisions at link time. We could do the same if we
could force the generated type class instance to not be exported from the

> This doesn't quite work though as two MapIntDouble defined in two
>> different libraries are incompatible. This is essentially the same
>> problem as with instance collisions.
> But you get to choose the module name, so you can avoid collisions by using
> qualified names.

Sorry, I was being unclear. The problem is that library A can't pass a
MapIntDouble to library B as the types defined by the two libraries aren't

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Glasgow-haskell-users mailing list