{-# LANGUAGE TypeFamilies, MultiParamTypeClasses, GADTs #-}
data D1
data D2
data Showable where
Showable :: Show a => a -> Showable
class Dispatch a b where
type Impl_ a b :: *
runF :: a -> b -> Impl_ a b
instance Dispatch D1 D2 where
type Impl_ D1 D2 = Showable -> IO ()
runF _ _ (Showable x) = print x
Now you can run it like this:
*Main> runF (undefined :: D1) (undefined :: D2) (Showable True)
True
Regards,
Erik