Add `liftA2` to Prelude
{-# LANGUAGE DeriveFunctor #-}
data Foo a = Foo a deriving (Functor)
instance Applicative (Foo) where
pure = Foo
Since base
shipped with GHC 8.2, this gives the following warning:
warning: [-Wmissing-methods]
• No explicit implementation for
either ‘<*>’ or ‘GHC.Base.liftA2’
• In the instance declaration for ‘Applicative Foo’
Trying to follow up on this literally,
instance Applicative Foo where
pure = Foo
GHC.Base.liftA2 f (Foo a) (Foo b) = Foo $ f a b
I get other errors:
‘GHC.Base.liftA2’ is not a (visible) method of class ‘Applicative’
|
10 | GHC.Base.liftA2 f (Foo a) (Foo b) = Foo $ f a b
| ^^^^^^^^^^^^^^^
Qualified name in binding position: GHC.Base.liftA2
|
10 | GHC.Base.liftA2 f (Foo a) (Foo b) = Foo $ f a b
| ^^^^^^^^^^^^^^^
GHC is giving me contradictory information here.
The workaround is import Control.Applicative
, but it seems inconsistent that some methods of Applicative
are exported by Prelude
and some not, especially those that comprise a MINIMAL
definition of an instance.
Proposal: export liftA2
also from Prelude.
Related: #13191 (closed), referenced in https://hackage.haskell.org/package/base-4.10.0.0/changelog