Re: Using associated data types to create unpacked data structures

2010-08-13 Thread Johan Tibell
On Fri, Aug 13, 2010 at 1:14 AM, Max Bolingbroke batterseapo...@hotmail.com wrote: On 12 August 2010 20:31, Johan Tibell johan.tib...@gmail.com wrote: Yes and dead code elimination should also be able to get rid of much of the code duplication even before it reaches the linker. I don't

Re: exporting instances: was Using associated data types to create unpacked data structures

2010-08-13 Thread Max Bolingbroke
On 13 August 2010 00:13, John Lask jvl...@hotmail.com wrote: I have wondered and perhaps someone can explain: what are the issues in explicit control of instance export and import? (apart from defining an appropriate syntax) IMHO main problem with this (and related feature requests like local

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Simon Marlow
On 11/08/2010 17:03, Johan Tibell wrote: Inspired by the generic maps example at http://www.haskell.org/haskellwiki/GHC/Indexed_types I tried to use associated data types to create a generic finite map that unpacks both the key and value into the leaf data constructor. What you're trying to

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Johan Tibell
On Thu, Aug 12, 2010 at 11:28 AM, Simon Marlow marlo...@gmail.com wrote: On 11/08/2010 17:03, Johan Tibell wrote: Inspired by the generic maps example at http://www.haskell.org/haskellwiki/GHC/Indexed_types I tried to use associated data types to create a generic finite map that unpacks

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Simon Marlow
On 12/08/2010 11:13, Johan Tibell wrote: There needs to be some amount of code generation, but much of the implementation can still be shared. I previously tried to defined the type class as {-# LANGUAGE MultiParamTypeClasses, TypeFamilies #-} module Ex2 where import Prelude

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Johan Tibell
On Thu, Aug 12, 2010 at 12:25 PM, Simon Marlow marlo...@gmail.com 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

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Simon Marlow
On 12/08/2010 12:28, Johan Tibell wrote: 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

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Johan Tibell
On Thu, Aug 12, 2010 at 1:47 PM, Max Bolingbroke batterseapo...@hotmail.com wrote: None of the mechanism for making this stuff happen is available at the moment. It's an engineering problem that just needs time to be thrown at it. If we could figure out which mechanisms are needed we would

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Jean-Marie Gaillourdet
Hi, On 12.08.2010, at 12:25, Simon Marlow wrote: On 12/08/2010 11:13, Johan Tibell wrote: There needs to be some amount of code generation, but much of the implementation can still be shared. I previously tried to defined the type class as {-# LANGUAGE MultiParamTypeClasses,

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Johan Tibell
On Thu, Aug 12, 2010 at 11:28 AM, Simon Marlow marlo...@gmail.com wrote: Rather than try to solve this problem in one go, I would go for a low-tech approach for now: write a TH library to generate the code, and ask the user to declare the versions they need. To make a particular version, the

RE: Using associated data types to create unpacked data structures

2010-08-12 Thread Simon Peyton-Jones
Subject: Re: Using associated data types to create unpacked data structures On Thu, Aug 12, 2010 at 11:28 AM, Simon Marlow marlo...@gmail.commailto:marlo...@gmail.com wrote: Rather than try to solve this problem in one go, I would go for a low-tech approach for now: write a TH library to generate

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Johan Tibell
On Thu, Aug 12, 2010 at 6:07 PM, Simon Peyton-Jones simo...@microsoft.comwrote: 1. You **want** a distinct blob of lookup code for each different key type, because you really do want a different lookup structure for each There are two reasons to want different blobs of code for the

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread scooter . phd
, 12 Aug 2010 13:28:25 To: Simon Marlowmarlo...@gmail.com Cc: glasgow-haskell-usersglasgow-haskell-users@haskell.org Subject: Re: Using associated data types to create unpacked data structures ___ Glasgow-haskell-users mailing list Glasgow-haskell-users

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Johan Tibell
On Thu, Aug 12, 2010 at 9:27 PM, scooter@gmail.com wrote: C++ template instantiations are exported as weak linker symbols. It's just that the linker elides all of the implementations. Yes and dead code elimination should also be able to get rid of much of the code duplication even before

exporting instances: was Using associated data types to create unpacked data structures

2010-08-12 Thread John Lask
re ... 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 module. I have encountered several occasions when I wished

Re: Using associated data types to create unpacked data structures

2010-08-12 Thread Max Bolingbroke
On 12 August 2010 20:31, Johan Tibell johan.tib...@gmail.com wrote: Yes and dead code elimination should also be able to get rid of much of the code duplication even before it reaches the linker. I don't think dead code elimination will help, because presumably you want to generate

Using associated data types to create unpacked data structures

2010-08-11 Thread Johan Tibell
Hi all, Inspired by the generic maps example at http://www.haskell.org/haskellwiki/GHC/Indexed_types I tried to use associated data types to create a generic finite map that unpacks both the key and value into the leaf data constructor. This makes functions such as lookup faster as the key

Re: Using associated data types to create unpacked data structures

2010-08-11 Thread Bryan O'Sullivan
On Wed, Aug 11, 2010 at 9:03 AM, Johan Tibell johan.tib...@gmail.comwrote: However, if we try to apply this method to large programs we run into problems: we need to defined instances for a large number of combinations of keys/values. We could generate a large number of instances, hoping that