import qualified Prelude as P
class Functor f => Apply f
where
zip :: f a -> f b -> f (a, b)
class Apply f => Applicative f
where
pure:: a -> f a
instance Applicative f => P.Applicative f
where
pure = pure
f <*> x = uncurry ($) <$> zip f x
src/Monoidal/Applicative.hs:19:10: error:
• Could not deduce (Functor f)
arising from the superclasses of an instance declaration
from the context: Applicative f
bound by the instance declaration
at src/Monoidal/Applicative.hs:19:10-41
Possible fix:
add (Functor f) to the context of the instance declaration
• In the instance declaration for ‘P.Applicative f’
|
19 | instance Applicative f => P.Applicative f
I'm trying to do the following:
But I get the following error:
shouldn't the
Functor
constraint onApply
make this work?Interesting. Looks like a GHC bug.
it works if I add
Functor f
to the constraints explicitly apparentlylike
instance (Functor f, Applicative f) => P.Applicative f
That is weird