base-compat-0.7.1: A compatibility layer for base

Safe HaskellSafe-Inferred
LanguageHaskell98

Control.Applicative.Compat

Synopsis

Documentation

class Functor f => Applicative f where

A functor with application, providing operations to

  • embed pure expressions (pure), and
  • sequence computations and combine their results (<*>).

A minimal complete definition must include implementations of these functions satisfying the following laws:

identity
pure id <*> v = v
composition
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
homomorphism
pure f <*> pure x = pure (f x)
interchange
u <*> pure y = 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).

Minimal complete definition

pure, (<*>)

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.

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:

Minimal complete definition

empty, (<|>)

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.

newtype Const a b :: * -> * -> *

Constructors

Const 

Fields

getConst :: a
 

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

unwrapMonad :: m a
 

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

unwrapArrow :: a b c
 

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 <$> ZipList xs1 <*> ... <*> ZipList xsn = ZipList (zipWithn f xs1 ... xsn)

Constructors

ZipList 

Fields

getZipList :: [a]
 

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])))