Edison 1.2rc2

Adrian Hey ahey at iee.org
Mon Mar 6 15:42:20 EST 2006

On Monday 06 Mar 2006 2:04 pm, Jean-Philippe Bernardy wrote:
> On 3/6/06, Christian Maeder <maeder at tzi.de> wrote:
> > Robert Dockins wrote:
> > > The second release candidate for Edison 1.2 is now ready for  comments.
> >
> > Will this make Jean-Philippe's work obsolete?
> > http://hackage.haskell.org/trac/ghc/wiki/CollectionClassFramework
> I intend to finish and publish that work... and of course make it the
> superior choice. :) In time I hope to retrofit edison concrete modules
> into my framework.

Hello Jean-Philippe,

I haven't had much time to study this, but in the light of recent
discussions about generalised tries I played about a little last night
and did have a go at producing n-Tuple maps from instances of your classes. 
e.g. for pairs I ended up trying to define something like this..

instance (MapLike c1 k1 c2, MapLike c2 k2 a) => MapLike (Map2 c1) (k1,k2) a

I must admit I found it hard going, but maybe I'm just using it wrong and
I didn't have much time to play about with alternatives. Perhaps you'd care
to give it a shot.

I'm not sure about the proper use of fundeps, but having the associated
values dependent on the map type seemed a little awkward to me and also
seems to make it hard to properly define intersectionWith for maps with
the same key type but different associated value types (one of the
infelicities you mention).

Would something like this be possible (using "Map" instead of "MapLike")?

class Ord k => Map map k | map -> k where

(I think I'd like an Ord constraint on keys)
then given..

newtype (Map2 map1 map2           a) = Map2 (     map1 (map2             a))
newtype (Map3 map1 map2 map3      a) = Map3 (Map2 map1  map2 (map3       a))
newtype (Map4 map1 map2 map3 map4 a) = Map4 (Map3 map1  map2  map3 (map4 a))

or perhaps..

newtype (Map2 map1 map2           a) = Map2 (map1 (     map2           a))
newtype (Map3 map1 map2 map3      a) = Map3 (map1 (Map2 map2 map3      a))
newtype (Map4 map1 map2 map3 map4 a) = Map4 (map1 (Map3 map2 map3 map4 a))

we could define..

instance (Map map1 k1, Map map2 k2)
      => Map (Map2 map1 map2) (k1,k2) where

instance (Map map1 k1, Map map2 k2, Map map3 k3)
      => Map (Map3 map1 map2 map3) (k1,k2,k3) where

instance (Map map1 k1, Map map2 k2, Map map3 k3, Map map4 k4)
      => Map (Map4 map1 map2 map3 map4) (k1,k2,k3,k4) where

Implementing these instances efficiently would be a good test of the
completeness of the class methods too (I haven't tried it yet :-).

But maybe there's a better way. Anybody got any alternative suggestions?

Adrian Hey

More information about the Libraries mailing list