22 Jun
2007
22 Jun
'07
5:10 p.m.
2007/6/22, Hugo Pacheco <hpacheco@gmail.com>:
class Functor f => C f a b | f a -> b where ftest :: f a -> b
I want to write some function
test :: (C f a b) => (a -> b) test = ftest . undefined
I'm not sure whether this is what you want, but the "obvious" way to make this type-check would seem to be to add a functional dependency and a type signature for 'undefined,' like this:
class Functor f => C f a b | f a -> b, a b -> f where ftest :: f a -> b
test :: (C f a b) => (a -> b) test = ftest . (undefined :: a -> f a)
- Benja