Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.
I'm trying to do the following:
import qualified Prelude as P
class Functor f => Apply f
zip :: f a -> f b -> f (a, b)
class Apply f => Applicative f
pure:: a -> f a
instance Applicative f => P.Applicative f
pure = pure
f <*> x = uncurry ($) <$> zip f x
But I get the following error:
• Could not deduce (Functor f)
arising from the superclasses of an instance declaration
from the context: Applicative f
bound by the instance declaration
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
shouldn't the Functor constraint on Apply make this work?
Interesting. Looks like a GHC bug.
it works if I add Functor f to the constraints explicitly apparently
like instance (Functor f, Applicative f) => P.Applicative f
instance (Functor f, Applicative f) => P.Applicative f
That is weird