[Haskell-cafe] Scope of type variables in associated types

Manuel M T Chakravarty chak at cse.unsw.edu.au
Fri Jun 8 02:55:53 EDT 2007

Matthew Sackman wrote:
> Andres Loeh <loeh at iai.uni-bonn.de> wrote:
>>> class OneStep a
>>>     data OS a :: *
>>> instance OneStep (Cons v t)
>>>     data OS (Cons v t) = t
>>> class TwoStep a
>>>     data TS a :: *
>>> instance (OneStep a, OneStep b) => TwoStep a
>> instance (OneStep a, OneStep (OS a)) => TwoStep a
>> ?
> Doesn't seem to work. Ok, my original was wrong as I had no constructor
> on the associated type. So below are 2 versions, one with fundeps, which
> works, one with associated type synonynms which doesn't work, which
> made me remember the warnings about how type synonynms aren't fully
> implemented yet, and so I wrote a third version with indexed types, but
> whilst I can make it work, wrapping up values in indexed types gets
> really really messy.

Yes, it's messy with indexed data families as they force you to introduce all 
these new constructors and the corresponding wrapping and unwrapping code.  As 
Tom wrote in another message in this thread, you really do want to use indexed 
synonyms families (aka associated type synonyms) here.  They will do what you 
want.  We are currently working on completing the implementation of
synonym families.[1]


[1] For those who wonder why this is taking so long, we are working on a system
     that is actually significantly more general than what we described in the
     ICFP05 paper.  In particular, we want synonym families to play nice with

More information about the Haskell-Cafe mailing list