[Haskell] class variable dynamic inference

Hugo Pacheco hpacheco at gmail.com
Thu Jun 14 17:43:01 EDT 2007


Hi,

I have defined some functors (with respective Functor instances) and a
class that derives  the equivalent non-functor representation

class (Functor f) => Rep f a b | f a -> b

My problem is that I need to define another class

class (Functor f,Rep f d c) => FunctorOf f d | d -> f where
    in''  :: c -> d
    out'' :: d -> c

where the variable c would be implicit and dynamically derived from
the (f d) context.

Of course this is not allowed as long as the variable c is not in the
class context.

Is there any way I can hack this around?

defining the class functions like in''  :: Rep f d c => c -> d doesn't
solve my problem as well.

Thanks in advance,
hugo


More information about the Haskell mailing list