из Control.Applicative (с) Conor McBride and Ross Paterson 2005
из Data.Functor.Constant (c) Ross Paterson 2010
(transformers package)
UPD. Росс ответил в кафе, что it was an accident
newtype Const a b = Const { getConst :: a }
instance Functor (Const m) where
fmap _ (Const v) = Const v
instance Monoid m => Applicative (Const m) where
pure _ = Const mempty
Const f <*> Const v = Const (f `mappend` v)
из Data.Functor.Constant (c) Ross Paterson 2010
(transformers package)
import Control.Applicative -- Sic!
...
newtype Constant a b = Constant { getConstant :: a }
instance Functor (Constant a) where
fmap f (Constant x) = Constant x
...
instance (Monoid a) => Applicative (Constant a) where
pure _ = Constant mempty
Constant x <*> Constant y = Constant (x `mappend` y)
UPD. Росс ответил в кафе, что it was an accident