base-4.11.0.0: Basic libraries

Control.Applicative

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 Source #

A functor with application, providing operations to

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

A minimal complete definition must include implementations of pure and of either <*> or liftA2. If it defines both, then they must behave the same as their default definitions:

(<*>) = liftA2 id
liftA2 f x y = f <$> x <*> y Further, any definition must satisfy the following: 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

It may be useful to note that supposing

forall x y. p (q x y) = f x . g y

it follows from the above that

liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v

If f is also a Monad, it should satisfy

(which implies that pure and <*> satisfy the applicative functor laws).

Minimal complete definition

pure, ((<*>) | liftA2)

Methods

pure :: a -> f a Source #

Lift a value.

(<*>) :: f (a -> b) -> f a -> f b infixl 4 Source #

Sequential application.

A few functors support an implementation of <*> that is more efficient than the default one.

liftA2 :: (a -> b -> c) -> f a -> f b -> f c Source #

Lift a binary function to actions.

Some functors support an implementation of liftA2 that is more efficient than the default one. In particular, if fmap is an expensive operation, it is likely better to use liftA2 than to fmap over the structure and then use <*>.

(*>) :: f a -> f b -> f b infixl 4 Source #

Sequence actions, discarding the value of the first argument.

(<*) :: f a -> f b -> f a infixl 4 Source #

Sequence actions, discarding the value of the second argument.

Instances
 Source # Since: 2.1 Instance detailsMethodspure :: a -> [a] Source #(<*>) :: [a -> b] -> [a] -> [b] Source #liftA2 :: (a -> b -> c) -> [a] -> [b] -> [c] Source #(*>) :: [a] -> [b] -> [b] Source #(<*) :: [a] -> [b] -> [a] Source # Source # Since: 2.1 Instance detailsMethodspure :: a -> Maybe a Source #(<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b Source #liftA2 :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c Source #(*>) :: Maybe a -> Maybe b -> Maybe b Source #(<*) :: Maybe a -> Maybe b -> Maybe a Source # Source # Since: 2.1 Instance detailsMethodspure :: a -> IO a Source #(<*>) :: IO (a -> b) -> IO a -> IO b Source #liftA2 :: (a -> b -> c) -> IO a -> IO b -> IO c Source #(*>) :: IO a -> IO b -> IO b Source #(<*) :: IO a -> IO b -> IO a Source # Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> Par1 a Source #(<*>) :: Par1 (a -> b) -> Par1 a -> Par1 b Source #liftA2 :: (a -> b -> c) -> Par1 a -> Par1 b -> Par1 c Source #(*>) :: Par1 a -> Par1 b -> Par1 b Source #(<*) :: Par1 a -> Par1 b -> Par1 a Source # Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> NonEmpty a Source #(<*>) :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b Source #liftA2 :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c Source #(*>) :: NonEmpty a -> NonEmpty b -> NonEmpty b Source #(<*) :: NonEmpty a -> NonEmpty b -> NonEmpty a Source # Source # Since: 4.6.0.0 Instance detailsMethodspure :: a -> ReadP a Source #(<*>) :: ReadP (a -> b) -> ReadP a -> ReadP b Source #liftA2 :: (a -> b -> c) -> ReadP a -> ReadP b -> ReadP c Source #(*>) :: ReadP a -> ReadP b -> ReadP b Source #(<*) :: ReadP a -> ReadP b -> ReadP a Source # Source # Since: 4.6.0.0 Instance detailsMethodspure :: a -> ReadPrec a Source #(<*>) :: ReadPrec (a -> b) -> ReadPrec a -> ReadPrec b Source #liftA2 :: (a -> b -> c) -> ReadPrec a -> ReadPrec b -> ReadPrec c Source #(*>) :: ReadPrec a -> ReadPrec b -> ReadPrec b Source #(<*) :: ReadPrec a -> ReadPrec b -> ReadPrec a Source # Source # Since: 4.11.0.0 Instance detailsMethodspure :: a -> Down a Source #(<*>) :: Down (a -> b) -> Down a -> Down b Source #liftA2 :: (a -> b -> c) -> Down a -> Down b -> Down c Source #(*>) :: Down a -> Down b -> Down b Source #(<*) :: Down a -> Down b -> Down a Source # Source # Since: 4.8.0.0 Instance detailsMethodspure :: a -> Product a Source #(<*>) :: Product (a -> b) -> Product a -> Product b Source #liftA2 :: (a -> b -> c) -> Product a -> Product b -> Product c Source #(*>) :: Product a -> Product b -> Product b Source #(<*) :: Product a -> Product b -> Product a Source # Source # Since: 4.8.0.0 Instance detailsMethodspure :: a -> Sum a Source #(<*>) :: Sum (a -> b) -> Sum a -> Sum b Source #liftA2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c Source #(*>) :: Sum a -> Sum b -> Sum b Source #(<*) :: Sum a -> Sum b -> Sum a Source # Source # Since: 4.8.0.0 Instance detailsMethodspure :: a -> Dual a Source #(<*>) :: Dual (a -> b) -> Dual a -> Dual b Source #liftA2 :: (a -> b -> c) -> Dual a -> Dual b -> Dual c Source #(*>) :: Dual a -> Dual b -> Dual b Source #(<*) :: Dual a -> Dual b -> Dual a Source # Source # Instance detailsMethodspure :: a -> Last a Source #(<*>) :: Last (a -> b) -> Last a -> Last b Source #liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c Source #(*>) :: Last a -> Last b -> Last b Source #(<*) :: Last a -> Last b -> Last a Source # Source # Instance detailsMethodspure :: a -> First a Source #(<*>) :: First (a -> b) -> First a -> First b Source #liftA2 :: (a -> b -> c) -> First a -> First b -> First c Source #(*>) :: First a -> First b -> First b Source #(<*) :: First a -> First b -> First a Source # Source # Since: 4.8.0.0 Instance detailsMethodspure :: a -> STM a Source #(<*>) :: STM (a -> b) -> STM a -> STM b Source #liftA2 :: (a -> b -> c) -> STM a -> STM b -> STM c Source #(*>) :: STM a -> STM b -> STM b Source #(<*) :: STM a -> STM b -> STM a Source # Source # Since: 4.8.0.0 Instance detailsMethodspure :: a -> Identity a Source #(<*>) :: Identity (a -> b) -> Identity a -> Identity b Source #liftA2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c Source #(*>) :: Identity a -> Identity b -> Identity b Source #(<*) :: Identity a -> Identity b -> Identity a Source # Source # f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsN = 'ZipList' (zipWithN f xs1 ... xsN)where zipWithN refers to the zipWith function of the appropriate arity (zipWith, zipWith3, zipWith4, ...). For example:(\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..] = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..]) = ZipList {getZipList = ["a5","b6b6","c7c7c7"]}Since: 2.1 Instance detailsMethodspure :: a -> ZipList a Source #(<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b Source #liftA2 :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c Source #(*>) :: ZipList a -> ZipList b -> ZipList b Source #(<*) :: ZipList a -> ZipList b -> ZipList a Source # Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> Option a Source #(<*>) :: Option (a -> b) -> Option a -> Option b Source #liftA2 :: (a -> b -> c) -> Option a -> Option b -> Option c Source #(*>) :: Option a -> Option b -> Option b Source #(<*) :: Option a -> Option b -> Option a Source # Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> Last a Source #(<*>) :: Last (a -> b) -> Last a -> Last b Source #liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c Source #(*>) :: Last a -> Last b -> Last b Source #(<*) :: Last a -> Last b -> Last a Source # Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> First a Source #(<*>) :: First (a -> b) -> First a -> First b Source #liftA2 :: (a -> b -> c) -> First a -> First b -> First c Source #(*>) :: First a -> First b -> First b Source #(<*) :: First a -> First b -> First a Source # Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> Max a Source #(<*>) :: Max (a -> b) -> Max a -> Max b Source #liftA2 :: (a -> b -> c) -> Max a -> Max b -> Max c Source #(*>) :: Max a -> Max b -> Max b Source #(<*) :: Max a -> Max b -> Max a Source # Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> Min a Source #(<*>) :: Min (a -> b) -> Min a -> Min b Source #liftA2 :: (a -> b -> c) -> Min a -> Min b -> Min c Source #(*>) :: Min a -> Min b -> Min b Source #(<*) :: Min a -> Min b -> Min a Source # Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> Complex a Source #(<*>) :: Complex (a -> b) -> Complex a -> Complex b Source #liftA2 :: (a -> b -> c) -> Complex a -> Complex b -> Complex c Source #(*>) :: Complex a -> Complex b -> Complex b Source #(<*) :: Complex a -> Complex b -> Complex a Source # Source # Since: 3.0 Instance detailsMethodspure :: a -> Either e a Source #(<*>) :: Either e (a -> b) -> Either e a -> Either e b Source #liftA2 :: (a -> b -> c) -> Either e a -> Either e b -> Either e c Source #(*>) :: Either e a -> Either e b -> Either e b Source #(<*) :: Either e a -> Either e b -> Either e a Source # Applicative (U1 :: * -> *) Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> U1 a Source #(<*>) :: U1 (a -> b) -> U1 a -> U1 b Source #liftA2 :: (a -> b -> c) -> U1 a -> U1 b -> U1 c Source #(*>) :: U1 a -> U1 b -> U1 b Source #(<*) :: U1 a -> U1 b -> U1 a Source # Monoid a => Applicative ((,) a) Source # For tuples, the Monoid constraint on a determines how the first values merge. For example, Strings concatenate:("hello ", (+15)) <*> ("world!", 2002) ("hello world!",2017)Since: 2.1 Instance detailsMethodspure :: a0 -> (a, a0) Source #(<*>) :: (a, a0 -> b) -> (a, a0) -> (a, b) Source #liftA2 :: (a0 -> b -> c) -> (a, a0) -> (a, b) -> (a, c) Source #(*>) :: (a, a0) -> (a, b) -> (a, b) Source #(<*) :: (a, a0) -> (a, b) -> (a, a0) Source # Source # Since: 4.4.0.0 Instance detailsMethodspure :: a -> ST s a Source #(<*>) :: ST s (a -> b) -> ST s a -> ST s b Source #liftA2 :: (a -> b -> c) -> ST s a -> ST s b -> ST s c Source #(*>) :: ST s a -> ST s b -> ST s b Source #(<*) :: ST s a -> ST s b -> ST s a Source # Applicative (Proxy :: * -> *) Source # Since: 4.7.0.0 Instance detailsMethodspure :: a -> Proxy a Source #(<*>) :: Proxy (a -> b) -> Proxy a -> Proxy b Source #liftA2 :: (a -> b -> c) -> Proxy a -> Proxy b -> Proxy c Source #(*>) :: Proxy a -> Proxy b -> Proxy b Source #(<*) :: Proxy a -> Proxy b -> Proxy a Source # Arrow a => Applicative (ArrowMonad a) Source # Since: 4.6.0.0 Instance detailsMethodspure :: a0 -> ArrowMonad a a0 Source #(<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b Source #liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c Source #(*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b Source #(<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 Source # Monad m => Applicative (WrappedMonad m) Source # Since: 2.1 Instance detailsMethodspure :: a -> WrappedMonad m a Source #(<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source #liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c Source #(*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source #(<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a Source # Source # Since: 2.1 Instance detailsMethodspure :: a -> ST s a Source #(<*>) :: ST s (a -> b) -> ST s a -> ST s b Source #liftA2 :: (a -> b -> c) -> ST s a -> ST s b -> ST s c Source #(*>) :: ST s a -> ST s b -> ST s b Source #(<*) :: ST s a -> ST s b -> ST s a Source # Applicative f => Applicative (Rec1 f) Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> Rec1 f a Source #(<*>) :: Rec1 f (a -> b) -> Rec1 f a -> Rec1 f b Source #liftA2 :: (a -> b -> c) -> Rec1 f a -> Rec1 f b -> Rec1 f c Source #(*>) :: Rec1 f a -> Rec1 f b -> Rec1 f b Source #(<*) :: Rec1 f a -> Rec1 f b -> Rec1 f a Source # Applicative f => Applicative (Alt f) Source # Instance detailsMethodspure :: a -> Alt f a Source #(<*>) :: Alt f (a -> b) -> Alt f a -> Alt f b Source #liftA2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c Source #(*>) :: Alt f a -> Alt f b -> Alt f b Source #(<*) :: Alt f a -> Alt f b -> Alt f a Source # Monoid m => Applicative (Const m :: * -> *) Source # Since: 2.0.1 Instance detailsMethodspure :: a -> Const m a Source #(<*>) :: Const m (a -> b) -> Const m a -> Const m b Source #liftA2 :: (a -> b -> c) -> Const m a -> Const m b -> Const m c Source #(*>) :: Const m a -> Const m b -> Const m b Source #(<*) :: Const m a -> Const m b -> Const m a Source # Arrow a => Applicative (WrappedArrow a b) Source # Since: 2.1 Instance detailsMethodspure :: a0 -> WrappedArrow a b a0 Source #(<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source #liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c Source #(*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 Source #(<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source # Applicative ((->) a :: * -> *) Source # Since: 2.1 Instance detailsMethodspure :: a0 -> a -> a0 Source #(<*>) :: (a -> a0 -> b) -> (a -> a0) -> a -> b Source #liftA2 :: (a0 -> b -> c) -> (a -> a0) -> (a -> b) -> a -> c Source #(*>) :: (a -> a0) -> (a -> b) -> a -> b Source #(<*) :: (a -> a0) -> (a -> b) -> a -> a0 Source # (Applicative f, Applicative g) => Applicative (f :*: g) Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> (f :*: g) a Source #(<*>) :: (f :*: g) (a -> b) -> (f :*: g) a -> (f :*: g) b Source #liftA2 :: (a -> b -> c) -> (f :*: g) a -> (f :*: g) b -> (f :*: g) c Source #(*>) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) b Source #(<*) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) a Source # (Applicative f, Applicative g) => Applicative (Product f g) Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> Product f g a Source #(<*>) :: Product f g (a -> b) -> Product f g a -> Product f g b Source #liftA2 :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c Source #(*>) :: Product f g a -> Product f g b -> Product f g b Source #(<*) :: Product f g a -> Product f g b -> Product f g a Source # Applicative f => Applicative (M1 i c f) Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> M1 i c f a Source #(<*>) :: M1 i c f (a -> b) -> M1 i c f a -> M1 i c f b Source #liftA2 :: (a -> b -> c0) -> M1 i c f a -> M1 i c f b -> M1 i c f c0 Source #(*>) :: M1 i c f a -> M1 i c f b -> M1 i c f b Source #(<*) :: M1 i c f a -> M1 i c f b -> M1 i c f a Source # (Applicative f, Applicative g) => Applicative (f :.: g) Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> (f :.: g) a Source #(<*>) :: (f :.: g) (a -> b) -> (f :.: g) a -> (f :.: g) b Source #liftA2 :: (a -> b -> c) -> (f :.: g) a -> (f :.: g) b -> (f :.: g) c Source #(*>) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) b Source #(<*) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) a Source # (Applicative f, Applicative g) => Applicative (Compose f g) Source # Since: 4.9.0.0 Instance detailsMethodspure :: a -> Compose f g a Source #(<*>) :: Compose f g (a -> b) -> Compose f g a -> Compose f g b Source #liftA2 :: (a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c Source #(*>) :: Compose f g a -> Compose f g b -> Compose f g b Source #(<*) :: Compose f g a -> Compose f g b -> Compose f g a Source #

Alternatives

class Applicative f => Alternative f where Source #

A monoid on applicative functors.

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

Minimal complete definition

Methods

empty :: f a Source #

The identity of <|>

(<|>) :: f a -> f a -> f a infixl 3 Source #

An associative binary operation

some :: f a -> f [a] Source #

One or more.

many :: f a -> f [a] Source #

Zero or more.

Instances

Instances

newtype Const a b Source #

The Const functor.

Constructors

 Const FieldsgetConst :: a
Instances
 Generic1 (Const a :: k -> *) Source # Instance detailsAssociated Typestype Rep1 (Const a) :: k -> * Source # Methodsfrom1 :: Const a a0 -> Rep1 (Const a) a0 Source #to1 :: Rep1 (Const a) a0 -> Const a a0 Source # Show2 (Const :: * -> * -> *) Source # Since: 4.9.0.0 Instance detailsMethodsliftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Const a b -> ShowS Source #liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Const a b] -> ShowS Source # Read2 (Const :: * -> * -> *) Source # Since: 4.9.0.0 Instance detailsMethodsliftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Const a b) Source #liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Const a b] Source #liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Const a b) Source #liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Const a b] Source # Ord2 (Const :: * -> * -> *) Source # Since: 4.9.0.0 Instance detailsMethodsliftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Const a c -> Const b d -> Ordering Source # Eq2 (Const :: * -> * -> *) Source # Since: 4.9.0.0 Instance detailsMethodsliftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Const a c -> Const b d -> Bool Source # Bifunctor (Const :: * -> * -> *) Source # Since: 4.8.0.0 Instance detailsMethodsbimap :: (a -> b) -> (c -> d) -> Const a c -> Const b d Source #first :: (a -> b) -> Const a c -> Const b c Source #second :: (b -> c) -> Const a b -> Const a c Source # Bifoldable (Const :: * -> * -> *) Source # Since: 4.10.0.0 Instance detailsMethodsbifold :: Monoid m => Const m m -> m Source #bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Const a b -> m Source #bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Const a b -> c Source #bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Const a b -> c Source # Bitraversable (Const :: * -> * -> *) Source # Since: 4.10.0.0 Instance detailsMethodsbitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Const a b -> f (Const c d) Source # Functor (Const m :: * -> *) Source # Since: 2.1 Instance detailsMethodsfmap :: (a -> b) -> Const m a -> Const m b Source #(<) :: a -> Const m b -> Const m a Source # Monoid m => Applicative (Const m :: * -> *) Source # Since: 2.0.1 Instance detailsMethodspure :: a -> Const m a Source #(<*>) :: Const m (a -> b) -> Const m a -> Const m b Source #liftA2 :: (a -> b -> c) -> Const m a -> Const m b -> Const m c Source #(*>) :: Const m a -> Const m b -> Const m b Source #(<*) :: Const m a -> Const m b -> Const m a Source # Foldable (Const m :: * -> *) Source # Since: 4.7.0.0 Instance detailsMethodsfold :: Monoid m0 => Const m m0 -> m0 Source #foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source #foldr :: (a -> b -> b) -> b -> Const m a -> b Source #foldr' :: (a -> b -> b) -> b -> Const m a -> b Source #foldl :: (b -> a -> b) -> b -> Const m a -> b Source #foldl' :: (b -> a -> b) -> b -> Const m a -> b Source #foldr1 :: (a -> a -> a) -> Const m a -> a Source #foldl1 :: (a -> a -> a) -> Const m a -> a Source #toList :: Const m a -> [a] Source #null :: Const m a -> Bool Source #length :: Const m a -> Int Source #elem :: Eq a => a -> Const m a -> Bool Source #maximum :: Ord a => Const m a -> a Source #minimum :: Ord a => Const m a -> a Source #sum :: Num a => Const m a -> a Source #product :: Num a => Const m a -> a Source # Traversable (Const m :: * -> *) Source # Since: 4.7.0.0 Instance detailsMethodstraverse :: Applicative f => (a -> f b) -> Const m a -> f (Const m b) Source #sequenceA :: Applicative f => Const m (f a) -> f (Const m a) Source #mapM :: Monad m0 => (a -> m0 b) -> Const m a -> m0 (Const m b) Source #sequence :: Monad m0 => Const m (m0 a) -> m0 (Const m a) Source # Show a => Show1 (Const a :: * -> *) Source # Since: 4.9.0.0 Instance detailsMethodsliftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> Const a a0 -> ShowS Source #liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [Const a a0] -> ShowS Source # Read a => Read1 (Const a :: * -> *) Source # Since: 4.9.0.0 Instance detailsMethodsliftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Const a a0) Source #liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Const a a0] Source #liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Const a a0) Source #liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Const a a0] Source # Ord a => Ord1 (Const a :: * -> *) Source # Since: 4.9.0.0 Instance detailsMethodsliftCompare :: (a0 -> b -> Ordering) -> Const a a0 -> Const a b -> Ordering Source # Eq a => Eq1 (Const a :: * -> *) Source # Since: 4.9.0.0 Instance detailsMethodsliftEq :: (a0 -> b -> Bool) -> Const a a0 -> Const a b -> Bool Source # Bounded a => Bounded (Const a b) Source # Instance detailsMethodsminBound :: Const a b Source #maxBound :: Const a b Source # Enum a => Enum (Const a b) Source # Instance detailsMethodssucc :: Const a b -> Const a b Source #pred :: Const a b -> Const a b Source #toEnum :: Int -> Const a b Source #fromEnum :: Const a b -> Int Source #enumFrom :: Const a b -> [Const a b] Source #enumFromThen :: Const a b -> Const a b -> [Const a b] Source #enumFromTo :: Const a b -> Const a b -> [Const a b] Source #enumFromThenTo :: Const a b -> Const a b -> Const a b -> [Const a b] Source # Eq a => Eq (Const a b) Source # Instance detailsMethods(==) :: Const a b -> Const a b -> Bool #(/=) :: Const a b -> Const a b -> Bool # Floating a => Floating (Const a b) Source # Instance detailsMethodspi :: Const a b Source #exp :: Const a b -> Const a b Source #log :: Const a b -> Const a b Source #sqrt :: Const a b -> Const a b Source #(**) :: Const a b -> Const a b -> Const a b Source #logBase :: Const a b -> Const a b -> Const a b Source #sin :: Const a b -> Const a b Source #cos :: Const a b -> Const a b Source #tan :: Const a b -> Const a b Source #asin :: Const a b -> Const a b Source #acos :: Const a b -> Const a b Source #atan :: Const a b -> Const a b Source #sinh :: Const a b -> Const a b Source #cosh :: Const a b -> Const a b Source #tanh :: Const a b -> Const a b Source #asinh :: Const a b -> Const a b Source #acosh :: Const a b -> Const a b Source #atanh :: Const a b -> Const a b Source #log1p :: Const a b -> Const a b Source #expm1 :: Const a b -> Const a b Source #log1pexp :: Const a b -> Const a b Source #log1mexp :: Const a b -> Const a b Source # Fractional a => Fractional (Const a b) Source # Instance detailsMethods(/) :: Const a b -> Const a b -> Const a b Source #recip :: Const a b -> Const a b Source # Integral a => Integral (Const a b) Source # Instance detailsMethodsquot :: Const a b -> Const a b -> Const a b Source #rem :: Const a b -> Const a b -> Const a b Source #div :: Const a b -> Const a b -> Const a b Source #mod :: Const a b -> Const a b -> Const a b Source #quotRem :: Const a b -> Const a b -> (Const a b, Const a b) Source #divMod :: Const a b -> Const a b -> (Const a b, Const a b) Source #toInteger :: Const a b -> Integer Source # (Typeable k, Data a, Typeable b) => Data (Const a b) Source # Since: 4.10.0.0 Instance detailsMethodsgfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Const a b -> c (Const a b) Source #gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Const a b) Source #toConstr :: Const a b -> Constr Source #dataTypeOf :: Const a b -> DataType Source #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Const a b)) Source #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Const a b)) Source #gmapT :: (forall b0. Data b0 => b0 -> b0) -> Const a b -> Const a b Source #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Const a b -> r Source #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Const a b -> r Source #gmapQ :: (forall d. Data d => d -> u) -> Const a b -> [u] Source #gmapQi :: Int -> (forall d. Data d => d -> u) -> Const a b -> u Source #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) Source #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) Source #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) Source # Num a => Num (Const a b) Source # Instance detailsMethods(+) :: Const a b -> Const a b -> Const a b Source #(-) :: Const a b -> Const a b -> Const a b Source #(*) :: Const a b -> Const a b -> Const a b Source #negate :: Const a b -> Const a b Source #abs :: Const a b -> Const a b Source #signum :: Const a b -> Const a b Source # Ord a => Ord (Const a b) Source # Instance detailsMethodscompare :: Const a b -> Const a b -> Ordering #(<) :: Const a b -> Const a b -> Bool #(<=) :: Const a b -> Const a b -> Bool #(>) :: Const a b -> Const a b -> Bool #(>=) :: Const a b -> Const a b -> Bool #max :: Const a b -> Const a b -> Const a b #min :: Const a b -> Const a b -> Const a b # Read a => Read (Const a b) Source # This instance would be equivalent to the derived instances of the Const newtype if the runConst field were removedSince: 4.8.0.0 Instance detailsMethodsreadsPrec :: Int -> ReadS (Const a b) Source #readList :: ReadS [Const a b] Source #readPrec :: ReadPrec (Const a b) Source # Real a => Real (Const a b) Source # Instance detailsMethodstoRational :: Const a b -> Rational Source # RealFloat a => RealFloat (Const a b) Source # Instance detailsMethodsfloatRadix :: Const a b -> Integer Source #floatDigits :: Const a b -> Int Source #floatRange :: Const a b -> (Int, Int) Source #decodeFloat :: Const a b -> (Integer, Int) Source #encodeFloat :: Integer -> Int -> Const a b Source #exponent :: Const a b -> Int Source #significand :: Const a b -> Const a b Source #scaleFloat :: Int -> Const a b -> Const a b Source #isNaN :: Const a b -> Bool Source #isInfinite :: Const a b -> Bool Source #isDenormalized :: Const a b -> Bool Source #isNegativeZero :: Const a b -> Bool Source #isIEEE :: Const a b -> Bool Source #atan2 :: Const a b -> Const a b -> Const a b Source # RealFrac a => RealFrac (Const a b) Source # Instance detailsMethodsproperFraction :: Integral b0 => Const a b -> (b0, Const a b) Source #truncate :: Integral b0 => Const a b -> b0 Source #round :: Integral b0 => Const a b -> b0 Source #ceiling :: Integral b0 => Const a b -> b0 Source #floor :: Integral b0 => Const a b -> b0 Source # Show a => Show (Const a b) Source # This instance would be equivalent to the derived instances of the Const newtype if the runConst field were removedSince: 4.8.0.0 Instance detailsMethodsshowsPrec :: Int -> Const a b -> ShowS Source #show :: Const a b -> String Source #showList :: [Const a b] -> ShowS Source # Ix a => Ix (Const a b) Source # Instance detailsMethodsrange :: (Const a b, Const a b) -> [Const a b] Source #index :: (Const a b, Const a b) -> Const a b -> Int Source #unsafeIndex :: (Const a b, Const a b) -> Const a b -> IntinRange :: (Const a b, Const a b) -> Const a b -> Bool Source #rangeSize :: (Const a b, Const a b) -> Int Source #unsafeRangeSize :: (Const a b, Const a b) -> Int IsString a => IsString (Const a b) Source # Since: 4.9.0.0 Instance detailsMethodsfromString :: String -> Const a b Source # Generic (Const a b) Source # Instance detailsAssociated Typestype Rep (Const a b) :: * -> * Source # Methodsfrom :: Const a b -> Rep (Const a b) x Source #to :: Rep (Const a b) x -> Const a b Source # Semigroup a => Semigroup (Const a b) Source # Instance detailsMethods(<>) :: Const a b -> Const a b -> Const a b Source #sconcat :: NonEmpty (Const a b) -> Const a b Source #stimes :: Integral b0 => b0 -> Const a b -> Const a b Source # Monoid a => Monoid (Const a b) Source # Instance detailsMethodsmempty :: Const a b Source #mappend :: Const a b -> Const a b -> Const a b Source #mconcat :: [Const a b] -> Const a b Source # FiniteBits a => FiniteBits (Const a b) Source # Instance detailsMethodsfiniteBitSize :: Const a b -> Int Source #countLeadingZeros :: Const a b -> Int Source # Bits a => Bits (Const a b) Source # Instance detailsMethods(.&.) :: Const a b -> Const a b -> Const a b Source #(.|.) :: Const a b -> Const a b -> Const a b Source #xor :: Const a b -> Const a b -> Const a b Source #complement :: Const a b -> Const a b Source #shift :: Const a b -> Int -> Const a b Source #rotate :: Const a b -> Int -> Const a b Source #zeroBits :: Const a b Source #bit :: Int -> Const a b Source #setBit :: Const a b -> Int -> Const a b Source #clearBit :: Const a b -> Int -> Const a b Source #complementBit :: Const a b -> Int -> Const a b Source #testBit :: Const a b -> Int -> Bool Source #bitSizeMaybe :: Const a b -> Maybe Int Source #bitSize :: Const a b -> Int Source #isSigned :: Const a b -> Bool Source #shiftL :: Const a b -> Int -> Const a b Source #unsafeShiftL :: Const a b -> Int -> Const a b Source #shiftR :: Const a b -> Int -> Const a b Source #unsafeShiftR :: Const a b -> Int -> Const a b Source #rotateL :: Const a b -> Int -> Const a b Source #rotateR :: Const a b -> Int -> Const a b Source #popCount :: Const a b -> Int Source # Storable a => Storable (Const a b) Source # Instance detailsMethodssizeOf :: Const a b -> Int Source #alignment :: Const a b -> Int Source #peekElemOff :: Ptr (Const a b) -> Int -> IO (Const a b) Source #pokeElemOff :: Ptr (Const a b) -> Int -> Const a b -> IO () Source #peekByteOff :: Ptr b0 -> Int -> IO (Const a b) Source #pokeByteOff :: Ptr b0 -> Int -> Const a b -> IO () Source #peek :: Ptr (Const a b) -> IO (Const a b) Source #poke :: Ptr (Const a b) -> Const a b -> IO () Source # type Rep1 (Const a :: k -> *) Source # Instance detailstype Rep1 (Const a :: k -> *) = D1 (MetaData "Const" "Data.Functor.Const" "base" True) (C1 (MetaCons "Const" PrefixI True) (S1 (MetaSel (Just "getConst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) type Rep (Const a b) Source # Instance detailstype Rep (Const a b) = D1 (MetaData "Const" "Data.Functor.Const" "base" True) (C1 (MetaCons "Const" PrefixI True) (S1 (MetaSel (Just "getConst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) newtype WrappedMonad m a Source # Constructors  WrapMonad FieldsunwrapMonad :: m a Instances  Monad m => Monad (WrappedMonad m) Source # Instance detailsMethods(>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b Source #(>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source #return :: a -> WrappedMonad m a Source # Monad m => Functor (WrappedMonad m) Source # Since: 2.1 Instance detailsMethodsfmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source #(<) :: a -> WrappedMonad m b -> WrappedMonad m a Source # Monad m => Applicative (WrappedMonad m) Source # Since: 2.1 Instance detailsMethodspure :: a -> WrappedMonad m a Source #(<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source #liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c Source #(*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source #(<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a Source # Source # Since: 2.1 Instance detailsMethods(<|>) :: WrappedMonad m a -> WrappedMonad m a -> WrappedMonad m a Source #some :: WrappedMonad m a -> WrappedMonad m [a] Source #many :: WrappedMonad m a -> WrappedMonad m [a] Source # Generic1 (WrappedMonad m :: * -> *) Source # Instance detailsAssociated Typestype Rep1 (WrappedMonad m) :: k -> * Source # Methodsfrom1 :: WrappedMonad m a -> Rep1 (WrappedMonad m) a Source #to1 :: Rep1 (WrappedMonad m) a -> WrappedMonad m a Source # Generic (WrappedMonad m a) Source # Instance detailsAssociated Typestype Rep (WrappedMonad m a) :: * -> * Source # Methodsfrom :: WrappedMonad m a -> Rep (WrappedMonad m a) x Source #to :: Rep (WrappedMonad m a) x -> WrappedMonad m a Source # type Rep1 (WrappedMonad m :: * -> *) Source # Instance detailstype Rep1 (WrappedMonad m :: * -> *) = D1 (MetaData "WrappedMonad" "Control.Applicative" "base" True) (C1 (MetaCons "WrapMonad" PrefixI True) (S1 (MetaSel (Just "unwrapMonad") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 m))) type Rep (WrappedMonad m a) Source # Instance detailstype Rep (WrappedMonad m a) = D1 (MetaData "WrappedMonad" "Control.Applicative" "base" True) (C1 (MetaCons "WrapMonad" PrefixI True) (S1 (MetaSel (Just "unwrapMonad") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (m a))))

newtype WrappedArrow a b c Source #

Constructors

 WrapArrow FieldsunwrapArrow :: a b c
Instances
 Generic1 (WrappedArrow a b :: * -> *) Source # Instance detailsAssociated Typestype Rep1 (WrappedArrow a b) :: k -> * Source # Methodsfrom1 :: WrappedArrow a b a0 -> Rep1 (WrappedArrow a b) a0 Source #to1 :: Rep1 (WrappedArrow a b) a0 -> WrappedArrow a b a0 Source # Arrow a => Functor (WrappedArrow a b) Source # Since: 2.1 Instance detailsMethodsfmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source #(<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source # Arrow a => Applicative (WrappedArrow a b) Source # Since: 2.1 Instance detailsMethodspure :: a0 -> WrappedArrow a b a0 Source #(<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source #liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c Source #(*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 Source #(<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source # (ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) Source # Since: 2.1 Instance detailsMethodsempty :: WrappedArrow a b a0 Source #(<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 Source #some :: WrappedArrow a b a0 -> WrappedArrow a b [a0] Source #many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] Source # Generic (WrappedArrow a b c) Source # Instance detailsAssociated Typestype Rep (WrappedArrow a b c) :: * -> * Source # Methodsfrom :: WrappedArrow a b c -> Rep (WrappedArrow a b c) x Source #to :: Rep (WrappedArrow a b c) x -> WrappedArrow a b c Source # type Rep1 (WrappedArrow a b :: * -> *) Source # Instance detailstype Rep1 (WrappedArrow a b :: * -> *) = D1 (MetaData "WrappedArrow" "Control.Applicative" "base" True) (C1 (MetaCons "WrapArrow" PrefixI True) (S1 (MetaSel (Just "unwrapArrow") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 (a b)))) type Rep (WrappedArrow a b c) Source # Instance detailstype Rep (WrappedArrow a b c) = D1 (MetaData "WrappedArrow" "Control.Applicative" "base" True) (C1 (MetaCons "WrapArrow" PrefixI True) (S1 (MetaSel (Just "unwrapArrow") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (a b c)))) newtype ZipList a Source # Lists, but with an Applicative functor based on zipping. Constructors  ZipList FieldsgetZipList :: [a] Instances  Source # Instance detailsMethodsfmap :: (a -> b) -> ZipList a -> ZipList b Source #(<$) :: a -> ZipList b -> ZipList a Source # Source # f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsN = 'ZipList' (zipWithN f xs1 ... xsN)where zipWithN refers to the zipWith function of the appropriate arity (zipWith, zipWith3, zipWith4, ...). For example:(\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..] = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..]) = ZipList {getZipList = ["a5","b6b6","c7c7c7"]}Since: 2.1 Instance detailsMethodspure :: a -> ZipList a Source #(<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b Source #liftA2 :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c Source #(*>) :: ZipList a -> ZipList b -> ZipList b Source #(<*) :: ZipList a -> ZipList b -> ZipList a Source # Source # Instance detailsMethodsfold :: Monoid m => ZipList m -> m Source #foldMap :: Monoid m => (a -> m) -> ZipList a -> m Source #foldr :: (a -> b -> b) -> b -> ZipList a -> b Source #foldr' :: (a -> b -> b) -> b -> ZipList a -> b Source #foldl :: (b -> a -> b) -> b -> ZipList a -> b Source #foldl' :: (b -> a -> b) -> b -> ZipList a -> b Source #foldr1 :: (a -> a -> a) -> ZipList a -> a Source #foldl1 :: (a -> a -> a) -> ZipList a -> a Source #toList :: ZipList a -> [a] Source #null :: ZipList a -> Bool Source #length :: ZipList a -> Int Source #elem :: Eq a => a -> ZipList a -> Bool Source #maximum :: Ord a => ZipList a -> a Source #minimum :: Ord a => ZipList a -> a Source #sum :: Num a => ZipList a -> a Source #product :: Num a => ZipList a -> a Source # Source # Since: 4.9.0.0 Instance detailsMethodstraverse :: Applicative f => (a -> f b) -> ZipList a -> f (ZipList b) Source #sequenceA :: Applicative f => ZipList (f a) -> f (ZipList a) Source #mapM :: Monad m => (a -> m b) -> ZipList a -> m (ZipList b) Source #sequence :: Monad m => ZipList (m a) -> m (ZipList a) Source # Source # Since: 4.11.0.0 Instance detailsMethods(<|>) :: ZipList a -> ZipList a -> ZipList a Source #some :: ZipList a -> ZipList [a] Source #many :: ZipList a -> ZipList [a] Source # Eq a => Eq (ZipList a) Source # Instance detailsMethods(==) :: ZipList a -> ZipList a -> Bool #(/=) :: ZipList a -> ZipList a -> Bool # Ord a => Ord (ZipList a) Source # Instance detailsMethodscompare :: ZipList a -> ZipList a -> Ordering #(<) :: ZipList a -> ZipList a -> Bool #(<=) :: ZipList a -> ZipList a -> Bool #(>) :: ZipList a -> ZipList a -> Bool #(>=) :: ZipList a -> ZipList a -> Bool #max :: ZipList a -> ZipList a -> ZipList a #min :: ZipList a -> ZipList a -> ZipList a # Read a => Read (ZipList a) Source # Instance detailsMethods Show a => Show (ZipList a) Source # Instance detailsMethodsshowsPrec :: Int -> ZipList a -> ShowS Source #show :: ZipList a -> String Source #showList :: [ZipList a] -> ShowS Source # Source # Instance detailsAssociated Typestype Rep (ZipList a) :: * -> * Source # Methodsfrom :: ZipList a -> Rep (ZipList a) x Source #to :: Rep (ZipList a) x -> ZipList a Source # Source # Instance detailsAssociated Typestype Rep1 ZipList :: k -> * Source # Methodsto1 :: Rep1 ZipList a -> ZipList a Source # type Rep (ZipList a) Source # Instance detailstype Rep (ZipList a) = D1 (MetaData "ZipList" "Control.Applicative" "base" True) (C1 (MetaCons "ZipList" PrefixI True) (S1 (MetaSel (Just "getZipList") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [a]))) type Rep1 ZipList Source # Instance detailstype Rep1 ZipList = D1 (MetaData "ZipList" "Control.Applicative" "base" True) (C1 (MetaCons "ZipList" PrefixI True) (S1 (MetaSel (Just "getZipList") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 [])))

Utility functions

(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 Source # An infix synonym for fmap. The name of this operator is an allusion to$. Note the similarities between their types:

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

Whereas $is function application, <$> is function application lifted over a Functor.

Examples

Expand

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 infixl 4 Source #

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 Source #

A variant of <*> with the arguments reversed.

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

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

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

Lift a ternary function to actions.

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

One or none.