Hi,
I have a set of functor definitions with corresponding instances
newtype Id a = Ident {unIdent :: a} deriving Eq
newtype K b a = Const {unConst :: b} deriving Eq
instance Functor Id where
fmap f (Ident x) = Ident $ f x
instance Functor (K a) where
fmap f (Const x) = Const x
(...)
And a class that creates a representation b for a functor f a:
class Functor f => C f a b | f a -> b where
ftest :: f a -> b
instance C Id a a
instance C (K b) a b
I want to write some function
test :: (C f a b) => (a -> b)
test = ftest . undefined
But, as expected, the type checker claims not to satisfy the context, since
the function may be valid for any representable functor, as long as it has
an instance.
What I would want is to constrain the set of functors that the class applies
to, for which I have all the required instances. Is it possible in Haskell?
Sorry if this explanation is confusing.
Thanks in advance,
hugo
_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell