base-4.10.1.0: Basic libraries

Copyright | Conor McBride and Ross Paterson 2005
License | BSD-style (see the LICENSE file in the distribution)
Maintainer | libraries@haskell.org
Stability | experimental
Portability | portable
Safe Haskell | Trustworthy
Language | Haskell2010

Control.Applicative

Contents

- Applicative functors
- Alternatives
- Instances
- Utility functions

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

- 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]
  }
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- (<$) :: Functor f => a -> f b -> f a
- (<**>) :: Applicative f => f a -> f (a -> b) -> f b
- liftA :: Applicative f => (a -> b) -> f a -> f b
- liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- optional :: Alternative f => f a -> f (Maybe a)

# 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 (`<*>` 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:

-     u *> v = (id <$ u) <*> v

-     u <* v = liftA2 const u v

As a consequence of these laws, the `Functor` instance for `f` will satisfy

-     fmap f x = pure f <*> x

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

-     pure = return

-     (<*>) = ap

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

Minimal complete definition

pure, ((<*>) | liftA2)

Methods

pure :: a -> f a #

Lift a value.

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

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 #

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 #

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 [] # | Since: 2.1
Methods pure :: a -> [a] # (<*>) :: [a -> b] -> [a] -> [b] # liftA2 :: (a -> b -> c) -> [a] -> [b] -> [c] # (*>) :: [a] -> [b] -> [b] # (<*) :: [a] -> [b] -> [a] #
Applicative Maybe # | Since: 2.1
Methods pure :: a -> Maybe a # (<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b # liftA2 :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c # (*>) :: Maybe a -> Maybe b -> Maybe b # (<*) :: Maybe a -> Maybe b -> Maybe a #
Applicative IO # | Since: 2.1
Methods pure :: a -> IO a # (<*>) :: IO (a -> b) -> IO a -> IO b # liftA2 :: (a -> b -> c) -> IO a -> IO b -> IO c # (*>) :: IO a -> IO b -> IO b # (<*) :: IO a -> IO b -> IO a #
Applicative Par1 # | Since: 4.9.0.0
Methods pure :: a -> Par1 a # (<*>) :: Par1 (a -> b) -> Par1 a -> Par1 b # liftA2 :: (a -> b -> c) -> Par1 a -> Par1 b -> Par1 c # (*>) :: Par1 a -> Par1 b -> Par1 b # (<*) :: Par1 a -> Par1 b -> Par1 a #
Applicative ReadP # | Since: 4.6.0.0
Methods pure :: a -> ReadP a # (<*>) :: ReadP (a -> b) -> ReadP a -> ReadP b # liftA2 :: (a -> b -> c) -> ReadP a -> ReadP b -> ReadP c # (*>) :: ReadP a -> ReadP b -> ReadP b # (<*) :: ReadP a -> ReadP b -> ReadP a #
Applicative ReadPrec # | Since: 4.6.0.0
Methods pure :: a -> ReadPrec a # (<*>) :: ReadPrec (a -> b) -> ReadPrec a -> ReadPrec b # liftA2 :: (a -> b -> c) -> ReadPrec a -> ReadPrec b -> ReadPrec c # (*>) :: 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 # liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c # (*>) :: 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 # liftA2 :: (a -> b -> c) -> First a -> First b -> First c # (*>) :: First a -> First b -> First b # (<*) :: First a -> First b -> First a #
Applicative Product # | Since: 4.8.0.0
Methods pure :: a -> Product a # (<*>) :: Product (a -> b) -> Product a -> Product b # liftA2 :: (a -> b -> c) -> Product a -> Product b -> Product c # (*>) :: Product a -> Product b -> Product b # (<*) :: Product a -> Product b -> Product a #
Applicative Sum # | Since: 4.8.0.0
Methods pure :: a -> Sum a # (<*>) :: Sum (a -> b) -> Sum a -> Sum b # liftA2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c # (*>) :: Sum a -> Sum b -> Sum b # (<*) :: Sum a -> Sum b -> Sum a #
Applicative Dual # | Since: 4.8.0.0
Methods pure :: a -> Dual a # (<*>) :: Dual (a -> b) -> Dual a -> Dual b # liftA2 :: (a -> b -> c) -> Dual a -> Dual b -> Dual c # (*>) :: Dual a -> Dual b -> Dual b # (<*) :: Dual a -> Dual b -> Dual a #
Applicative STM # | Since: 4.8.0.0
Methods pure :: a -> STM a # (<*>) :: STM (a -> b) -> STM a -> STM b # liftA2 :: (a -> b -> c) -> STM a -> STM b -> STM c # (*>) :: STM a -> STM b -> STM b # (<*) :: STM a -> STM b -> STM a #
Applicative Identity # | Since: 4.8.0.0
Methods pure :: a -> Identity a # (<*>) :: Identity (a -> b) -> Identity a -> Identity b # liftA2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c # (*>) :: Identity a -> Identity b -> Identity b # (<*) :: Identity a -> Identity b -> Identity a #

Applicative ZipList #

    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

Methods pure :: a -> ZipList a # (<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b # liftA2 :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c # (*>) :: ZipList a -> ZipList b -> ZipList b # (<*) :: ZipList a -> ZipList b -> ZipList a #
Applicative NonEmpty # | Since: 4.9.0.0
Methods pure :: a -> NonEmpty a # (<*>) :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b # liftA2 :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c # (*>) :: NonEmpty a -> NonEmpty b -> NonEmpty b # (<*) :: NonEmpty a -> NonEmpty b -> NonEmpty a #
Applicative Option # | Since: 4.9.0.0
Methods pure :: a -> Option a # (<*>) :: Option (a -> b) -> Option a -> Option b # liftA2 :: (a -> b -> c) -> Option a -> Option b -> Option c # (*>) :: Option a -> Option b -> Option b # (<*) :: Option a -> Option b -> Option a #
Applicative Last # | Since: 4.9.0.0
Methods pure :: a -> Last a # (<*>) :: Last (a -> b) -> Last a -> Last b # liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c # (*>) :: Last a -> Last b -> Last b # (<*) :: Last a -> Last b -> Last a #
Applicative First # | Since: 4.9.0.0
Methods pure :: a -> First a # (<*>) :: First (a -> b) -> First a -> First b # liftA2 :: (a -> b -> c) -> First a -> First b -> First c # (*>) :: First a -> First b -> First b # (<*) :: First a -> First b -> First a #
Applicative Max # | Since: 4.9.0.0
Methods pure :: a -> Max a # (<*>) :: Max (a -> b) -> Max a -> Max b # liftA2 :: (a -> b -> c) -> Max a -> Max b -> Max c # (*>) :: Max a -> Max b -> Max b # (<*) :: Max a -> Max b -> Max a #
Applicative Min # | Since: 4.9.0.0
Methods pure :: a -> Min a # (<*>) :: Min (a -> b) -> Min a -> Min b # liftA2 :: (a -> b -> c) -> Min a -> Min b -> Min c # (*>) :: Min a -> Min b -> Min b # (<*) :: Min a -> Min b -> Min a #
Applicative Complex # | Since: 4.9.0.0
Methods pure :: a -> Complex a # (<*>) :: Complex (a -> b) -> Complex a -> Complex b # liftA2 :: (a -> b -> c) -> Complex a -> Complex b -> Complex c # (*>) :: Complex a -> Complex b -> Complex b # (<*) :: Complex a -> Complex b -> Complex a #
Applicative (Either e) # | Since: 3.0
Methods pure :: a -> Either e a # (<*>) :: Either e (a -> b) -> Either e a -> Either e b # liftA2 :: (a -> b -> c) -> Either e a -> Either e b -> Either e c # (*>) :: Either e a -> Either e b -> Either e b # (<*) :: Either e a -> Either e b -> Either e a #
Applicative (U1 *) # | Since: 4.9.0.0
Methods pure :: a -> U1 * a # (<*>) :: U1 * (a -> b) -> U1 * a -> U1 * b # liftA2 :: (a -> b -> c) -> U1 * a -> U1 * b -> U1 * c # (*>) :: U1 * a -> U1 * b -> U1 * b # (<*) :: U1 * a -> U1 * b -> U1 * a #

Monoid a => Applicative ((,) a) #

For tuples, the `Monoid` constraint on `a` determines how the first values merge. For example, `String`s concatenate:

    ("hello ", (+15)) <*> ("world!", 2002)
    ("hello world!",2017)

Since: 2.1

Methods pure :: a -> (a, a) # (<*>) :: (a, a -> b) -> (a, a) -> (a, b) # liftA2 :: (a -> b -> c) -> (a, a) -> (a, b) -> (a, c) # (*>) :: (a, a) -> (a, b) -> (a, b) # (<*) :: (a, a) -> (a, b) -> (a, a) #
Applicative (ST s) # | Since: 4.4.0.0
Methods pure :: a -> ST s a # (<*>) :: ST s (a -> b) -> ST s a -> ST s b # liftA2 :: (a -> b -> c) -> ST s a -> ST s b -> ST s c # (*>) :: ST s a -> ST s b -> ST s b # (<*) :: ST s a -> ST s b -> ST s a #
Applicative (Proxy *) # | Since: 4.7.0.0
Methods pure :: a -> Proxy * a # (<*>) :: Proxy * (a -> b) -> Proxy * a -> Proxy * b # liftA2 :: (a -> b -> c) -> Proxy * a -> Proxy * b -> Proxy * c # (*>) :: Proxy * a -> Proxy * b -> Proxy * b # (<*) :: Proxy * a -> Proxy * b -> Proxy * a #
Arrow a => Applicative (ArrowMonad a) # | Since: 4.6.0.0
Methods pure :: a -> ArrowMonad a a # (<*>) :: ArrowMonad a (a -> b) -> ArrowMonad a a -> ArrowMonad a b # liftA2 :: (a -> b -> c) -> ArrowMonad a a -> ArrowMonad a b -> ArrowMonad a c # (*>) :: ArrowMonad a a -> ArrowMonad a b -> ArrowMonad a b # (<*) :: ArrowMonad a a -> ArrowMonad a b -> ArrowMonad a a #
Monad m => Applicative (WrappedMonad m) # | Since: 2.1
Methods pure :: a -> WrappedMonad m a # (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b # liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c # (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b # (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a #
Applicative (ST s) # | Since: 2.1
Methods pure :: a -> ST s a # (<*>) :: ST s (a -> b) -> ST s a -> ST s b # liftA2 :: (a -> b -> c) -> ST s a -> ST s b -> ST s c # (*>) :: ST s a -> ST s b -> ST s b # (<*) :: ST s a -> ST s b -> ST s a #
Applicative f => Applicative (Rec1 * f) # | Since: 4.9.0.0
Methods pure :: a -> Rec1 * f a # (<*>) :: Rec1 * f (a -> b) -> Rec1 * f a -> Rec1 * f b # liftA2 :: (a -> b -> c) -> Rec1 * f a -> Rec1 * f b -> Rec1 * f c # (*>) :: Rec1 * f a -> Rec1 * f b -> Rec1 * f b # (<*) :: Rec1 * f a -> Rec1 * f b -> Rec1 * f a #
Applicative f => Applicative (Alt * f) # |
Methods pure :: a -> Alt * f a # (<*>) :: Alt * f (a -> b) -> Alt * f a -> Alt * f b # liftA2 :: (a -> b -> c) -> Alt * f a -> Alt * f b -> Alt * f c # (*>) :: Alt * f a -> Alt * f b -> Alt * f b # (<*) :: Alt * f a -> Alt * f b -> Alt * f a #
Monoid m => Applicative (Const * m) # | Since: 2.0.1
Methods pure :: a -> Const * m a # (<*>) :: Const * m (a -> b) -> Const * m a -> Const * m b # liftA2 :: (a -> b -> c) -> Const * m a -> Const * m b -> Const * m c # (*>) :: Const * m a -> Const * m b -> Const * m b # (<*) :: Const * m a -> Const * m b -> Const * m a #
Arrow a => Applicative (WrappedArrow a b) # | Since: 2.1
Methods pure :: a -> WrappedArrow a b a # (<*>) :: WrappedArrow a b (a -> b) -> WrappedArrow a b a -> WrappedArrow a b b # liftA2 :: (a -> b -> c) -> WrappedArrow a b a -> WrappedArrow a b b -> WrappedArrow a b c # (*>) :: 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 ((->) LiftedRep LiftedRep a) # | Since: 2.1

Methods

pure :: a -> (LiftedRep -> LiftedRep) a a #

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

liftA2 :: (a -> b -> c) -> (LiftedRep -> LiftedRep) a a -> (LiftedRep -> LiftedRep) a b -> (LiftedRep -> LiftedRep) a c #

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

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

(Applicative f, Applicative g) => Applicative ((:*:) * f g) # | Since: 4.9.0.0
Methods pure :: a -> (* :*: f) g a # (<*>) :: (* :*: f) g (a -> b) -> (* :*: f) g a -> (* :*: f) g b # liftA2 :: (a -> b -> c) -> (* :*: f) g a -> (* :*: f) g b -> (* :*: f) g c # (*>) :: (* :*: f) g a -> (* :*: f) g b -> (* :*: f) g b # (<*) :: (* :*: f) g a -> (* :*: f) g b -> (* :*: f) g a #
(Applicative f, Applicative g) => Applicative (Product * f g) # | Since: 4.9.0.0
Methods pure :: a -> Product * f g a # (<*>) :: Product * f g (a -> b) -> Product * f g a -> Product * f g b # liftA2 :: (a -> b -> c) -> Product * f g a -> Product * f g b -> Product * f g c # (*>) :: Product * f g a -> Product * f g b -> Product * f g b # (<*) :: Product * f g a -> Product * f g b -> Product * f g a #
Applicative f => Applicative (M1 * i c f) # | Since: 4.9.0.0
Methods pure :: a -> M1 * i c f a # (<*>) :: M1 * i c f (a -> b) -> M1 * i c f a -> M1 * i c f b # liftA2 :: (a -> b -> c) -> M1 * i c f a -> M1 * i c f b -> M1 * i c f c # (*>) :: M1 * i c f a -> M1 * i c f b -> M1 * i c f b # (<*) :: M1 * i c f a -> M1 * i c f b -> M1 * i c f a #
(Applicative f, Applicative g) => Applicative ((:.:) * * f g) # | Since: 4.9.0.0
Methods pure :: a -> (* :.: *) f g a # (<*>) :: (* :.: *) f g (a -> b) -> (* :.: *) f g a -> (* :.: *) f g b # liftA2 :: (a -> b -> c) -> (* :.: *) f g a -> (* :.: *) f g b -> (* :.: *) f g c # (*>) :: (* :.: *) f g a -> (* :.: *) f g b -> (* :.: *) f g b # (<*) :: (* :.: *) f g a -> (* :.: *) f g b -> (* :.: *) f g a #
(Applicative f, Applicative g) => Applicative (Compose * * f g) # | Since: 4.9.0.0
Methods pure :: a -> Compose * * f g a # (<*>) :: Compose * * f g (a -> b) -> Compose * * f g a -> Compose * * f g b # liftA2 :: (a -> b -> c) -> Compose * * f g a -> Compose * * f g b -> Compose * * f g c # (*>) :: Compose * * f g a -> Compose * * f g b -> Compose * * f g b # (<*) :: Compose * * f g a -> Compose * * f g b -> Compose * * 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 [] # | Since: 2.1
Methods empty :: [a] # (<|>) :: [a] -> [a] -> [a] # some :: [a] -> [[a]] # many :: [a] -> [[a]] #
Alternative Maybe # | Since: 2.1
Methods empty :: Maybe a # (<|>) :: Maybe a -> Maybe a -> Maybe a # some :: Maybe a -> Maybe [a] # many :: Maybe a -> Maybe [a] #
Alternative IO # | Since: 4.9.0.0
Methods empty :: IO a # (<|>) :: IO a -> IO a -> IO a # some :: IO a -> IO [a] # many :: IO a -> IO [a] #
Alternative ReadP # | Since: 4.6.0.0
Methods empty :: ReadP a # (<|>) :: ReadP a -> ReadP a -> ReadP a # some :: ReadP a -> ReadP [a] # many :: ReadP a -> ReadP [a] #
Alternative ReadPrec # | Since: 4.6.0.0
Methods empty :: ReadPrec a # (<|>) :: ReadPrec a -> ReadPrec a -> ReadPrec a # some :: ReadPrec a -> ReadPrec [a] # many :: ReadPrec a -> ReadPrec [a] #
Alternative STM # | Since: 4.8.0.0
Methods empty :: STM a # (<|>) :: STM a -> STM a -> STM a # some :: STM a -> STM [a] # many :: STM a -> STM [a] #
Alternative Option # | Since: 4.9.0.0
Methods empty :: Option a # (<|>) :: Option a -> Option a -> Option a # some :: Option a -> Option [a] # many :: Option a -> Option [a] #
Alternative (U1 *) # | Since: 4.9.0.0
Methods empty :: U1 * a # (<|>) :: U1 * a -> U1 * a -> U1 * a # some :: U1 * a -> U1 * [a] # many :: U1 * a -> U1 * [a] #
Alternative (Proxy *) # | Since: 4.9.0.0
Methods empty :: Proxy * a # (<|>) :: Proxy * a -> Proxy * a -> Proxy * a # some :: Proxy * a -> Proxy * [a] # many :: Proxy * a -> Proxy * [a] #
ArrowPlus a => Alternative (ArrowMonad a) # | Since: 4.6.0.0
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) # | Since: 2.1
Methods empty :: WrappedMonad m a # (<|>) :: WrappedMonad m a -> WrappedMonad m a -> WrappedMonad m a # some :: WrappedMonad m a -> WrappedMonad m [a] # many :: WrappedMonad m a -> WrappedMonad m [a] #
Alternative f => Alternative (Rec1 * f) # | Since: 4.9.0.0
Methods empty :: Rec1 * f a # (<|>) :: Rec1 * f a -> Rec1 * f a -> Rec1 * f a # some :: Rec1 * f a -> Rec1 * f [a] # many :: Rec1 * f a -> Rec1 * f [a] #
Alternative f => Alternative (Alt * f) # |
Methods empty :: Alt * f a # (<|>) :: Alt * f a -> Alt * f a -> Alt * f a # some :: Alt * f a -> Alt * f [a] # many :: Alt * f a -> Alt * f [a] #
(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) # | Since: 2.1
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 ((:*:) * f g) # | Since: 4.9.0.0
Methods empty :: (* :*: f) g a # (<|>) :: (* :*: f) g a -> (* :*: f) g a -> (* :*: f) g a # some :: (* :*: f) g a -> (* :*: f) g [a] # many :: (* :*: f) g a -> (* :*: f) g [a] #
(Alternative f, Alternative g) => Alternative (Product * f g) # | Since: 4.9.0.0
Methods empty :: Product * f g a # (<|>) :: Product * f g a -> Product * f g a -> Product * f g a # some :: Product * f g a -> Product * f g [a] # many :: Product * f g a -> Product * f g [a] #
Alternative f => Alternative (M1 * i c f) # | Since: 4.9.0.0
Methods empty :: M1 * i c f a # (<|>) :: M1 * i c f a -> M1 * i c f a -> M1 * i c f a # some :: M1 * i c f a -> M1 * i c f [a] # many :: M1 * i c f a -> M1 * i c f [a] #
(Alternative f, Applicative g) => Alternative ((:.:) * * f g) # | Since: 4.9.0.0
Methods empty :: (* :.: *) f g a # (<|>) :: (* :.: *) f g a -> (* :.: *) f g a -> (* :.: *) f g a # some :: (* :.: *) f g a -> (* :.: *) f g [a] # many :: (* :.: *) f g a -> (* :.: *) f g [a] #
(Alternative f, Applicative g) => Alternative (Compose * * f g) # | Since: 4.9.0.0
Methods empty :: Compose * * f g a # (<|>) :: Compose * * f g a -> Compose * * f g a -> Compose * * f g a # some :: Compose * * f g a -> Compose * * f g [a] # many :: Compose * * f g a -> Compose * * f g [a] #

# Instances

newtype Const a b #

The `Const` functor.

Constructors

Const |

Fields

- getConst :: a

Instances

Generic1 k (Const k a) # |
Associated Types type Rep1 (Const k a) (f :: Const k a -> *) :: k -> * # Methods from1 :: f a -> Rep1 (Const k a) f a # to1 :: Rep1 (Const k a) f a -> f a #
Show2 (Const *) # | Since: 4.9.0.0
Methods liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Const * a b -> ShowS # liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Const * a b] -> ShowS #
Read2 (Const *) # | Since: 4.9.0.0

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Const * a b) #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Const * a b] #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Const * a b) #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Const * a b] #

Ord2 (Const *) # | Since: 4.9.0.0
Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Const * a c -> Const * b d -> Ordering #
Eq2 (Const *) # | Since: 4.9.0.0
Methods liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Const * a c -> Const * b d -> Bool #
Bifunctor (Const *) # | Since: 4.8.0.0
Methods bimap :: (a -> b) -> (c -> d) -> Const * a c -> Const * b d # first :: (a -> b) -> Const * a c -> Const * b c # second :: (b -> c) -> Const * a b -> Const * a c #
Bifoldable (Const *) # | Since: 4.10.0.0
Methods bifold :: Monoid m => Const * m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Const * a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Const * a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Const * a b -> c #
Bitraversable (Const *) # | Since: 4.10.0.0
Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Const * a b -> f (Const * c d) #
Functor (Const * m) # | Since: 2.1
Methods fmap :: (a -> b) -> Const * m a -> Const * m b # (<$) :: a -> Const * m b -> Const * m a #
Monoid m => Applicative (Const * m) # | Since: 2.0.1
Methods pure :: a -> Const * m a # (<*>) :: Const * m (a -> b) -> Const * m a -> Const * m b # liftA2 :: (a -> b -> c) -> Const * m a -> Const * m b -> Const * m c # (*>) :: Const * m a -> Const * m b -> Const * m b # (<*) :: Const * m a -> Const * m b -> Const * m a #
Foldable (Const * m) # | Since: 4.7.0.0

Methods

fold :: Monoid m => Const * m m -> m #

foldMap :: Monoid m => (a -> m) -> Const * m a -> m #

foldr :: (a -> b -> b) -> b -> Const * m a -> b #

foldr' :: (a -> b -> b) -> b -> Const * m a -> b #

foldl :: (b -> a -> b) -> b -> Const * m a -> b #

foldl' :: (b -> a -> b) -> b -> Const * m a -> b #

foldr1 :: (a -> a -> a) -> Const * m a -> a #

foldl1 :: (a -> a -> a) -> Const * m a -> a #

toList :: Const * m a -> [a] #

null :: Const * m a -> Bool #

length :: Const * m a -> Int #

elem :: Eq a => a -> Const * m a -> Bool #

maximum :: Ord a => Const * m a -> a #

minimum :: Ord a => Const * m a -> a #

sum :: Num a => Const * m a -> a #

product :: Num a => Const * m a -> a #

Traversable (Const * m) # | Since: 4.7.0.0
Methods traverse :: Applicative f => (a -> f b) -> Const * m a -> f (Const * m b) # sequenceA :: Applicative f => Const * m (f a) -> f (Const * m a) # mapM :: Monad m => (a -> m b) -> Const * m a -> m (Const * m b) # sequence :: Monad m => Const * m (m a) -> m (Const * m a) #
Show a => Show1 (Const * a) # | Since: 4.9.0.0
Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Const * a a -> ShowS # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Const * a a] -> ShowS #
Read a => Read1 (Const * a) # | Since: 4.9.0.0
Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Const * a a) # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Const * a a] # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Const * a a) # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Const * a a] #
Ord a => Ord1 (Const * a) # | Since: 4.9.0.0
Methods liftCompare :: (a -> b -> Ordering) -> Const * a a -> Const * a b -> Ordering #
Eq a => Eq1 (Const * a) # | Since: 4.9.0.0
Methods liftEq :: (a -> b -> Bool) -> Const * a a -> Const * 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 #
Floating a => Floating (Const k a b) # |

Methods

pi :: Const k a b #

exp :: Const k a b -> Const k a b #

log :: Const k a b -> Const k a b #

sqrt :: Const k a b -> Const k a b #

(**) :: Const k a b -> Const k a b -> Const k a b #

logBase :: Const k a b -> Const k a b -> Const k a b #

sin :: Const k a b -> Const k a b #

cos :: Const k a b -> Const k a b #

tan :: Const k a b -> Const k a b #

asin :: Const k a b -> Const k a b #

acos :: Const k a b -> Const k a b #

atan :: Const k a b -> Const k a b #

sinh :: Const k a b -> Const k a b #

cosh :: Const k a b -> Const k a b #

tanh :: Const k a b -> Const k a b #

asinh :: Const k a b -> Const k a b #

acosh :: Const k a b -> Const k a b #

atanh :: Const k a b -> Const k a b #

log1p :: Const k a b -> Const k a b #

expm1 :: Const k a b -> Const k a b #

log1pexp :: Const k a b -> Const k a b #

log1mexp :: Const k a b -> Const k a b #

Fractional a => Fractional (Const k a b) # |
Methods (/) :: Const k a b -> Const k a b -> Const k a b # recip :: Const k a b -> Const k a b # fromRational :: Rational -> Const k a b #
Integral a => Integral (Const k a b) # |
Methods quot :: Const k a b -> Const k a b -> Const k a b # rem :: Const k a b -> Const k a b -> Const k a b # div :: Const k a b -> Const k a b -> Const k a b # mod :: Const k a b -> Const k a b -> Const k a b # quotRem :: Const k a b -> Const k a b -> (Const k a b, Const k a b) # divMod :: Const k a b -> Const k a b -> (Const k a b, Const k a b) # toInteger :: Const k a b -> Integer #
(Typeable * k3, Data a, Typeable k3 b) => Data (Const k3 a b) # | Since: 4.10.0.0

Methods

gfoldl :: (forall d c. Data d => c (d -> c) -> d -> c c) -> (forall g. g -> c g) -> Const k3 a b -> c (Const k3 a b) #

gunfold :: (forall c r. Data c => c (c -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Const k3 a b) #

toConstr :: Const k3 a b -> Constr #

dataTypeOf :: Const k3 a b -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Const k3 a b)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Const k3 a b)) #

gmapT :: (forall c. Data c => c -> c) -> Const k3 a b -> Const k3 a b #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Const k3 a b -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Const k3 a b -> r #

gmapQ :: (forall d. Data d => d -> u) -> Const k3 a b -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Const k3 a b -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Const k3 a b -> m (Const k3 a b) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Const k3 a b -> m (Const k3 a b) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Const k3 a b -> m (Const k3 a b) #

Num a => Num (Const k a b) # |
Methods (+) :: Const k a b -> Const k a b -> Const k a b # (-) :: Const k a b -> Const k a b -> Const k a b # (*) :: Const k a b -> Const k a b -> Const k a b # negate :: Const k a b -> Const k a b # abs :: Const k a b -> Const k a b # signum :: Const k a b -> Const k a b # fromInteger :: Integer -> Const k a b #
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 Since: 4.8.0.0
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] #
Real a => Real (Const k a b) # |
Methods toRational :: Const k a b -> Rational #
RealFloat a => RealFloat (Const k a b) # |

Methods

floatRadix :: Const k a b -> Integer #

floatDigits :: Const k a b -> Int #

floatRange :: Const k a b -> (Int, Int) #

decodeFloat :: Const k a b -> (Integer, Int) #

encodeFloat :: Integer -> Int -> Const k a b #

exponent :: Const k a b -> Int #

significand :: Const k a b -> Const k a b #

scaleFloat :: Int -> Const k a b -> Const k a b #

isNaN :: Const k a b -> Bool #

isInfinite :: Const k a b -> Bool #

isDenormalized :: Const k a b -> Bool #

isNegativeZero :: Const k a b -> Bool #

isIEEE :: Const k a b -> Bool #

atan2 :: Const k a b -> Const k a b -> Const k a b #

RealFrac a => RealFrac (Const k a b) # |
Methods properFraction :: Integral b => Const k a b -> (b, Const k a b) # truncate :: Integral b => Const k a b -> b # round :: Integral b => Const k a b -> b # ceiling :: Integral b => Const k a b -> b # floor :: Integral b => Const k a b -> 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 Since: 4.8.0.0
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
IsString a => IsString (Const * a b) # | Since: 4.9.0.0
Methods fromString :: String -> Const * a b #
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) # | Since: 4.9.0.0
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 #
FiniteBits a => FiniteBits (Const k a b) # |
Methods finiteBitSize :: Const k a b -> Int # countLeadingZeros :: Const k a b -> Int # countTrailingZeros :: Const k a b -> Int #
Bits a => Bits (Const k a b) # |

Methods

(.&.) :: Const k a b -> Const k a b -> Const k a b #

(.|.) :: Const k a b -> Const k a b -> Const k a b #

xor :: Const k a b -> Const k a b -> Const k a b #

complement :: Const k a b -> Const k a b #

shift :: Const k a b -> Int -> Const k a b #

rotate :: Const k a b -> Int -> Const k a b #

zeroBits :: Const k a b #

bit :: Int -> Const k a b #

setBit :: Const k a b -> Int -> Const k a b #

clearBit :: Const k a b -> Int -> Const k a b #

complementBit :: Const k a b -> Int -> Const k a b #

testBit :: Const k a b -> Int -> Bool #

bitSizeMaybe :: Const k a b -> Maybe Int #

bitSize :: Const k a b -> Int #

isSigned :: Const k a b -> Bool #

shiftL :: Const k a b -> Int -> Const k a b #

unsafeShiftL :: Const k a b -> Int -> Const k a b #

shiftR :: Const k a b -> Int -> Const k a b #

unsafeShiftR :: Const k a b -> Int -> Const k a b #

rotateL :: Const k a b -> Int -> Const k a b #

rotateR :: Const k a b -> Int -> Const k a b #

popCount :: Const k a b -> Int #

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 k (Const k a) # |
type Rep1 k (Const k a) = D1 k (MetaData "Const" "Data.Functor.Const" "base" True) (C1 k (MetaCons "Const" PrefixI True) (S1 k (MetaSel (Just Symbol "getConst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 k a)))
type Rep (Const k a b) # |
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

- unwrapMonad :: m a

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) # | Since: 2.1
Methods fmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b # (<$) :: a -> WrappedMonad m b -> WrappedMonad m a #
Monad m => Applicative (WrappedMonad m) # | Since: 2.1
Methods pure :: a -> WrappedMonad m a # (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b # liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c # (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b # (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a #
MonadPlus m => Alternative (WrappedMonad m) # | Since: 2.1
Methods empty :: WrappedMonad m a # (<|>) :: WrappedMonad m a -> WrappedMonad m a -> WrappedMonad m a # some :: WrappedMonad m a -> WrappedMonad m [a] # many :: WrappedMonad m a -> WrappedMonad m [a] #
Generic1 * (WrappedMonad m) # |
Associated Types type Rep1 (WrappedMonad m) (f :: WrappedMonad m -> *) :: k -> * # Methods from1 :: f a -> Rep1 (WrappedMonad m) f a # to1 :: Rep1 (WrappedMonad m) f a -> f a #
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) # |
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) # |
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

- unwrapArrow :: a b c

Instances

Generic1 * (WrappedArrow a b) # |
Associated Types type Rep1 (WrappedArrow a b) (f :: WrappedArrow a b -> *) :: k -> * # Methods from1 :: f a -> Rep1 (WrappedArrow a b) f a # to1 :: Rep1 (WrappedArrow a b) f a -> f a #
Arrow a => Functor (WrappedArrow a b) # | Since: 2.1
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) # | Since: 2.1
Methods pure :: a -> WrappedArrow a b a # (<*>) :: WrappedArrow a b (a -> b) -> WrappedArrow a b a -> WrappedArrow a b b # liftA2 :: (a -> b -> c) -> WrappedArrow a b a -> WrappedArrow a b b -> WrappedArrow a b c # (*>) :: WrappedArrow a b a -> WrappedArrow a b b -> WrappedArrow a b b # (<*) :: WrappedArrow a b a -> WrappedArrow a b b -> WrappedArrow a b a #
(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) # | Since: 2.1
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) # |
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) # |
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.

Constructors

ZipList |

Fields

- getZipList :: [a]

Instances

Functor ZipList # |
Methods fmap :: (a -> b) -> ZipList a -> ZipList b # (<$) :: a -> ZipList b -> ZipList a #

Applicative ZipList #

    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

Methods pure :: a -> ZipList a # (<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b # liftA2 :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c # (*>) :: 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 # | Since: 4.9.0.0
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) #
Eq a => Eq (ZipList a) # |
Methods (==) :: ZipList a -> ZipList a -> Bool Source # (/=) :: ZipList a -> ZipList a -> Bool Source #
Ord a => Ord (ZipList a) # |
Methods compare :: ZipList a -> ZipList a -> Ordering Source # (<) :: ZipList a -> ZipList a -> Bool Source # (<=) :: ZipList a -> ZipList a -> Bool Source # (>) :: ZipList a -> ZipList a -> Bool Source # (>=) :: ZipList a -> ZipList a -> Bool Source # max :: ZipList a -> ZipList a -> ZipList a Source # min :: ZipList a -> ZipList a -> ZipList a Source #
Read a => Read (ZipList a) # |
Methods readsPrec :: Int -> ReadS (ZipList a) # readList :: ReadS [ZipList a] # readPrec :: ReadPrec (ZipList a) # readListPrec :: ReadPrec [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 #
Generic1 * ZipList # |
Associated Types type Rep1 ZipList (f :: ZipList -> *) :: k -> * # Methods from1 :: f a -> Rep1 ZipList f a # to1 :: Rep1 ZipList f a -> f a #
type Rep (ZipList a) # |
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])))
type Rep1 * ZipList # |
type Rep1 * ZipList = D1 * (MetaData "ZipList" "Control.Applicative" "base" True) (C1 * (MetaCons "ZipList" PrefixI True) (S1 * (MetaSel (Just Symbol "getZipList") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 * [])))

# Utility functions

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

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

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 #

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.

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.