base-4.9.0.0: Basic libraries

CopyrightConor McBride and Ross Paterson 2005
LicenseBSD-style (see the LICENSE file in the distribution)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Control.Applicative

Contents

Description

This module describes a structure intermediate between a functor and a monad (technically, a strong lax monoidal functor). Compared with monads, this interface lacks the full power of the binding operation >>=, but

  • it has more instances.
  • it is sufficient for many uses, e.g. context-free parsing, or the Traversable class.
  • instances can perform analysis of computations before they are executed, and thus produce shared optimizations.

This interface was introduced for parsers by Niklas Röjemo, because it admits more sharing than the monadic interface. The names here are mostly based on parsing work by Doaitse Swierstra.

For more details, see Applicative Programming with Effects, by Conor McBride and Ross Paterson.

Synopsis

Applicative functors

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.

Instances

Applicative [] 

Methods

pure :: a -> [a]

(<*>) :: [a -> b] -> [a] -> [b]

(*>) :: [a] -> [b] -> [b]

(<*) :: [a] -> [b] -> [a]

Applicative Maybe 

Methods

pure :: a -> Maybe a

(<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b

(*>) :: Maybe a -> Maybe b -> Maybe b

(<*) :: Maybe a -> Maybe b -> Maybe a

Applicative IO 

Methods

pure :: a -> IO a

(<*>) :: IO (a -> b) -> IO a -> IO b

(*>) :: IO a -> IO b -> IO b

(<*) :: IO a -> IO b -> IO a

Applicative ReadP 

Methods

pure :: a -> ReadP a

(<*>) :: ReadP (a -> b) -> ReadP a -> ReadP b

(*>) :: ReadP a -> ReadP b -> ReadP b

(<*) :: ReadP a -> ReadP b -> ReadP a

Applicative ReadPrec 

Methods

pure :: a -> ReadPrec a

(<*>) :: ReadPrec (a -> b) -> ReadPrec a -> ReadPrec b

(*>) :: ReadPrec a -> ReadPrec b -> ReadPrec b

(<*) :: ReadPrec a -> ReadPrec b -> ReadPrec a

Applicative Last 

Methods

pure :: a -> Last a

(<*>) :: Last (a -> b) -> Last a -> Last b

(*>) :: Last a -> Last b -> Last b

(<*) :: Last a -> Last b -> Last a

Applicative First 

Methods

pure :: a -> First a

(<*>) :: First (a -> b) -> First a -> First b

(*>) :: First a -> First b -> First b

(<*) :: First a -> First b -> First a

Applicative Product 

Methods

pure :: a -> Product a

(<*>) :: Product (a -> b) -> Product a -> Product b

(*>) :: Product a -> Product b -> Product b

(<*) :: Product a -> Product b -> Product a

Applicative Sum 

Methods

pure :: a -> Sum a

(<*>) :: Sum (a -> b) -> Sum a -> Sum b

(*>) :: Sum a -> Sum b -> Sum b

(<*) :: Sum a -> Sum b -> Sum a

Applicative Dual 

Methods

pure :: a -> Dual a

(<*>) :: Dual (a -> b) -> Dual a -> Dual b

(*>) :: Dual a -> Dual b -> Dual b

(<*) :: Dual a -> Dual b -> Dual a

Applicative STM 

Methods

pure :: a -> STM a

(<*>) :: STM (a -> b) -> STM a -> STM b

(*>) :: STM a -> STM b -> STM b

(<*) :: STM a -> STM b -> STM a

Applicative ZipList 

Methods

pure :: a -> ZipList a

(<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b

(*>) :: ZipList a -> ZipList b -> ZipList b

(<*) :: ZipList a -> ZipList b -> ZipList a

Applicative Complex 

Methods

pure :: a -> Complex a

(<*>) :: Complex (a -> b) -> Complex a -> Complex b

(*>) :: Complex a -> Complex b -> Complex b

(<*) :: Complex a -> Complex b -> Complex a

Applicative NonEmpty 

Methods

pure :: a -> NonEmpty a

(<*>) :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b

(*>) :: NonEmpty a -> NonEmpty b -> NonEmpty b

(<*) :: NonEmpty a -> NonEmpty b -> NonEmpty a

Applicative Option 

Methods

pure :: a -> Option a

(<*>) :: Option (a -> b) -> Option a -> Option b

(*>) :: Option a -> Option b -> Option b

(<*) :: Option a -> Option b -> Option a

Applicative Last 

Methods

pure :: a -> Last a

(<*>) :: Last (a -> b) -> Last a -> Last b

(*>) :: Last a -> Last b -> Last b

(<*) :: Last a -> Last b -> Last a

Applicative First 

Methods

pure :: a -> First a

(<*>) :: First (a -> b) -> First a -> First b

(*>) :: First a -> First b -> First b

(<*) :: First a -> First b -> First a

Applicative Max 

Methods

pure :: a -> Max a

(<*>) :: Max (a -> b) -> Max a -> Max b

(*>) :: Max a -> Max b -> Max b

(<*) :: Max a -> Max b -> Max a

Applicative Min 

Methods

pure :: a -> Min a

(<*>) :: Min (a -> b) -> Min a -> Min b

(*>) :: Min a -> Min b -> Min b

(<*) :: Min a -> Min b -> Min a

Applicative Identity 

Methods

pure :: a -> Identity a

(<*>) :: Identity (a -> b) -> Identity a -> Identity b

(*>) :: Identity a -> Identity b -> Identity b

(<*) :: Identity a -> Identity b -> Identity a

Applicative ((->) a) 

Methods

pure :: a -> a -> a

(<*>) :: (a -> a -> b) -> (a -> a) -> a -> b

(*>) :: (a -> a) -> (a -> b) -> a -> b

(<*) :: (a -> a) -> (a -> b) -> a -> a

Applicative (Either e) 

Methods

pure :: a -> Either e a

(<*>) :: Either e (a -> b) -> Either e a -> Either e b

(*>) :: Either e a -> Either e b -> Either e b

(<*) :: Either e a -> Either e b -> Either e a

Monoid a => Applicative ((,) a) 

Methods

pure :: a -> (a, a)

(<*>) :: (a, a -> b) -> (a, a) -> (a, b)

(*>) :: (a, a) -> (a, b) -> (a, b)

(<*) :: (a, a) -> (a, b) -> (a, a)

Applicative (ST s) 

Methods

pure :: a -> ST s a

(<*>) :: ST s (a -> b) -> ST s a -> ST s b

(*>) :: ST s a -> ST s b -> ST s b

(<*) :: ST s a -> ST s b -> ST s a

Applicative (Proxy (TYPE Lifted)) 

Methods

pure :: a -> Proxy (TYPE Lifted) a

(<*>) :: Proxy (TYPE Lifted) (a -> b) -> Proxy (TYPE Lifted) a -> Proxy (TYPE Lifted) b

(*>) :: Proxy (TYPE Lifted) a -> Proxy (TYPE Lifted) b -> Proxy (TYPE Lifted) b

(<*) :: Proxy (TYPE Lifted) a -> Proxy (TYPE Lifted) b -> Proxy (TYPE Lifted) a

Arrow a => Applicative (ArrowMonad a) 

Methods

pure :: a -> ArrowMonad a a

(<*>) :: ArrowMonad a (a -> b) -> ArrowMonad a a -> ArrowMonad a b

(*>) :: ArrowMonad a a -> ArrowMonad a b -> ArrowMonad a b

(<*) :: ArrowMonad a a -> ArrowMonad a b -> ArrowMonad a a

Monad m => Applicative (WrappedMonad m) 

Methods

pure :: a -> WrappedMonad m a

(<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b

(*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b

(<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a

Applicative (ST s) 

Methods

pure :: a -> ST s a

(<*>) :: ST s (a -> b) -> ST s a -> ST s b

(*>) :: ST s a -> ST s b -> ST s b

(<*) :: ST s a -> ST s b -> ST s a

Applicative f => Applicative (Alt (TYPE Lifted) f) 

Methods

pure :: a -> Alt (TYPE Lifted) f a

(<*>) :: Alt (TYPE Lifted) f (a -> b) -> Alt (TYPE Lifted) f a -> Alt (TYPE Lifted) f b

(*>) :: Alt (TYPE Lifted) f a -> Alt (TYPE Lifted) f b -> Alt (TYPE Lifted) f b

(<*) :: Alt (TYPE Lifted) f a -> Alt (TYPE Lifted) f b -> Alt (TYPE Lifted) f a

Monoid m => Applicative (Const (TYPE Lifted) m) 

Methods

pure :: a -> Const (TYPE Lifted) m a

(<*>) :: Const (TYPE Lifted) m (a -> b) -> Const (TYPE Lifted) m a -> Const (TYPE Lifted) m b

(*>) :: Const (TYPE Lifted) m a -> Const (TYPE Lifted) m b -> Const (TYPE Lifted) m b

(<*) :: Const (TYPE Lifted) m a -> Const (TYPE Lifted) m b -> Const (TYPE Lifted) m a

Arrow a => Applicative (WrappedArrow a b) 

Methods

pure :: a -> WrappedArrow a b a

(<*>) :: WrappedArrow a b (a -> b) -> WrappedArrow a b a -> WrappedArrow a b b

(*>) :: WrappedArrow a b a -> WrappedArrow a b b -> WrappedArrow a b b

(<*) :: WrappedArrow a b a -> WrappedArrow a b b -> WrappedArrow a b a

(Applicative f, Applicative g) => Applicative (Product (TYPE Lifted) f g) 

Methods

pure :: a -> Product (TYPE Lifted) f g a

(<*>) :: Product (TYPE Lifted) f g (a -> b) -> Product (TYPE Lifted) f g a -> Product (TYPE Lifted) f g b

(*>) :: Product (TYPE Lifted) f g a -> Product (TYPE Lifted) f g b -> Product (TYPE Lifted) f g b

(<*) :: Product (TYPE Lifted) f g a -> Product (TYPE Lifted) f g b -> Product (TYPE Lifted) f g a

(Applicative f, Applicative g) => Applicative (Compose (TYPE Lifted) (TYPE Lifted) f g) 

Methods

pure :: a -> Compose (TYPE Lifted) (TYPE Lifted) f g a

(<*>) :: Compose (TYPE Lifted) (TYPE Lifted) f g (a -> b) -> Compose (TYPE Lifted) (TYPE Lifted) f g a -> Compose (TYPE Lifted) (TYPE Lifted) f g b

(*>) :: Compose (TYPE Lifted) (TYPE Lifted) f g a -> Compose (TYPE Lifted) (TYPE Lifted) f g b -> Compose (TYPE Lifted) (TYPE Lifted) f g b

(<*) :: Compose (TYPE Lifted) (TYPE Lifted) f g a -> Compose (TYPE Lifted) (TYPE Lifted) f g b -> Compose (TYPE Lifted) (TYPE Lifted) f g a

Alternatives

class Applicative f => Alternative f where

A monoid on applicative functors.

If defined, some and many should be the least solutions of the equations:

  • some v = (:) <$> v <*> many v
  • many v = some v <|> pure []

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.

Instances

Alternative [] 

Methods

empty :: [a]

(<|>) :: [a] -> [a] -> [a]

some :: [a] -> [[a]]

many :: [a] -> [[a]]

Alternative Maybe 

Methods

empty :: Maybe a

(<|>) :: Maybe a -> Maybe a -> Maybe a

some :: Maybe a -> Maybe [a]

many :: Maybe a -> Maybe [a]

Alternative IO 

Methods

empty :: IO a

(<|>) :: IO a -> IO a -> IO a

some :: IO a -> IO [a]

many :: IO a -> IO [a]

Alternative ReadP 

Methods

empty :: ReadP a

(<|>) :: ReadP a -> ReadP a -> ReadP a

some :: ReadP a -> ReadP [a]

many :: ReadP a -> ReadP [a]

Alternative ReadPrec 

Methods

empty :: ReadPrec a

(<|>) :: ReadPrec a -> ReadPrec a -> ReadPrec a

some :: ReadPrec a -> ReadPrec [a]

many :: ReadPrec a -> ReadPrec [a]

Alternative STM 

Methods

empty :: STM a

(<|>) :: STM a -> STM a -> STM a

some :: STM a -> STM [a]

many :: STM a -> STM [a]

Alternative Option 

Methods

empty :: Option a

(<|>) :: Option a -> Option a -> Option a

some :: Option a -> Option [a]

many :: Option a -> Option [a]

ArrowPlus a => Alternative (ArrowMonad a) 

Methods

empty :: ArrowMonad a a

(<|>) :: ArrowMonad a a -> ArrowMonad a a -> ArrowMonad a a

some :: ArrowMonad a a -> ArrowMonad a [a]

many :: ArrowMonad a a -> ArrowMonad a [a]

MonadPlus m => Alternative (WrappedMonad m) 
Alternative f => Alternative (Alt (TYPE Lifted) f) 

Methods

empty :: Alt (TYPE Lifted) f a

(<|>) :: Alt (TYPE Lifted) f a -> Alt (TYPE Lifted) f a -> Alt (TYPE Lifted) f a

some :: Alt (TYPE Lifted) f a -> Alt (TYPE Lifted) f [a]

many :: Alt (TYPE Lifted) f a -> Alt (TYPE Lifted) f [a]

(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) 

Methods

empty :: WrappedArrow a b a

(<|>) :: WrappedArrow a b a -> WrappedArrow a b a -> WrappedArrow a b a

some :: WrappedArrow a b a -> WrappedArrow a b [a]

many :: WrappedArrow a b a -> WrappedArrow a b [a]

(Alternative f, Alternative g) => Alternative (Product (TYPE Lifted) f g) 

Methods

empty :: Product (TYPE Lifted) f g a

(<|>) :: Product (TYPE Lifted) f g a -> Product (TYPE Lifted) f g a -> Product (TYPE Lifted) f g a

some :: Product (TYPE Lifted) f g a -> Product (TYPE Lifted) f g [a]

many :: Product (TYPE Lifted) f g a -> Product (TYPE Lifted) f g [a]

(Alternative f, Applicative g) => Alternative (Compose (TYPE Lifted) (TYPE Lifted) f g) 

Instances

newtype Const a b

The Const functor.

Constructors

Const 

Fields

Instances

Bifunctor (Const (TYPE Lifted)) 

Methods

bimap :: (a -> b) -> (c -> d) -> Const (TYPE Lifted) a c -> Const (TYPE Lifted) b d

first :: (a -> b) -> Const (TYPE Lifted) a c -> Const (TYPE Lifted) b c

second :: (b -> c) -> Const (TYPE Lifted) a b -> Const (TYPE Lifted) a c

Show2 (Const (TYPE Lifted)) 

Methods

liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Const (TYPE Lifted) a b -> ShowS

liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Const (TYPE Lifted) a b] -> ShowS

Read2 (Const (TYPE Lifted)) 

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Const (TYPE Lifted) a b)

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Const (TYPE Lifted) a b]

Ord2 (Const (TYPE Lifted)) 

Methods

liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Const (TYPE Lifted) a c -> Const (TYPE Lifted) b d -> Ordering

Eq2 (Const (TYPE Lifted)) 

Methods

liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Const (TYPE Lifted) a c -> Const (TYPE Lifted) b d -> Bool

Functor (Const (TYPE Lifted) m) 

Methods

fmap :: (a -> b) -> Const (TYPE Lifted) m a -> Const (TYPE Lifted) m b

(<$) :: a -> Const (TYPE Lifted) m b -> Const (TYPE Lifted) m a

Monoid m => Applicative (Const (TYPE Lifted) m) 

Methods

pure :: a -> Const (TYPE Lifted) m a

(<*>) :: Const (TYPE Lifted) m (a -> b) -> Const (TYPE Lifted) m a -> Const (TYPE Lifted) m b

(*>) :: Const (TYPE Lifted) m a -> Const (TYPE Lifted) m b -> Const (TYPE Lifted) m b

(<*) :: Const (TYPE Lifted) m a -> Const (TYPE Lifted) m b -> Const (TYPE Lifted) m a

Foldable (Const (TYPE Lifted) m) 

Methods

fold :: Monoid m => Const (TYPE Lifted) m m -> m

foldMap :: Monoid m => (a -> m) -> Const (TYPE Lifted) m a -> m

foldr :: (a -> b -> b) -> b -> Const (TYPE Lifted) m a -> b

foldr' :: (a -> b -> b) -> b -> Const (TYPE Lifted) m a -> b

foldl :: (b -> a -> b) -> b -> Const (TYPE Lifted) m a -> b

foldl' :: (b -> a -> b) -> b -> Const (TYPE Lifted) m a -> b

foldr1 :: (a -> a -> a) -> Const (TYPE Lifted) m a -> a

foldl1 :: (a -> a -> a) -> Const (TYPE Lifted) m a -> a

toList :: Const (TYPE Lifted) m a -> [a]

null :: Const (TYPE Lifted) m a -> Bool

length :: Const (TYPE Lifted) m a -> Int

elem :: Eq a => a -> Const (TYPE Lifted) m a -> Bool

maximum :: Ord a => Const (TYPE Lifted) m a -> a

minimum :: Ord a => Const (TYPE Lifted) m a -> a

sum :: Num a => Const (TYPE Lifted) m a -> a

product :: Num a => Const (TYPE Lifted) m a -> a

Traversable (Const (TYPE Lifted) m) 

Methods

traverse :: Applicative f => (a -> f b) -> Const (TYPE Lifted) m a -> f (Const (TYPE Lifted) m b)

sequenceA :: Applicative f => Const (TYPE Lifted) m (f a) -> f (Const (TYPE Lifted) m a)

mapM :: Monad m => (a -> m b) -> Const (TYPE Lifted) m a -> m (Const (TYPE Lifted) m b)

sequence :: Monad m => Const (TYPE Lifted) m (m a) -> m (Const (TYPE Lifted) m a)

Generic1 (Const (TYPE Lifted) a) 

Associated Types

type Rep1 (Const (TYPE Lifted) a :: * -> TYPE Lifted) :: * -> *

Methods

from1 :: Const (TYPE Lifted) a a -> Rep1 (Const (TYPE Lifted) a) a

to1 :: Rep1 (Const (TYPE Lifted) a) a -> Const (TYPE Lifted) a a

Show a => Show1 (Const (TYPE Lifted) a) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Const (TYPE Lifted) a a -> ShowS

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Const (TYPE Lifted) a a] -> ShowS

Read a => Read1 (Const (TYPE Lifted) a) 

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Const (TYPE Lifted) a a)

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Const (TYPE Lifted) a a]

Ord a => Ord1 (Const (TYPE Lifted) a) 

Methods

liftCompare :: (a -> b -> Ordering) -> Const (TYPE Lifted) a a -> Const (TYPE Lifted) a b -> Ordering

Eq a => Eq1 (Const (TYPE Lifted) a) 

Methods

liftEq :: (a -> b -> Bool) -> Const (TYPE Lifted) a a -> Const (TYPE Lifted) a b -> Bool

Bounded a => Bounded (Const k a b) 

Methods

minBound :: Const k a b

maxBound :: Const k a b

Enum a => Enum (Const k a b) 

Methods

succ :: Const k a b -> Const k a b

pred :: Const k a b -> Const k a b

toEnum :: Int -> Const k a b

fromEnum :: Const k a b -> Int

enumFrom :: Const k a b -> [Const k a b]

enumFromThen :: Const k a b -> Const k a b -> [Const k a b]

enumFromTo :: Const k a b -> Const k a b -> [Const k a b]

enumFromThenTo :: Const k a b -> Const k a b -> Const k a b -> [Const k a b]

Eq a => Eq (Const k a b) 

Methods

(==) :: Const k a b -> Const k a b -> Bool Source

(/=) :: Const k a b -> Const k a b -> Bool Source

Ord a => Ord (Const k a b) 

Methods

compare :: Const k a b -> Const k a b -> Ordering Source

(<) :: Const k a b -> Const k a b -> Bool Source

(<=) :: Const k a b -> Const k a b -> Bool Source

(>) :: Const k a b -> Const k a b -> Bool Source

(>=) :: Const k a b -> Const k a b -> Bool Source

max :: Const k a b -> Const k a b -> Const k a b Source

min :: Const k a b -> Const k a b -> Const k a b Source

Read a => Read (Const k a b)

This instance would be equivalent to the derived instances of the Const newtype if the runConst field were removed

Methods

readsPrec :: Int -> ReadS (Const k a b)

readList :: ReadS [Const k a b]

readPrec :: ReadPrec (Const k a b)

readListPrec :: ReadPrec [Const k a b]

Show a => Show (Const k a b)

This instance would be equivalent to the derived instances of the Const newtype if the runConst field were removed

Methods

showsPrec :: Int -> Const k a b -> ShowS

show :: Const k a b -> String

showList :: [Const k a b] -> ShowS

Ix a => Ix (Const k a b) 

Methods

range :: (Const k a b, Const k a b) -> [Const k a b]

index :: (Const k a b, Const k a b) -> Const k a b -> Int

unsafeIndex :: (Const k a b, Const k a b) -> Const k a b -> Int

inRange :: (Const k a b, Const k a b) -> Const k a b -> Bool

rangeSize :: (Const k a b, Const k a b) -> Int

unsafeRangeSize :: (Const k a b, Const k a b) -> Int

Generic (Const k a b) 

Associated Types

type Rep (Const k a b) :: * -> *

Methods

from :: Const k a b -> Rep (Const k a b) x

to :: Rep (Const k a b) x -> Const k a b

Semigroup a => Semigroup (Const k a b) 

Methods

(<>) :: Const k a b -> Const k a b -> Const k a b

sconcat :: NonEmpty (Const k a b) -> Const k a b

stimes :: Integral b => b -> Const k a b -> Const k a b

Monoid a => Monoid (Const k a b) 

Methods

mempty :: Const k a b

mappend :: Const k a b -> Const k a b -> Const k a b

mconcat :: [Const k a b] -> Const k a b

Storable a => Storable (Const k a b) 

Methods

sizeOf :: Const k a b -> Int

alignment :: Const k a b -> Int

peekElemOff :: Ptr (Const k a b) -> Int -> IO (Const k a b)

pokeElemOff :: Ptr (Const k a b) -> Int -> Const k a b -> IO ()

peekByteOff :: Ptr b -> Int -> IO (Const k a b)

pokeByteOff :: Ptr b -> Int -> Const k a b -> IO ()

peek :: Ptr (Const k a b) -> IO (Const k a b)

poke :: Ptr (Const k a b) -> Const k a b -> IO ()

type Rep1 (Const k a) = D1 (MetaData "Const" "Data.Functor.Const" "base" True) (C1 (MetaCons "Const" PrefixI True) (S1 (MetaSel (Just Symbol "getConst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) 
type Rep (Const k a b) = D1 (MetaData "Const" "Data.Functor.Const" "base" True) (C1 (MetaCons "Const" PrefixI True) (S1 (MetaSel (Just Symbol "getConst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) 

newtype WrappedMonad m a

Constructors

WrapMonad 

Fields

Instances

Monad m => Monad (WrappedMonad m) 

Methods

(>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b

(>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b

return :: a -> WrappedMonad m a

fail :: String -> WrappedMonad m a

Monad m => Functor (WrappedMonad m) 

Methods

fmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b

(<$) :: a -> WrappedMonad m b -> WrappedMonad m a

Monad m => Applicative (WrappedMonad m) 

Methods

pure :: a -> WrappedMonad m a

(<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b

(*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b

(<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a

Generic1 (WrappedMonad m) 

Associated Types

type Rep1 (WrappedMonad m :: * -> TYPE Lifted) :: * -> *

Methods

from1 :: WrappedMonad m a -> Rep1 (WrappedMonad m) a

to1 :: Rep1 (WrappedMonad m) a -> WrappedMonad m a

MonadPlus m => Alternative (WrappedMonad m) 
Generic (WrappedMonad m a) 

Associated Types

type Rep (WrappedMonad m a) :: * -> *

Methods

from :: WrappedMonad m a -> Rep (WrappedMonad m a) x

to :: Rep (WrappedMonad m a) x -> WrappedMonad m a

type Rep1 (WrappedMonad m) = D1 (MetaData "WrappedMonad" "Control.Applicative" "base" True) (C1 (MetaCons "WrapMonad" PrefixI True) (S1 (MetaSel (Just Symbol "unwrapMonad") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 m))) 
type Rep (WrappedMonad m a) = D1 (MetaData "WrappedMonad" "Control.Applicative" "base" True) (C1 (MetaCons "WrapMonad" PrefixI True) (S1 (MetaSel (Just Symbol "unwrapMonad") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (m a)))) 

newtype WrappedArrow a b c

Constructors

WrapArrow 

Fields

Instances

Arrow a => Functor (WrappedArrow a b) 

Methods

fmap :: (a -> b) -> WrappedArrow a b a -> WrappedArrow a b b

(<$) :: a -> WrappedArrow a b b -> WrappedArrow a b a

Arrow a => Applicative (WrappedArrow a b) 

Methods

pure :: a -> WrappedArrow a b a

(<*>) :: WrappedArrow a b (a -> b) -> WrappedArrow a b a -> WrappedArrow a b b

(*>) :: WrappedArrow a b a -> WrappedArrow a b b -> WrappedArrow a b b

(<*) :: WrappedArrow a b a -> WrappedArrow a b b -> WrappedArrow a b a

Generic1 (WrappedArrow a b) 

Associated Types

type Rep1 (WrappedArrow a b :: * -> TYPE Lifted) :: * -> *

Methods

from1 :: WrappedArrow a b a -> Rep1 (WrappedArrow a b) a

to1 :: Rep1 (WrappedArrow a b) a -> WrappedArrow a b a

(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) 

Methods

empty :: WrappedArrow a b a

(<|>) :: WrappedArrow a b a -> WrappedArrow a b a -> WrappedArrow a b a

some :: WrappedArrow a b a -> WrappedArrow a b [a]

many :: WrappedArrow a b a -> WrappedArrow a b [a]

Generic (WrappedArrow a b c) 

Associated Types

type Rep (WrappedArrow a b c) :: * -> *

Methods

from :: WrappedArrow a b c -> Rep (WrappedArrow a b c) x

to :: Rep (WrappedArrow a b c) x -> WrappedArrow a b c

type Rep1 (WrappedArrow a b) = D1 (MetaData "WrappedArrow" "Control.Applicative" "base" True) (C1 (MetaCons "WrapArrow" PrefixI True) (S1 (MetaSel (Just Symbol "unwrapArrow") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 (a b)))) 
type Rep (WrappedArrow a b c) = D1 (MetaData "WrappedArrow" "Control.Applicative" "base" True) (C1 (MetaCons "WrapArrow" PrefixI True) (S1 (MetaSel (Just Symbol "unwrapArrow") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (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

Instances

Functor ZipList 

Methods

fmap :: (a -> b) -> ZipList a -> ZipList b

(<$) :: a -> ZipList b -> ZipList a

Applicative ZipList 

Methods

pure :: a -> ZipList a

(<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b

(*>) :: ZipList a -> ZipList b -> ZipList b

(<*) :: ZipList a -> ZipList b -> ZipList a

Foldable ZipList 

Methods

fold :: Monoid m => ZipList m -> m

foldMap :: Monoid m => (a -> m) -> ZipList a -> m

foldr :: (a -> b -> b) -> b -> ZipList a -> b

foldr' :: (a -> b -> b) -> b -> ZipList a -> b

foldl :: (b -> a -> b) -> b -> ZipList a -> b

foldl' :: (b -> a -> b) -> b -> ZipList a -> b

foldr1 :: (a -> a -> a) -> ZipList a -> a

foldl1 :: (a -> a -> a) -> ZipList a -> a

toList :: ZipList a -> [a]

null :: ZipList a -> Bool

length :: ZipList a -> Int

elem :: Eq a => a -> ZipList a -> Bool

maximum :: Ord a => ZipList a -> a

minimum :: Ord a => ZipList a -> a

sum :: Num a => ZipList a -> a

product :: Num a => ZipList a -> a

Traversable ZipList 

Methods

traverse :: Applicative f => (a -> f b) -> ZipList a -> f (ZipList b)

sequenceA :: Applicative f => ZipList (f a) -> f (ZipList a)

mapM :: Monad m => (a -> m b) -> ZipList a -> m (ZipList b)

sequence :: Monad m => ZipList (m a) -> m (ZipList a)

Generic1 ZipList 

Associated Types

type Rep1 (ZipList :: * -> TYPE Lifted) :: * -> *

Methods

from1 :: ZipList a -> Rep1 ZipList a

to1 :: Rep1 ZipList a -> ZipList a

Eq a => Eq (ZipList a) 

Methods

(==) :: ZipList a -> ZipList a -> Bool Source

(/=) :: ZipList a -> ZipList a -> Bool Source

Ord a => Ord (ZipList a) 
Read a => Read (ZipList a) 
Show a => Show (ZipList a) 

Methods

showsPrec :: Int -> ZipList a -> ShowS

show :: ZipList a -> String

showList :: [ZipList a] -> ShowS

Generic (ZipList a) 

Associated Types

type Rep (ZipList a) :: * -> *

Methods

from :: ZipList a -> Rep (ZipList a) x

to :: Rep (ZipList a) x -> ZipList a

type Rep1 ZipList = D1 (MetaData "ZipList" "Control.Applicative" "base" True) (C1 (MetaCons "ZipList" PrefixI True) (S1 (MetaSel (Just Symbol "getZipList") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 []))) 
type Rep (ZipList a) = D1 (MetaData "ZipList" "Control.Applicative" "base" True) (C1 (MetaCons "ZipList" PrefixI True) (S1 (MetaSel (Just Symbol "getZipList") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [a]))) 

Utility functions

(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4

An infix synonym for fmap.

Examples

Convert from a Maybe Int to a Maybe String using show:

>>> show <$> Nothing
Nothing
>>> show <$> Just 3
Just "3"

Convert from an Either Int Int to an Either Int String using show:

>>> show <$> Left 17
Left 17
>>> show <$> Right 17
Right "17"

Double each element of a list:

>>> (*2) <$> [1,2,3]
[2,4,6]

Apply even to the second element of a pair:

>>> even <$> (2,2)
(2,True)

(<$) :: Functor f => a -> f b -> f a

Replace all locations in the input with the same value. The default definition is fmap . const, but this may be overridden with a more efficient version.

(<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4

A variant of <*> with the arguments reversed.

liftA :: Applicative f => (a -> b) -> f a -> f b

Lift a function to actions. This function may be used as a value for fmap in a Functor instance.

liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

Lift a binary function to actions.

liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d

Lift a ternary function to actions.

optional :: Alternative f => f a -> f (Maybe a)

One or none.