
Could you do something like this?
instance (Impl D1 D2 ~ a -> IO (), C a) => Dispatch D1 D2
Erik
On Fri, Jan 2, 2015 at 7:59 PM, aditya siram
Hi all, I'd like to be able to constrain an associated type.
I used to have an instance that looked like: class Dispatch a b c | a b -> c where runF :: a -> b -> c instance (C a) => Dispatch D1 D2 ( a -> IO ()) where runF d1 d2 = (\_ -> return ())
Since I upgraded to 7.8 from 7.5 that instance declaration is no longer accepted is no longer accepted since it violates FD's.
I have been updating my code to use type families like so: class Dispatch a b where type Impl a b :: * runF :: a -> b -> Impl a b instance (C a) => Dispatch D1 D2 where type Impl D1 D2 = a -> IO () runF d1 d2 = (\_ return ())
Unfortunately the `type Impl ...` line in the instance is rejected because it uses `a` on the RHS.
In this one case I could just package it up into a newtype or something but I would ideally like to be able to constrain any number of arguments like: instance (C a, C b ... C z) => Dispatch D1 D2 where type Impl D1 D2 = a -> b -> ... -> z -> IO () ...
This was something I could do in 7.6 (although I realize this is way safer). How do I go about getting that constraint back?
Thanks! -deech
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe