
Ok, thanks for the clarification. One final question then, how could I rewrite the following in associated types:
class OneStep a b | a -> b instance OneStep (Cons v t) t
class TwoStep a b | a -> b instance (OneStep a b, OneStep b c) => TwoStep a c
If the fundep and b is dropped then I get:
class OneStep a data OS a :: * instance OneStep (Cons v t) data OS (Cons v t) = t <<<< data constructor missing !!!
class TwoStep a data TS a :: * instance (OneStep a, OneStep b) => TwoStep a
This last one can't be right, as I can't express the fact that the OS in "OneStep a" provides the link with "OneStep b". So is there a way to achieve this sort of chaining with associated types?
You'd have to write
class OneStep a data OS a :: * instance OneStep (Cons v t) data OS (Cons v t) = OSC t
class TwoStep a data TS a :: * instance (OneStep a, OneStep (OS a)) => TwoStep a where type TS a = TSC (OS (OS a))
which seems rather awkward with all these additional data type constructors. You'd be better off with associated type synonyms:
class OneStep a type OS a :: * instance OneStep (Cons v t) type OS (Cons v t) = t
class TwoStep a type TS a :: * instance (OneStep a, OneStep (OS a)) => TwoStep a type TS a = OS (OS a)
which are currently under development. -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: tom.schrijvers@cs.kuleuven.be