Ah... I see that I have a bug in my proposal, perhaps corrected below.
>> 2. In the second and fourth instances, the type variable x appears twice >> in the parameters of the type function built from the fundep (a b -> c). >> This causes an error. If I try adding (x ~ x') to the context and >> making one of them x' instead of x, I get different errors. I see the problem with the x parameter now: >> >> I'm starting to this this is an example of using functional dependencies >> that has no translation to type families. Can anyone free me of such >> thoughts? >> >> Code with fundeps is: >> >> data Var a = Var Int (Maybe String) >> data RHS a b = RHS a b >> >> class Action t a b c | a -> t, a b -> c, a c -> b >> instance Action t () y y >> instance Action t (Var x) (x -> y) y >> instance Action t [t] y y >> instance (Action t a b c) => Action t (RHS (Var x) a) (x -> b) c >> instance (Action t a b c) => Action t (RHS [t] a) b c >> > > I have never used associated types or type families. I assume you cannot rely > on GHC lazy goodwill for the a->t constraint. You will have to be explicit. > Not using associated types but type families I think the syntax should be: > > [snip] > type instance A_C_B (RHS (Var x) a) c = x -> A_C_B a c The above is the corrected line. I had forgotten the (x->) on the RHS. > [snip] _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe