| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell98 |
Control.Applicative.Compat
- class Functor f => Applicative f where
- class Applicative f => Alternative f where
- newtype Const a b :: * -> * -> * = Const {
- getConst :: a
- newtype WrappedMonad m a :: (* -> *) -> * -> * = WrapMonad {
- unwrapMonad :: m a
- newtype WrappedArrow a b c :: (* -> * -> *) -> * -> * -> * = WrapArrow {
- unwrapArrow :: a b c
- newtype ZipList a :: * -> * = ZipList {
- getZipList :: [a]
Documentation
class Functor f => Applicative f where
A functor with application, providing operations to
A minimal complete definition must include implementations of these functions satisfying the following laws:
- identity
pureid<*>v = v- composition
pure(.)<*>u<*>v<*>w = u<*>(v<*>w)- homomorphism
puref<*>purex =pure(f x)- interchange
u
<*>purey =pure($y)<*>u
The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:
As a consequence of these laws, the Functor instance for f will satisfy
If f is also a Monad, it should satisfy
(which implies that pure and <*> satisfy the applicative functor laws).
Methods
pure :: a -> f a
Lift a value.
(<*>) :: f (a -> b) -> f a -> f b infixl 4
Sequential application.
(*>) :: f a -> f b -> f b infixl 4
Sequence actions, discarding the value of the first argument.
(<*) :: f a -> f b -> f a infixl 4
Sequence actions, discarding the value of the second argument.
Instances
| Applicative [] | |
| Applicative IO | |
| Applicative Id | |
| Applicative ZipList | |
| Applicative STM | |
| Applicative ReadPrec | |
| Applicative ReadP | |
| Applicative Maybe | |
| Applicative ((->) a) | |
| Applicative (Either e) | |
| Monoid a => Applicative ((,) a) | |
| Applicative (ST s) | |
| Applicative (StateL s) | |
| Applicative (StateR s) | |
| Monoid m => Applicative (Const m) | |
| Monad m => Applicative (WrappedMonad m) | |
| Applicative (ST s) | |
| Arrow a => Applicative (ArrowMonad a) | |
| Applicative (Proxy *) | |
| Arrow a => Applicative (WrappedArrow a b) | |
| Applicative f => Applicative (Alt * f) | |
| Typeable ((* -> *) -> Constraint) Applicative |
class Applicative f => Alternative f where
A monoid on applicative functors.
Minimal complete definition: empty and <|>.
If defined, some and many should be the least solutions
of the equations:
Methods
empty :: f a
The identity of <|>
(<|>) :: f a -> f a -> f a infixl 3
An associative binary operation
some :: f a -> f [a]
One or more.
many :: f a -> f [a]
Zero or more.
Instances
| Alternative [] | |
| Alternative STM | |
| Alternative ReadPrec | |
| Alternative ReadP | |
| Alternative Maybe | |
| MonadPlus m => Alternative (WrappedMonad m) | |
| ArrowPlus a => Alternative (ArrowMonad a) | |
| (ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) | |
| Alternative f => Alternative (Alt * f) | |
| Typeable ((* -> *) -> Constraint) Alternative |
newtype Const a b :: * -> * -> *
Instances
| Functor (Const m) | |
| Monoid m => Applicative (Const m) | |
| Foldable (Const m) | |
| Traversable (Const m) | |
| Generic1 (Const a) | |
| Eq a => Eq (Const a b) | |
| Ord a => Ord (Const a b) | |
| Read a => Read (Const a b) | |
| Show a => Show (Const a b) | |
| Generic (Const a b) | |
| Monoid a => Monoid (Const a b) | |
| type Rep1 (Const a) = D1 D1Const (C1 C1_0Const (S1 S1_0_0Const (Rec0 a))) | |
| type Rep (Const a b) = D1 D1Const (C1 C1_0Const (S1 S1_0_0Const (Rec0 a))) |
newtype WrappedMonad m a :: (* -> *) -> * -> *
Constructors
| WrapMonad | |
Fields
| |
Instances
| MonadPlus m => Alternative (WrappedMonad m) | |
| Monad m => Monad (WrappedMonad m) | |
| Monad m => Functor (WrappedMonad m) | |
| Monad m => Applicative (WrappedMonad m) | |
| Generic1 (WrappedMonad m) | |
| Generic (WrappedMonad m a) | |
| type Rep1 (WrappedMonad m) = D1 D1WrappedMonad (C1 C1_0WrappedMonad (S1 S1_0_0WrappedMonad (Rec1 m))) | |
| type Rep (WrappedMonad m a) = D1 D1WrappedMonad (C1 C1_0WrappedMonad (S1 S1_0_0WrappedMonad (Rec0 (m a)))) |
newtype WrappedArrow a b c :: (* -> * -> *) -> * -> * -> *
Constructors
| WrapArrow | |
Fields
| |
Instances
| (ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) | |
| Arrow a => Functor (WrappedArrow a b) | |
| Arrow a => Applicative (WrappedArrow a b) | |
| Generic1 (WrappedArrow a b) | |
| Generic (WrappedArrow a b c) | |
| type Rep1 (WrappedArrow a b) = D1 D1WrappedArrow (C1 C1_0WrappedArrow (S1 S1_0_0WrappedArrow (Rec1 (a b)))) | |
| type Rep (WrappedArrow a b c) = D1 D1WrappedArrow (C1 C1_0WrappedArrow (S1 S1_0_0WrappedArrow (Rec0 (a b c)))) |
newtype ZipList a :: * -> *
Lists, but with an Applicative functor based on zipping, so that
f<$>ZipListxs1<*>...<*>ZipListxsn =ZipList(zipWithn f xs1 ... xsn)
Constructors
| ZipList | |
Fields
| |
Instances
| Functor ZipList | |
| Applicative ZipList | |
| Generic1 ZipList | |
| Eq a => Eq (ZipList a) | |
| Ord a => Ord (ZipList a) | |
| Read a => Read (ZipList a) | |
| Show a => Show (ZipList a) | |
| Generic (ZipList a) | |
| type Rep1 ZipList = D1 D1ZipList (C1 C1_0ZipList (S1 S1_0_0ZipList (Rec1 []))) | |
| type Rep (ZipList a) = D1 D1ZipList (C1 C1_0ZipList (S1 S1_0_0ZipList (Rec0 [a]))) |