semigroupoids-6.0.1: Semigroupoids: Category sans id

Copyright | (C) 2011-2015 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | portable
Safe Haskell | Trustworthy
Language | Haskell2010

Data.Functor.Bind

Contents

- Functors
- Applyable functors
- Wrappers
- Bindable functors

Description

Synopsis

- class Functor (f :: Type -> Type) where
  - fmap :: (a -> b) -> f a -> f b
  - (<$) :: a -> f b -> f a
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- ($>) :: Functor f => f a -> b -> f b
- class Functor f => Apply (f :: Type -> Type) where
  - (<.>) :: f (a -> b) -> f a -> f b
  - (.>) :: f a -> f b -> f b
  - (<.) :: f a -> f b -> f a
  - liftF2 :: (a -> b -> c) -> f a -> f b -> f c
- (<..>) :: Apply w => w a -> w (a -> b) -> w b
- liftF3 :: Apply w => (a -> b -> c -> d) -> w a -> w b -> w c -> w d
- newtype WrappedApplicative (f :: Type -> Type) a = WrapApplicative {
  - unwrapApplicative :: f a
  }
- newtype MaybeApply (f :: Type -> Type) a = MaybeApply {
  - runMaybeApply :: Either (f a) a
  }
- class Apply m => Bind (m :: Type -> Type) where
  - (>>-) :: m a -> (a -> m b) -> m b
  - join :: m (m a) -> m a
- gbind :: (Generic1 m, Bind (Rep1 m)) => m a -> (a -> m b) -> m b
- (-<<) :: Bind m => (a -> m b) -> m a -> m b
- (-<-) :: Bind m => (b -> m c) -> (a -> m b) -> a -> m c
- (->-) :: Bind m => (a -> m b) -> (b -> m c) -> a -> m c
- apDefault :: Bind f => f (a -> b) -> f a -> f b
- returning :: Functor f => f a -> (a -> b) -> f b

# Functors

class Functor (f :: Type -> Type) where Source #

A type `f` is a Functor if it provides a function `fmap` which, given any types `a` and `b` lets you apply any function from `(a -> b)` to turn an `f a` into an `f b`, preserving the structure of `f`. Furthermore `f` needs to adhere to the following:

Identity
  ``fmap` `id` == `id``
Composition
  ``fmap` (f . g) == `fmap` f . `fmap` g`

Note, that the second law follows from the free theorem of the type `fmap` and the first law, so you need only check that the former condition holds. See these articles by School of Haskell or David Luposchainsky for an explanation.

Minimal complete definition

fmap

Methods

fmap :: (a -> b) -> f a -> f b Source #

`fmap` is used to apply a function of type `(a -> b)` to a value of type `f a`, where f is a functor, to produce a value of type `f b`. Note that for any type constructor with more than one parameter (e.g., `Either`), only the last type parameter can be modified with `fmap` (e.g., `b` in `Either a b`).

Some type constructors with two parameters or more have a ``Bifunctor`` instance that allows both the last and the penultimate parameters to be mapped over.

#### Examples

Expand

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

    >>> fmap show Nothing
    Nothing
    >>> fmap show (Just 3)
    Just "3"

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

    >>> fmap show (Left 17)
    Left 17
    >>> fmap show (Right 17)
    Right "17"

Double each element of a list:

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

Apply `even` to the second element of a pair:

    >>> fmap even (2,2)
    (2,True)

It may seem surprising that the function is only applied to the last element of the tuple compared to the list example above which applies it to every element in the list. To understand, remember that tuples are type constructors with multiple type parameters: a tuple of 3 elements `(a,b,c)` can also be written `(,,) a b c` and its `Functor` instance is defined for `Functor ((,,) a b)` (i.e., only the third parameter is free to be mapped over with `fmap`).

It explains why `fmap` can be used with tuples containing values of different types as in the following example:

    >>> fmap even ("hello", 1.0, 4)
    ("hello",1.0,True)

(<$) :: 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.

#### Examples

Expand

Perform a computation with `Maybe` and replace the result with a constant value if it is `Just`:

    >>> 'a' <$ Just 2
    Just 'a'
    >>> 'a' <$ Nothing
    Nothing

#### Instances

Instances details

Functor Complex | Since: base-4.9.0.0
Instance details Defined in Data.Complex Methods fmap :: (a -> b) -> Complex a -> Complex b Source # (<$) :: a -> Complex b -> Complex a Source #
Functor First | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods fmap :: (a -> b) -> First a -> First b Source # (<$) :: a -> First b -> First a Source #
Functor Last | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods fmap :: (a -> b) -> Last a -> Last b Source # (<$) :: a -> Last b -> Last a Source #
Functor Max | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods fmap :: (a -> b) -> Max a -> Max b Source # (<$) :: a -> Max b -> Max a Source #
Functor Min | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods fmap :: (a -> b) -> Min a -> Min b Source # (<$) :: a -> Min b -> Min a Source #
Functor ArgDescr | Since: base-4.7.0.0
Instance details Defined in System.Console.GetOpt Methods fmap :: (a -> b) -> ArgDescr a -> ArgDescr b Source # (<$) :: a -> ArgDescr b -> ArgDescr a Source #
Functor ArgOrder | Since: base-4.7.0.0
Instance details Defined in System.Console.GetOpt Methods fmap :: (a -> b) -> ArgOrder a -> ArgOrder b Source # (<$) :: a -> ArgOrder b -> ArgOrder a Source #
Functor OptDescr | Since: base-4.7.0.0
Instance details Defined in System.Console.GetOpt Methods fmap :: (a -> b) -> OptDescr a -> OptDescr b Source # (<$) :: a -> OptDescr b -> OptDescr a Source #
Functor Put |
Instance details Defined in Data.ByteString.Builder.Internal Methods fmap :: (a -> b) -> Put a -> Put b Source # (<$) :: a -> Put b -> Put a Source #
Functor SCC | Since: containers-0.5.4
Instance details Defined in Data.Graph Methods fmap :: (a -> b) -> SCC a -> SCC b Source # (<$) :: a -> SCC b -> SCC a Source #
Functor IntMap |
Instance details Defined in Data.IntMap.Internal Methods fmap :: (a -> b) -> IntMap a -> IntMap b Source # (<$) :: a -> IntMap b -> IntMap a Source #
Functor Digit |
Instance details Defined in Data.Sequence.Internal Methods fmap :: (a -> b) -> Digit a -> Digit b Source # (<$) :: a -> Digit b -> Digit a Source #
Functor Elem |
Instance details Defined in Data.Sequence.Internal Methods fmap :: (a -> b) -> Elem a -> Elem b Source # (<$) :: a -> Elem b -> Elem a Source #
Functor FingerTree |
Instance details Defined in Data.Sequence.Internal Methods fmap :: (a -> b) -> FingerTree a -> FingerTree b Source # (<$) :: a -> FingerTree b -> FingerTree a Source #
Functor Node |
Instance details Defined in Data.Sequence.Internal Methods fmap :: (a -> b) -> Node a -> Node b Source # (<$) :: a -> Node b -> Node a Source #
Functor Seq |
Instance details Defined in Data.Sequence.Internal Methods fmap :: (a -> b) -> Seq a -> Seq b Source # (<$) :: a -> Seq b -> Seq a Source #
Functor ViewL |
Instance details Defined in Data.Sequence.Internal Methods fmap :: (a -> b) -> ViewL a -> ViewL b Source # (<$) :: a -> ViewL b -> ViewL a Source #
Functor ViewR |
Instance details Defined in Data.Sequence.Internal Methods fmap :: (a -> b) -> ViewR a -> ViewR b Source # (<$) :: a -> ViewR b -> ViewR a Source #
Functor Tree |
Instance details Defined in Data.Tree Methods fmap :: (a -> b) -> Tree a -> Tree b Source # (<$) :: a -> Tree b -> Tree a Source #
Functor NonEmpty | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods fmap :: (a -> b) -> NonEmpty a -> NonEmpty b Source # (<$) :: a -> NonEmpty b -> NonEmpty a Source #
Functor Identity | Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods fmap :: (a -> b) -> Identity a -> Identity b Source # (<$) :: a -> Identity b -> Identity a Source #
Functor First | Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods fmap :: (a -> b) -> First a -> First b Source # (<$) :: a -> First b -> First a Source #
Functor Last | Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods fmap :: (a -> b) -> Last a -> Last b Source # (<$) :: a -> Last b -> Last a Source #
Functor Down | Since: base-4.11.0.0
Instance details Defined in GHC.Internal.Data.Ord Methods fmap :: (a -> b) -> Down a -> Down b Source # (<$) :: a -> Down b -> Down a Source #
Functor Dual | Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods fmap :: (a -> b) -> Dual a -> Dual b Source # (<$) :: a -> Dual b -> Dual a Source #
Functor Product | Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods fmap :: (a -> b) -> Product a -> Product b Source # (<$) :: a -> Product b -> Product a Source #
Functor Sum | Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods fmap :: (a -> b) -> Sum a -> Sum b Source # (<$) :: a -> Sum b -> Sum a Source #
Functor ZipList | Since: base-2.1
Instance details Defined in GHC.Internal.Functor.ZipList Methods fmap :: (a -> b) -> ZipList a -> ZipList b Source # (<$) :: a -> ZipList b -> ZipList a Source #
Functor Par1 | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> Par1 a -> Par1 b Source # (<$) :: a -> Par1 b -> Par1 a Source #
Functor IO | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods fmap :: (a -> b) -> IO a -> IO b Source # (<$) :: a -> IO b -> IO a Source #
Functor AnnotDetails |
Instance details Defined in Text.PrettyPrint.Annotated.HughesPJ Methods fmap :: (a -> b) -> AnnotDetails a -> AnnotDetails b Source # (<$) :: a -> AnnotDetails b -> AnnotDetails a Source #
Functor Doc |
Instance details Defined in Text.PrettyPrint.Annotated.HughesPJ Methods fmap :: (a -> b) -> Doc a -> Doc b Source # (<$) :: a -> Doc b -> Doc a Source #
Functor Span |
Instance details Defined in Text.PrettyPrint.Annotated.HughesPJ Methods fmap :: (a -> b) -> Span a -> Span b Source # (<$) :: a -> Span b -> Span a Source #
Functor PprM |
Instance details Defined in Language.Haskell.TH.PprLib Methods fmap :: (a -> b) -> PprM a -> PprM b Source # (<$) :: a -> PprM b -> PprM a Source #
Functor Q |
Instance details Defined in Language.Haskell.TH.Syntax Methods fmap :: (a -> b) -> Q a -> Q b Source # (<$) :: a -> Q b -> Q a Source #
Functor TyVarBndr |
Instance details Defined in Language.Haskell.TH.Syntax Methods fmap :: (a -> b) -> TyVarBndr a -> TyVarBndr b Source # (<$) :: a -> TyVarBndr b -> TyVarBndr a Source #
Functor Maybe | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods fmap :: (a -> b) -> Maybe a -> Maybe b Source # (<$) :: a -> Maybe b -> Maybe a Source #
Functor Solo | Since: base-4.15
Instance details Defined in GHC.Internal.Base Methods fmap :: (a -> b) -> Solo a -> Solo b Source # (<$) :: a -> Solo b -> Solo a Source #
Functor [] | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods fmap :: (a -> b) -> [a] -> [b] Source # (<$) :: a -> [b] -> [a] Source #
Monad m => Functor (WrappedMonad m) | Since: base-2.1
Instance details Defined in Control.Applicative Methods fmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source # (<$) :: a -> WrappedMonad m b -> WrappedMonad m a Source #
Functor (Arg a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods fmap :: (a0 -> b) -> Arg a a0 -> Arg a b Source # (<$) :: a0 -> Arg a b -> Arg a a0 Source #
Functor (SetM s) |
Instance details Defined in Data.Graph Methods fmap :: (a -> b) -> SetM s a -> SetM s b Source # (<$) :: a -> SetM s b -> SetM s a Source #
Functor (Map k) |
Instance details Defined in Data.Map.Internal Methods fmap :: (a -> b) -> Map k a -> Map k b Source # (<$) :: a -> Map k b -> Map k a Source #
Arrow a => Functor (ArrowMonad a) | Since: base-4.6.0.0
Instance details Defined in GHC.Internal.Control.Arrow Methods fmap :: (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b Source # (<$) :: a0 -> ArrowMonad a b -> ArrowMonad a a0 Source #
Functor (Either a) | Since: base-3.0
Instance details Defined in GHC.Internal.Data.Either Methods fmap :: (a0 -> b) -> Either a a0 -> Either a b Source # (<$) :: a0 -> Either a b -> Either a a0 Source #
Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Proxy Methods fmap :: (a -> b) -> Proxy a -> Proxy b Source # (<$) :: a -> Proxy b -> Proxy a Source #
Functor (U1 :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> U1 a -> U1 b Source # (<$) :: a -> U1 b -> U1 a Source #
Functor (V1 :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> V1 a -> V1 b Source # (<$) :: a -> V1 b -> V1 a Source #
Functor f => Functor (MaybeApply f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods fmap :: (a -> b) -> MaybeApply f a -> MaybeApply f b Source # (<$) :: a -> MaybeApply f b -> MaybeApply f a Source #
Functor f => Functor (WrappedApplicative f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods fmap :: (a -> b) -> WrappedApplicative f a -> WrappedApplicative f b Source # (<$) :: a -> WrappedApplicative f b -> WrappedApplicative f a Source #
Functor f => Functor (Lift f) |
Instance details Defined in Control.Applicative.Lift Methods fmap :: (a -> b) -> Lift f a -> Lift f b Source # (<$) :: a -> Lift f b -> Lift f a Source #
Functor m => Functor (MaybeT m) |
Instance details Defined in Control.Monad.Trans.Maybe Methods fmap :: (a -> b) -> MaybeT m a -> MaybeT m b Source # (<$) :: a -> MaybeT m b -> MaybeT m a Source #
Functor (HashMap k) |
Instance details Defined in Data.HashMap.Internal Methods fmap :: (a -> b) -> HashMap k a -> HashMap k b Source # (<$) :: a -> HashMap k b -> HashMap k a Source #
Functor ((,) a) | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods fmap :: (a0 -> b) -> (a, a0) -> (a, b) Source # (<$) :: a0 -> (a, b) -> (a, a0) Source #
Arrow a => Functor (WrappedArrow a b) | Since: base-2.1
Instance details Defined in Control.Applicative Methods fmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source # (<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source #
Functor (Mag a b) |
Instance details Defined in Data.Biapplicative Methods fmap :: (a0 -> b0) -> Mag a b a0 -> Mag a b b0 Source # (<$) :: a0 -> Mag a b b0 -> Mag a b a0 Source #
Functor (bi a) => Functor (Biap bi a) |
Instance details Defined in Data.Bifunctor.Biap Methods fmap :: (a0 -> b) -> Biap bi a a0 -> Biap bi a b Source # (<$) :: a0 -> Biap bi a b -> Biap bi a a0 Source #
Bifunctor p => Functor (Fix p) |
Instance details Defined in Data.Bifunctor.Fix Methods fmap :: (a -> b) -> Fix p a -> Fix p b Source # (<$) :: a -> Fix p b -> Fix p a Source #
Bifunctor p => Functor (Join p) |
Instance details Defined in Data.Bifunctor.Join Methods fmap :: (a -> b) -> Join p a -> Join p b Source # (<$) :: a -> Join p b -> Join p a Source #
Functor w => Functor (EnvT e w) |
Instance details Defined in Control.Comonad.Trans.Env Methods fmap :: (a -> b) -> EnvT e w a -> EnvT e w b Source # (<$) :: a -> EnvT e w b -> EnvT e w a Source #
Functor w => Functor (StoreT s w) |
Instance details Defined in Control.Comonad.Trans.Store Methods fmap :: (a -> b) -> StoreT s w a -> StoreT s w b Source # (<$) :: a -> StoreT s w b -> StoreT s w a Source #
Functor w => Functor (TracedT m w) |
Instance details Defined in Control.Comonad.Trans.Traced Methods fmap :: (a -> b) -> TracedT m w a -> TracedT m w b Source # (<$) :: a -> TracedT m w b -> TracedT m w a Source #
(Applicative f, Monad f) => Functor (WhenMissing f x) | Since: containers-0.5.9
Instance details Defined in Data.IntMap.Internal Methods fmap :: (a -> b) -> WhenMissing f x a -> WhenMissing f x b Source # (<$) :: a -> WhenMissing f x b -> WhenMissing f x a Source #
(Contravariant f, Contravariant g) => Functor (Compose f g) |
Instance details Defined in Data.Functor.Contravariant.Compose Methods fmap :: (a -> b) -> Compose f g a -> Compose f g b Source # (<$) :: a -> Compose f g b -> Compose f g a Source #
(Functor f, Functor g) => Functor (ComposeCF f g) |
Instance details Defined in Data.Functor.Contravariant.Compose Methods fmap :: (a -> b) -> ComposeCF f g a -> ComposeCF f g b Source # (<$) :: a -> ComposeCF f g b -> ComposeCF f g a Source #
(Functor f, Functor g) => Functor (ComposeFC f g) |
Instance details Defined in Data.Functor.Contravariant.Compose Methods fmap :: (a -> b) -> ComposeFC f g a -> ComposeFC f g b Source # (<$) :: a -> ComposeFC f g b -> ComposeFC f g a Source #
Functor m => Functor (Kleisli m a) | Since: base-4.14.0.0
Instance details Defined in GHC.Internal.Control.Arrow Methods fmap :: (a0 -> b) -> Kleisli m a a0 -> Kleisli m a b Source # (<$) :: a0 -> Kleisli m a b -> Kleisli m a a0 Source #
Functor (Const m :: Type -> Type) | Since: base-2.1
Instance details Defined in GHC.Internal.Data.Functor.Const Methods fmap :: (a -> b) -> Const m a -> Const m b Source # (<$) :: a -> Const m b -> Const m a Source #
Functor f => Functor (Ap f) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods fmap :: (a -> b) -> Ap f a -> Ap f b Source # (<$) :: a -> Ap f b -> Ap f a Source #
Functor f => Functor (Alt f) | Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods fmap :: (a -> b) -> Alt f a -> Alt f b Source # (<$) :: a -> Alt f b -> Alt f a Source #
(Generic1 f, Functor (Rep1 f)) => Functor (Generically1 f) | Since: base-4.17.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> Generically1 f a -> Generically1 f b Source # (<$) :: a -> Generically1 f b -> Generically1 f a Source #
Functor f => Functor (Rec1 f) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> Rec1 f a -> Rec1 f b Source # (<$) :: a -> Rec1 f b -> Rec1 f a Source #
Functor (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> URec (Ptr ()) a -> URec (Ptr ()) b Source # (<$) :: a -> URec (Ptr ()) b -> URec (Ptr ()) a Source #
Functor (URec Char :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> URec Char a -> URec Char b Source # (<$) :: a -> URec Char b -> URec Char a Source #
Functor (URec Double :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> URec Double a -> URec Double b Source # (<$) :: a -> URec Double b -> URec Double a Source #
Functor (URec Float :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> URec Float a -> URec Float b Source # (<$) :: a -> URec Float b -> URec Float a Source #
Functor (URec Int :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> URec Int a -> URec Int b Source # (<$) :: a -> URec Int b -> URec Int a Source #
Functor (URec Word :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> URec Word a -> URec Word b Source # (<$) :: a -> URec Word b -> URec Word a Source #
Functor f => Functor (Static f a) Source # |
Instance details Defined in Data.Semigroupoid.Static Methods fmap :: (a0 -> b) -> Static f a a0 -> Static f a b Source # (<$) :: a0 -> Static f a b -> Static f a a0 Source #
Functor (Tagged s) |
Instance details Defined in Data.Tagged Methods fmap :: (a -> b) -> Tagged s a -> Tagged s b Source # (<$) :: a -> Tagged s b -> Tagged s a Source #
Functor f => Functor (Backwards f) | Derived instance.
Instance details Defined in Control.Applicative.Backwards Methods fmap :: (a -> b) -> Backwards f a -> Backwards f b Source # (<$) :: a -> Backwards f b -> Backwards f a Source #
Functor m => Functor (AccumT w m) |
Instance details Defined in Control.Monad.Trans.Accum Methods fmap :: (a -> b) -> AccumT w m a -> AccumT w m b Source # (<$) :: a -> AccumT w m b -> AccumT w m a Source #
Functor m => Functor (ExceptT e m) |
Instance details Defined in Control.Monad.Trans.Except Methods fmap :: (a -> b) -> ExceptT e m a -> ExceptT e m b Source # (<$) :: a -> ExceptT e m b -> ExceptT e m a Source #
Functor m => Functor (IdentityT m) |
Instance details Defined in Control.Monad.Trans.Identity Methods fmap :: (a -> b) -> IdentityT m a -> IdentityT m b Source # (<$) :: a -> IdentityT m b -> IdentityT m a Source #
Functor m => Functor (ReaderT r m) |
Instance details Defined in Control.Monad.Trans.Reader Methods fmap :: (a -> b) -> ReaderT r m a -> ReaderT r m b Source # (<$) :: a -> ReaderT r m b -> ReaderT r m a Source #
Functor m => Functor (SelectT r m) |
Instance details Defined in Control.Monad.Trans.Select Methods fmap :: (a -> b) -> SelectT r m a -> SelectT r m b Source # (<$) :: a -> SelectT r m b -> SelectT r m a Source #
Functor m => Functor (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods fmap :: (a -> b) -> StateT s m a -> StateT s m b Source # (<$) :: a -> StateT s m b -> StateT s m a Source #
Functor m => Functor (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Strict Methods fmap :: (a -> b) -> StateT s m a -> StateT s m b Source # (<$) :: a -> StateT s m b -> StateT s m a Source #
Functor m => Functor (WriterT w m) |
Instance details Defined in Control.Monad.Trans.Writer.CPS Methods fmap :: (a -> b) -> WriterT w m a -> WriterT w m b Source # (<$) :: a -> WriterT w m b -> WriterT w m a Source #
Functor m => Functor (WriterT w m) |
Instance details Defined in Control.Monad.Trans.Writer.Lazy Methods fmap :: (a -> b) -> WriterT w m a -> WriterT w m b Source # (<$) :: a -> WriterT w m b -> WriterT w m a Source #
Functor m => Functor (WriterT w m) |
Instance details Defined in Control.Monad.Trans.Writer.Strict Methods fmap :: (a -> b) -> WriterT w m a -> WriterT w m b Source # (<$) :: a -> WriterT w m b -> WriterT w m a Source #
Functor (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods fmap :: (a0 -> b) -> Constant a a0 -> Constant a b Source # (<$) :: a0 -> Constant a b -> Constant a a0 Source #
Functor f => Functor (Reverse f) | Derived instance.
Instance details Defined in Data.Functor.Reverse Methods fmap :: (a -> b) -> Reverse f a -> Reverse f b Source # (<$) :: a -> Reverse f b -> Reverse f a Source #
Functor ((,,) a b) | Since: base-4.14.0.0
Instance details Defined in GHC.Internal.Base Methods fmap :: (a0 -> b0) -> (a, b, a0) -> (a, b, b0) Source # (<$) :: a0 -> (a, b, b0) -> (a, b, a0) Source #
(Functor f, Functor g) => Functor (Product f g) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods fmap :: (a -> b) -> Product f g a -> Product f g b Source # (<$) :: a -> Product f g b -> Product f g a Source #
(Functor f, Functor g) => Functor (Sum f g) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Sum Methods fmap :: (a -> b) -> Sum f g a -> Sum f g b Source # (<$) :: a -> Sum f g b -> Sum f g a Source #
Functor (Cokleisli w a) |
Instance details Defined in Control.Comonad Methods fmap :: (a0 -> b) -> Cokleisli w a a0 -> Cokleisli w a b Source # (<$) :: a0 -> Cokleisli w a b -> Cokleisli w a a0 Source #
Functor f => Functor (WhenMatched f x y) | Since: containers-0.5.9
Instance details Defined in Data.IntMap.Internal Methods fmap :: (a -> b) -> WhenMatched f x y a -> WhenMatched f x y b Source # (<$) :: a -> WhenMatched f x y b -> WhenMatched f x y a Source #
(Applicative f, Monad f) => Functor (WhenMissing f k x) | Since: containers-0.5.9
Instance details Defined in Data.Map.Internal Methods fmap :: (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b Source # (<$) :: a -> WhenMissing f k x b -> WhenMissing f k x a Source #
(Functor f, Functor g) => Functor (f :*: g) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> (f :*: g) a -> (f :*: g) b Source # (<$) :: a -> (f :*: g) b -> (f :*: g) a Source #
(Functor f, Functor g) => Functor (f :+: g) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> (f :+: g) a -> (f :+: g) b Source # (<$) :: a -> (f :+: g) b -> (f :+: g) a Source #
Functor (K1 i c :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> K1 i c a -> K1 i c b Source # (<$) :: a -> K1 i c b -> K1 i c a Source #
Functor (ContT r m) |
Instance details Defined in Control.Monad.Trans.Cont Methods fmap :: (a -> b) -> ContT r m a -> ContT r m b Source # (<$) :: a -> ContT r m b -> ContT r m a Source #
Functor ((,,,) a b c) | Since: base-4.14.0.0
Instance details Defined in GHC.Internal.Base Methods fmap :: (a0 -> b0) -> (a, b, c, a0) -> (a, b, c, b0) Source # (<$) :: a0 -> (a, b, c, b0) -> (a, b, c, a0) Source #
Functor ((->) r) | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods fmap :: (a -> b) -> (r -> a) -> r -> b Source # (<$) :: a -> (r -> b) -> r -> a Source #
(Functor f, Functor g) => Functor (Compose f g) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Compose Methods fmap :: (a -> b) -> Compose f g a -> Compose f g b Source # (<$) :: a -> Compose f g b -> Compose f g a Source #
Functor (Clown f a :: Type -> Type) |
Instance details Defined in Data.Bifunctor.Clown Methods fmap :: (a0 -> b) -> Clown f a a0 -> Clown f a b Source # (<$) :: a0 -> Clown f a b -> Clown f a a0 Source #
Bifunctor p => Functor (Flip p a) |
Instance details Defined in Data.Bifunctor.Flip Methods fmap :: (a0 -> b) -> Flip p a a0 -> Flip p a b Source # (<$) :: a0 -> Flip p a b -> Flip p a a0 Source #
Functor g => Functor (Joker g a) |
Instance details Defined in Data.Bifunctor.Joker Methods fmap :: (a0 -> b) -> Joker g a a0 -> Joker g a b Source # (<$) :: a0 -> Joker g a b -> Joker g a a0 Source #
Bifunctor p => Functor (WrappedBifunctor p a) |
Instance details Defined in Data.Bifunctor.Wrapped Methods fmap :: (a0 -> b) -> WrappedBifunctor p a a0 -> WrappedBifunctor p a b Source # (<$) :: a0 -> WrappedBifunctor p a b -> WrappedBifunctor p a a0 Source #
Functor f => Functor (WhenMatched f k x y) | Since: containers-0.5.9
Instance details Defined in Data.Map.Internal Methods fmap :: (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b Source # (<$) :: a -> WhenMatched f k x y b -> WhenMatched f k x y a Source #
(Functor f, Functor g) => Functor (f :.: g) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> (f :.: g) a -> (f :.: g) b Source # (<$) :: a -> (f :.: g) b -> (f :.: g) a Source #
Functor f => Functor (M1 i c f) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Generics Methods fmap :: (a -> b) -> M1 i c f a -> M1 i c f b Source # (<$) :: a -> M1 i c f b -> M1 i c f a Source #
Functor m => Functor (RWST r w s m) |
Instance details Defined in Control.Monad.Trans.RWS.CPS Methods fmap :: (a -> b) -> RWST r w s m a -> RWST r w s m b Source # (<$) :: a -> RWST r w s m b -> RWST r w s m a Source #
Functor m => Functor (RWST r w s m) |
Instance details Defined in Control.Monad.Trans.RWS.Lazy Methods fmap :: (a -> b) -> RWST r w s m a -> RWST r w s m b Source # (<$) :: a -> RWST r w s m b -> RWST r w s m a Source #
Functor m => Functor (RWST r w s m) |
Instance details Defined in Control.Monad.Trans.RWS.Strict Methods fmap :: (a -> b) -> RWST r w s m a -> RWST r w s m b Source # (<$) :: a -> RWST r w s m b -> RWST r w s m a Source #
Functor ((,,,,) a b c d) | Since: base-4.18.0.0
Instance details Defined in GHC.Internal.Base Methods fmap :: (a0 -> b0) -> (a, b, c, d, a0) -> (a, b, c, d, b0) Source # (<$) :: a0 -> (a, b, c, d, b0) -> (a, b, c, d, a0) Source #
(Functor (f a), Functor (g a)) => Functor (Product f g a) |
Instance details Defined in Data.Bifunctor.Product Methods fmap :: (a0 -> b) -> Product f g a a0 -> Product f g a b Source # (<$) :: a0 -> Product f g a b -> Product f g a a0 Source #
(Functor (f a), Functor (g a)) => Functor (Sum f g a) |
Instance details Defined in Data.Bifunctor.Sum Methods fmap :: (a0 -> b) -> Sum f g a a0 -> Sum f g a b Source # (<$) :: a0 -> Sum f g a b -> Sum f g a a0 Source #
Functor ((,,,,,) a b c d e) | Since: base-4.18.0.0
Instance details Defined in GHC.Internal.Base Methods fmap :: (a0 -> b0) -> (a, b, c, d, e, a0) -> (a, b, c, d, e, b0) Source # (<$) :: a0 -> (a, b, c, d, e, b0) -> (a, b, c, d, e, a0) Source #
(Functor f, Bifunctor p) => Functor (Tannen f p a) |
Instance details Defined in Data.Bifunctor.Tannen Methods fmap :: (a0 -> b) -> Tannen f p a a0 -> Tannen f p a b Source # (<$) :: a0 -> Tannen f p a b -> Tannen f p a a0 Source #
Functor ((,,,,,,) a b c d e f) | Since: base-4.18.0.0
Instance details Defined in GHC.Internal.Base Methods fmap :: (a0 -> b0) -> (a, b, c, d, e, f, a0) -> (a, b, c, d, e, f, b0) Source # (<$) :: a0 -> (a, b, c, d, e, f, b0) -> (a, b, c, d, e, f, a0) Source #
(Bifunctor p, Functor g) => Functor (Biff p f g a) |
Instance details Defined in Data.Bifunctor.Biff Methods fmap :: (a0 -> b) -> Biff p f g a a0 -> Biff p f g a b Source # (<$) :: a0 -> Biff p f g a b -> Biff p f g a a0 Source #

(<$>) :: 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 => f a -> b -> f b infixl 4 Source #

Flipped version of `<$`.

#### Examples

Expand

Replace the contents of a ``Maybe` `Int`` with a constant `String`:

    >>> Nothing $> "foo"
    Nothing

    >>> Just 90210 $> "foo"
    Just "foo"

Replace the contents of an ``Either` `Int` `Int`` with a constant `String`, resulting in an ``Either` `Int` `String``:

    >>> Left 8675309 $> "foo"
    Left 8675309

    >>> Right 8675309 $> "foo"
    Right "foo"

Replace each element of a list with a constant `String`:

    >>> [1,2,3] $> "foo"
    ["foo","foo","foo"]

Replace the second element of a pair with a constant `String`:

    >>> (1,2) $> "foo"
    (1,"foo")

Since: base-4.7.0.0

# Applyable functors

class Functor f => Apply (f :: Type -> Type) where Source #

A strong lax semi-monoidal endofunctor. This is equivalent to an `Applicative` without `pure`.

Laws:

    (.) <$> u <.> v <.> w = u <.> (v <.> w)
    x <.> (f <$> y) = (. f) <$> x <.> y
    f <$> (x <.> y) = (f .) <$> x <.> y

The laws imply that `.>` and `<.` really ignore their left and right results, respectively, and really return their right and left results, respectively. Specifically,

    (mf <$> m) .> (nf <$> n) = nf <$> (m .> n)
    (mf <$> m) <. (nf <$> n) = mf <$> (m <. n)

Minimal complete definition

(<.>) | liftF2

Methods

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

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

     a .> b = const id <$> a <.> b

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

     a <. b = const <$> a <.> b

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

Lift a binary function into a comonad with zipping

#### Instances

Instances details

Apply Complex Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Complex (a -> b) -> Complex a -> Complex b Source # (.>) :: Complex a -> Complex b -> Complex b Source # (<.) :: Complex a -> Complex b -> Complex a Source # liftF2 :: (a -> b -> c) -> Complex a -> Complex b -> Complex c Source #
Apply First Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: First (a -> b) -> First a -> First b Source # (.>) :: First a -> First b -> First b Source # (<.) :: First a -> First b -> First a Source # liftF2 :: (a -> b -> c) -> First a -> First b -> First c Source #
Apply Last Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Last (a -> b) -> Last a -> Last b Source # (.>) :: Last a -> Last b -> Last b Source # (<.) :: Last a -> Last b -> Last a Source # liftF2 :: (a -> b -> c) -> Last a -> Last b -> Last c Source #
Apply Max Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Max (a -> b) -> Max a -> Max b Source # (.>) :: Max a -> Max b -> Max b Source # (<.) :: Max a -> Max b -> Max a Source # liftF2 :: (a -> b -> c) -> Max a -> Max b -> Max c Source #
Apply Min Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Min (a -> b) -> Min a -> Min b Source # (.>) :: Min a -> Min b -> Min b Source # (<.) :: Min a -> Min b -> Min a Source # liftF2 :: (a -> b -> c) -> Min a -> Min b -> Min c Source #
Apply IntMap Source # | An `IntMap` is not `Applicative`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: IntMap (a -> b) -> IntMap a -> IntMap b Source # (.>) :: IntMap a -> IntMap b -> IntMap b Source # (<.) :: IntMap a -> IntMap b -> IntMap a Source # liftF2 :: (a -> b -> c) -> IntMap a -> IntMap b -> IntMap c Source #
Apply Seq Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Seq (a -> b) -> Seq a -> Seq b Source # (.>) :: Seq a -> Seq b -> Seq b Source # (<.) :: Seq a -> Seq b -> Seq a Source # liftF2 :: (a -> b -> c) -> Seq a -> Seq b -> Seq c Source #
Apply Tree Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Tree (a -> b) -> Tree a -> Tree b Source # (.>) :: Tree a -> Tree b -> Tree b Source # (<.) :: Tree a -> Tree b -> Tree a Source # liftF2 :: (a -> b -> c) -> Tree a -> Tree b -> Tree c Source #
Apply NonEmpty Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b Source # (.>) :: NonEmpty a -> NonEmpty b -> NonEmpty b Source # (<.) :: NonEmpty a -> NonEmpty b -> NonEmpty a Source # liftF2 :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c Source #
Apply Identity Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Identity (a -> b) -> Identity a -> Identity b Source # (.>) :: Identity a -> Identity b -> Identity b Source # (<.) :: Identity a -> Identity b -> Identity a Source # liftF2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c Source #
Apply First Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: First (a -> b) -> First a -> First b Source # (.>) :: First a -> First b -> First b Source # (<.) :: First a -> First b -> First a Source # liftF2 :: (a -> b -> c) -> First a -> First b -> First c Source #
Apply Last Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Last (a -> b) -> Last a -> Last b Source # (.>) :: Last a -> Last b -> Last b Source # (<.) :: Last a -> Last b -> Last a Source # liftF2 :: (a -> b -> c) -> Last a -> Last b -> Last c Source #
Apply Down Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Down (a -> b) -> Down a -> Down b Source # (.>) :: Down a -> Down b -> Down b Source # (<.) :: Down a -> Down b -> Down a Source # liftF2 :: (a -> b -> c) -> Down a -> Down b -> Down c Source #
Apply Dual Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Dual (a -> b) -> Dual a -> Dual b Source # (.>) :: Dual a -> Dual b -> Dual b Source # (<.) :: Dual a -> Dual b -> Dual a Source # liftF2 :: (a -> b -> c) -> Dual a -> Dual b -> Dual c Source #
Apply Product Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Product (a -> b) -> Product a -> Product b Source # (.>) :: Product a -> Product b -> Product b Source # (<.) :: Product a -> Product b -> Product a Source # liftF2 :: (a -> b -> c) -> Product a -> Product b -> Product c Source #
Apply Sum Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Sum (a -> b) -> Sum a -> Sum b Source # (.>) :: Sum a -> Sum b -> Sum b Source # (<.) :: Sum a -> Sum b -> Sum a Source # liftF2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c Source #
Apply ZipList Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: ZipList (a -> b) -> ZipList a -> ZipList b Source # (.>) :: ZipList a -> ZipList b -> ZipList b Source # (<.) :: ZipList a -> ZipList b -> ZipList a Source # liftF2 :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c Source #
Apply Par1 Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Par1 (a -> b) -> Par1 a -> Par1 b Source # (.>) :: Par1 a -> Par1 b -> Par1 b Source # (<.) :: Par1 a -> Par1 b -> Par1 a Source # liftF2 :: (a -> b -> c) -> Par1 a -> Par1 b -> Par1 c Source #
Apply IO Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: IO (a -> b) -> IO a -> IO b Source # (.>) :: IO a -> IO b -> IO b Source # (<.) :: IO a -> IO b -> IO a Source # liftF2 :: (a -> b -> c) -> IO a -> IO b -> IO c Source #
Apply Q Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Q (a -> b) -> Q a -> Q b Source # (.>) :: Q a -> Q b -> Q b Source # (<.) :: Q a -> Q b -> Q a Source # liftF2 :: (a -> b -> c) -> Q a -> Q b -> Q c Source #
Apply Maybe Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Maybe (a -> b) -> Maybe a -> Maybe b Source # (.>) :: Maybe a -> Maybe b -> Maybe b Source # (<.) :: Maybe a -> Maybe b -> Maybe a Source # liftF2 :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c Source #
Apply [] Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: [a -> b] -> [a] -> [b] Source # (.>) :: [a] -> [b] -> [b] Source # (<.) :: [a] -> [b] -> [a] Source # liftF2 :: (a -> b -> c) -> [a] -> [b] -> [c] Source #
Monad m => Apply (WrappedMonad m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source # (.>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source # (<.) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a Source # liftF2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c Source #
Ord k => Apply (Map k) Source # | A 'Map k' is not `Applicative`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Map k (a -> b) -> Map k a -> Map k b Source # (.>) :: Map k a -> Map k b -> Map k b Source # (<.) :: Map k a -> Map k b -> Map k a Source # liftF2 :: (a -> b -> c) -> Map k a -> Map k b -> Map k c Source #
Apply (Either a) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Either a (a0 -> b) -> Either a a0 -> Either a b Source # (.>) :: Either a a0 -> Either a b -> Either a b Source # (<.) :: Either a a0 -> Either a b -> Either a a0 Source # liftF2 :: (a0 -> b -> c) -> Either a a0 -> Either a b -> Either a c Source #
Apply (Proxy :: Type -> Type) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Proxy (a -> b) -> Proxy a -> Proxy b Source # (.>) :: Proxy a -> Proxy b -> Proxy b Source # (<.) :: Proxy a -> Proxy b -> Proxy a Source # liftF2 :: (a -> b -> c) -> Proxy a -> Proxy b -> Proxy c Source #
Apply (U1 :: Type -> Type) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: U1 (a -> b) -> U1 a -> U1 b Source # (.>) :: U1 a -> U1 b -> U1 b Source # (<.) :: U1 a -> U1 b -> U1 a Source # liftF2 :: (a -> b -> c) -> U1 a -> U1 b -> U1 c Source #
Apply (V1 :: Type -> Type) Source # | A `V1` is not `Applicative`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: V1 (a -> b) -> V1 a -> V1 b Source # (.>) :: V1 a -> V1 b -> V1 b Source # (<.) :: V1 a -> V1 b -> V1 a Source # liftF2 :: (a -> b -> c) -> V1 a -> V1 b -> V1 c Source #
Apply f => Apply (MaybeApply f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: MaybeApply f (a -> b) -> MaybeApply f a -> MaybeApply f b Source # (.>) :: MaybeApply f a -> MaybeApply f b -> MaybeApply f b Source # (<.) :: MaybeApply f a -> MaybeApply f b -> MaybeApply f a Source # liftF2 :: (a -> b -> c) -> MaybeApply f a -> MaybeApply f b -> MaybeApply f c Source #
Applicative f => Apply (WrappedApplicative f) Source # |

Instance details

Defined in Data.Functor.Bind.Class

Methods

(<.>) :: WrappedApplicative f (a -> b) -> WrappedApplicative f a -> WrappedApplicative f b Source #

(.>) :: WrappedApplicative f a -> WrappedApplicative f b -> WrappedApplicative f b Source #

(<.) :: WrappedApplicative f a -> WrappedApplicative f b -> WrappedApplicative f a Source #

liftF2 :: (a -> b -> c) -> WrappedApplicative f a -> WrappedApplicative f b -> WrappedApplicative f c Source #

Apply f => Apply (Lift f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Lift f (a -> b) -> Lift f a -> Lift f b Source # (.>) :: Lift f a -> Lift f b -> Lift f b Source # (<.) :: Lift f a -> Lift f b -> Lift f a Source # liftF2 :: (a -> b -> c) -> Lift f a -> Lift f b -> Lift f c Source #
(Functor m, Monad m) => Apply (MaybeT m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: MaybeT m (a -> b) -> MaybeT m a -> MaybeT m b Source # (.>) :: MaybeT m a -> MaybeT m b -> MaybeT m b Source # (<.) :: MaybeT m a -> MaybeT m b -> MaybeT m a Source # liftF2 :: (a -> b -> c) -> MaybeT m a -> MaybeT m b -> MaybeT m c Source #
(Hashable k, Eq k) => Apply (HashMap k) Source # | A 'HashMap k' is not `Applicative`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: HashMap k (a -> b) -> HashMap k a -> HashMap k b Source # (.>) :: HashMap k a -> HashMap k b -> HashMap k b Source # (<.) :: HashMap k a -> HashMap k b -> HashMap k a Source # liftF2 :: (a -> b -> c) -> HashMap k a -> HashMap k b -> HashMap k c Source #
Semigroup m => Apply ((,) m) Source # | A ``(,)` m` is not `Applicative` unless its `m` is a `Monoid`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: (m, a -> b) -> (m, a) -> (m, b) Source # (.>) :: (m, a) -> (m, b) -> (m, b) Source # (<.) :: (m, a) -> (m, b) -> (m, a) Source # liftF2 :: (a -> b -> c) -> (m, a) -> (m, b) -> (m, c) Source #
Arrow a => Apply (WrappedArrow a b) Source # |

Instance details

Defined in Data.Functor.Bind.Class

Methods

(<.>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 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 #

liftF2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c Source #

Biapply p => Apply (Join p) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Join p (a -> b) -> Join p a -> Join p b Source # (.>) :: Join p a -> Join p b -> Join p b Source # (<.) :: Join p a -> Join p b -> Join p a Source # liftF2 :: (a -> b -> c) -> Join p a -> Join p b -> Join p c Source #
(Semigroup e, Apply w) => Apply (EnvT e w) Source # | An ``EnvT` e w` is not `Applicative` unless its `e` is a `Monoid`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: EnvT e w (a -> b) -> EnvT e w a -> EnvT e w b Source # (.>) :: EnvT e w a -> EnvT e w b -> EnvT e w b Source # (<.) :: EnvT e w a -> EnvT e w b -> EnvT e w a Source # liftF2 :: (a -> b -> c) -> EnvT e w a -> EnvT e w b -> EnvT e w c Source #
(Apply w, Semigroup s) => Apply (StoreT s w) Source # | A ``StoreT` s w` is not `Applicative` unless its `s` is a `Monoid`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: StoreT s w (a -> b) -> StoreT s w a -> StoreT s w b Source # (.>) :: StoreT s w a -> StoreT s w b -> StoreT s w b Source # (<.) :: StoreT s w a -> StoreT s w b -> StoreT s w a Source # liftF2 :: (a -> b -> c) -> StoreT s w a -> StoreT s w b -> StoreT s w c Source #
Apply w => Apply (TracedT m w) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: TracedT m w (a -> b) -> TracedT m w a -> TracedT m w b Source # (.>) :: TracedT m w a -> TracedT m w b -> TracedT m w b Source # (<.) :: TracedT m w a -> TracedT m w b -> TracedT m w a Source # liftF2 :: (a -> b -> c) -> TracedT m w a -> TracedT m w b -> TracedT m w c Source #
Semigroup m => Apply (Const m :: Type -> Type) Source # | A ``Const` m` is not `Applicative` unless its `m` is a `Monoid`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Const m (a -> b) -> Const m a -> Const m b Source # (.>) :: Const m a -> Const m b -> Const m b Source # (<.) :: Const m a -> Const m b -> Const m a Source # liftF2 :: (a -> b -> c) -> Const m a -> Const m b -> Const m c Source #
Apply f => Apply (Alt f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Alt f (a -> b) -> Alt f a -> Alt f b Source # (.>) :: Alt f a -> Alt f b -> Alt f b Source # (<.) :: Alt f a -> Alt f b -> Alt f a Source # liftF2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c Source #
Apply f => Apply (Rec1 f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Rec1 f (a -> b) -> Rec1 f a -> Rec1 f b Source # (.>) :: Rec1 f a -> Rec1 f b -> Rec1 f b Source # (<.) :: Rec1 f a -> Rec1 f b -> Rec1 f a Source # liftF2 :: (a -> b -> c) -> Rec1 f a -> Rec1 f b -> Rec1 f c Source #
Apply f => Apply (Static f a) Source # |
Instance details Defined in Data.Semigroupoid.Static Methods (<.>) :: Static f a (a0 -> b) -> Static f a a0 -> Static f a b Source # (.>) :: Static f a a0 -> Static f a b -> Static f a b Source # (<.) :: Static f a a0 -> Static f a b -> Static f a a0 Source # liftF2 :: (a0 -> b -> c) -> Static f a a0 -> Static f a b -> Static f a c Source #
Apply (Tagged a) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Tagged a (a0 -> b) -> Tagged a a0 -> Tagged a b Source # (.>) :: Tagged a a0 -> Tagged a b -> Tagged a b Source # (<.) :: Tagged a a0 -> Tagged a b -> Tagged a a0 Source # liftF2 :: (a0 -> b -> c) -> Tagged a a0 -> Tagged a b -> Tagged a c Source #
Apply f => Apply (Backwards f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Backwards f (a -> b) -> Backwards f a -> Backwards f b Source # (.>) :: Backwards f a -> Backwards f b -> Backwards f b Source # (<.) :: Backwards f a -> Backwards f b -> Backwards f a Source # liftF2 :: (a -> b -> c) -> Backwards f a -> Backwards f b -> Backwards f c Source #
(Functor m, Monad m) => Apply (ExceptT e m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: ExceptT e m (a -> b) -> ExceptT e m a -> ExceptT e m b Source # (.>) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m b Source # (<.) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m a Source # liftF2 :: (a -> b -> c) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c Source #
Apply w => Apply (IdentityT w) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: IdentityT w (a -> b) -> IdentityT w a -> IdentityT w b Source # (.>) :: IdentityT w a -> IdentityT w b -> IdentityT w b Source # (<.) :: IdentityT w a -> IdentityT w b -> IdentityT w a Source # liftF2 :: (a -> b -> c) -> IdentityT w a -> IdentityT w b -> IdentityT w c Source #
Apply m => Apply (ReaderT e m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: ReaderT e m (a -> b) -> ReaderT e m a -> ReaderT e m b Source # (.>) :: ReaderT e m a -> ReaderT e m b -> ReaderT e m b Source # (<.) :: ReaderT e m a -> ReaderT e m b -> ReaderT e m a Source # liftF2 :: (a -> b -> c) -> ReaderT e m a -> ReaderT e m b -> ReaderT e m c Source #
Bind m => Apply (StateT s m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b Source # (.>) :: StateT s m a -> StateT s m b -> StateT s m b Source # (<.) :: StateT s m a -> StateT s m b -> StateT s m a Source # liftF2 :: (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c Source #
Bind m => Apply (StateT s m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b Source # (.>) :: StateT s m a -> StateT s m b -> StateT s m b Source # (<.) :: StateT s m a -> StateT s m b -> StateT s m a Source # liftF2 :: (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c Source #
Bind m => Apply (WriterT w m) Source # | Since: 5.3.6
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b Source # (.>) :: WriterT w m a -> WriterT w m b -> WriterT w m b Source # (<.) :: WriterT w m a -> WriterT w m b -> WriterT w m a Source # liftF2 :: (a -> b -> c) -> WriterT w m a -> WriterT w m b -> WriterT w m c Source #
(Apply m, Semigroup w) => Apply (WriterT w m) Source # | A ``WriterT` w m` is not `Applicative` unless its `w` is a `Monoid`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b Source # (.>) :: WriterT w m a -> WriterT w m b -> WriterT w m b Source # (<.) :: WriterT w m a -> WriterT w m b -> WriterT w m a Source # liftF2 :: (a -> b -> c) -> WriterT w m a -> WriterT w m b -> WriterT w m c Source #
(Apply m, Semigroup w) => Apply (WriterT w m) Source # | A ``WriterT` w m` is not `Applicative` unless its `w` is a `Monoid`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b Source # (.>) :: WriterT w m a -> WriterT w m b -> WriterT w m b Source # (<.) :: WriterT w m a -> WriterT w m b -> WriterT w m a Source # liftF2 :: (a -> b -> c) -> WriterT w m a -> WriterT w m b -> WriterT w m c Source #
Semigroup f => Apply (Constant f :: Type -> Type) Source # | A ``Constant` f` is not `Applicative` unless its `f` is a `Monoid`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Constant f (a -> b) -> Constant f a -> Constant f b Source # (.>) :: Constant f a -> Constant f b -> Constant f b Source # (<.) :: Constant f a -> Constant f b -> Constant f a Source # liftF2 :: (a -> b -> c) -> Constant f a -> Constant f b -> Constant f c Source #
Apply f => Apply (Reverse f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Reverse f (a -> b) -> Reverse f a -> Reverse f b Source # (.>) :: Reverse f a -> Reverse f b -> Reverse f b Source # (<.) :: Reverse f a -> Reverse f b -> Reverse f a Source # liftF2 :: (a -> b -> c) -> Reverse f a -> Reverse f b -> Reverse f c Source #
(Apply f, Apply g) => Apply (Product f g) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Product f g (a -> b) -> Product f g a -> Product f g b 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 # liftF2 :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c Source #
Apply (Cokleisli w a) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Cokleisli w a (a0 -> b) -> Cokleisli w a a0 -> Cokleisli w a b Source # (.>) :: Cokleisli w a a0 -> Cokleisli w a b -> Cokleisli w a b Source # (<.) :: Cokleisli w a a0 -> Cokleisli w a b -> Cokleisli w a a0 Source # liftF2 :: (a0 -> b -> c) -> Cokleisli w a a0 -> Cokleisli w a b -> Cokleisli w a c Source #
(Apply f, Apply g) => Apply (f :*: g) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: (f :*: g) (a -> b) -> (f :*: g) a -> (f :*: g) b Source # (.>) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) b Source # (<.) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) a Source # liftF2 :: (a -> b -> c) -> (f :*: g) a -> (f :*: g) b -> (f :*: g) c Source #
Semigroup c => Apply (K1 i c :: Type -> Type) Source # | A ``K1` i c` is not `Applicative` unless its `c` is a `Monoid`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: K1 i c (a -> b) -> K1 i c a -> K1 i c b Source # (.>) :: K1 i c a -> K1 i c b -> K1 i c b Source # (<.) :: K1 i c a -> K1 i c b -> K1 i c a Source # liftF2 :: (a -> b -> c0) -> K1 i c a -> K1 i c b -> K1 i c c0 Source #
Apply (ContT r m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: ContT r m (a -> b) -> ContT r m a -> ContT r m b Source # (.>) :: ContT r m a -> ContT r m b -> ContT r m b Source # (<.) :: ContT r m a -> ContT r m b -> ContT r m a Source # liftF2 :: (a -> b -> c) -> ContT r m a -> ContT r m b -> ContT r m c Source #
Apply ((->) m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: (m -> (a -> b)) -> (m -> a) -> m -> b Source # (.>) :: (m -> a) -> (m -> b) -> m -> b Source # (<.) :: (m -> a) -> (m -> b) -> m -> a Source # liftF2 :: (a -> b -> c) -> (m -> a) -> (m -> b) -> m -> c Source #
(Apply f, Apply g) => Apply (Compose f g) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: Compose f g (a -> b) -> Compose f g a -> Compose f g b 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 # liftF2 :: (a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c Source #
(Apply f, Apply g) => Apply (f :.: g) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: (f :.: g) (a -> b) -> (f :.: g) a -> (f :.: g) b Source # (.>) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) b Source # (<.) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) a Source # liftF2 :: (a -> b -> c) -> (f :.: g) a -> (f :.: g) b -> (f :.: g) c Source #
Apply f => Apply (M1 i t f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: M1 i t f (a -> b) -> M1 i t f a -> M1 i t f b Source # (.>) :: M1 i t f a -> M1 i t f b -> M1 i t f b Source # (<.) :: M1 i t f a -> M1 i t f b -> M1 i t f a Source # liftF2 :: (a -> b -> c) -> M1 i t f a -> M1 i t f b -> M1 i t f c Source #
Bind m => Apply (RWST r w s m) Source # | Since: 5.3.6
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b Source # (.>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b Source # (<.) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source # liftF2 :: (a -> b -> c) -> RWST r w s m a -> RWST r w s m b -> RWST r w s m c Source #
(Bind m, Semigroup w) => Apply (RWST r w s m) Source # | An ``RWST` r w s m` is not `Applicative` unless its `w` is a `Monoid`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b Source # (.>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b Source # (<.) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source # liftF2 :: (a -> b -> c) -> RWST r w s m a -> RWST r w s m b -> RWST r w s m c Source #
(Bind m, Semigroup w) => Apply (RWST r w s m) Source # | An ``RWST` r w s m` is not `Applicative` unless its `w` is a `Monoid`, but it is an instance of `Apply`
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b Source # (.>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b Source # (<.) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source # liftF2 :: (a -> b -> c) -> RWST r w s m a -> RWST r w s m b -> RWST r w s m c Source #

(<..>) :: Apply w => w a -> w (a -> b) -> w b infixl 4 Source #

A variant of `<.>` with the arguments reversed.

liftF3 :: Apply w => (a -> b -> c -> d) -> w a -> w b -> w c -> w d Source #

Lift a ternary function into a comonad with zipping

# Wrappers

newtype WrappedApplicative (f :: Type -> Type) a Source #

Wrap an `Applicative` to be used as a member of `Apply`

Constructors

WrapApplicative |

Fields

- unwrapApplicative :: f a

#### Instances

Instances details

Alternative f => Alternative (WrappedApplicative f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods empty :: WrappedApplicative f a Source # (<|>) :: WrappedApplicative f a -> WrappedApplicative f a -> WrappedApplicative f a Source # some :: WrappedApplicative f a -> WrappedApplicative f [a] Source # many :: WrappedApplicative f a -> WrappedApplicative f [a] Source #
Applicative f => Applicative (WrappedApplicative f) Source # |

Instance details

Defined in Data.Functor.Bind.Class

Methods

pure :: a -> WrappedApplicative f a Source #

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

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

(*>) :: WrappedApplicative f a -> WrappedApplicative f b -> WrappedApplicative f b Source #

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

Functor f => Functor (WrappedApplicative f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods fmap :: (a -> b) -> WrappedApplicative f a -> WrappedApplicative f b Source # (<$) :: a -> WrappedApplicative f b -> WrappedApplicative f a Source #
Alternative f => Alt (WrappedApplicative f) Source # |
Instance details Defined in Data.Functor.Alt Methods (<!>) :: WrappedApplicative f a -> WrappedApplicative f a -> WrappedApplicative f a Source # some :: Applicative (WrappedApplicative f) => WrappedApplicative f a -> WrappedApplicative f [a] Source # many :: Applicative (WrappedApplicative f) => WrappedApplicative f a -> WrappedApplicative f [a] Source #
Applicative f => Apply (WrappedApplicative f) Source # |

Instance details

Defined in Data.Functor.Bind.Class

Methods

(<.>) :: WrappedApplicative f (a -> b) -> WrappedApplicative f a -> WrappedApplicative f b Source #

(.>) :: WrappedApplicative f a -> WrappedApplicative f b -> WrappedApplicative f b Source #

(<.) :: WrappedApplicative f a -> WrappedApplicative f b -> WrappedApplicative f a Source #

liftF2 :: (a -> b -> c) -> WrappedApplicative f a -> WrappedApplicative f b -> WrappedApplicative f c Source #

Alternative f => Plus (WrappedApplicative f) Source # |
Instance details Defined in Data.Functor.Plus Methods zero :: WrappedApplicative f a Source #

newtype MaybeApply (f :: Type -> Type) a Source #

Transform an Apply into an Applicative by adding a unit.

Constructors

MaybeApply |

Fields

- runMaybeApply :: Either (f a) a

#### Instances

Instances details

Comonad f => Comonad (MaybeApply f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods extract :: MaybeApply f a -> a Source # duplicate :: MaybeApply f a -> MaybeApply f (MaybeApply f a) Source # extend :: (MaybeApply f a -> b) -> MaybeApply f a -> MaybeApply f b Source #
Apply f => Applicative (MaybeApply f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods pure :: a -> MaybeApply f a Source # (<*>) :: MaybeApply f (a -> b) -> MaybeApply f a -> MaybeApply f b Source # liftA2 :: (a -> b -> c) -> MaybeApply f a -> MaybeApply f b -> MaybeApply f c Source # (*>) :: MaybeApply f a -> MaybeApply f b -> MaybeApply f b Source # (<*) :: MaybeApply f a -> MaybeApply f b -> MaybeApply f a Source #
Functor f => Functor (MaybeApply f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods fmap :: (a -> b) -> MaybeApply f a -> MaybeApply f b Source # (<$) :: a -> MaybeApply f b -> MaybeApply f a Source #
Apply f => Apply (MaybeApply f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (<.>) :: MaybeApply f (a -> b) -> MaybeApply f a -> MaybeApply f b Source # (.>) :: MaybeApply f a -> MaybeApply f b -> MaybeApply f b Source # (<.) :: MaybeApply f a -> MaybeApply f b -> MaybeApply f a Source # liftF2 :: (a -> b -> c) -> MaybeApply f a -> MaybeApply f b -> MaybeApply f c Source #
Extend f => Extend (MaybeApply f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods duplicated :: MaybeApply f a -> MaybeApply f (MaybeApply f a) Source # extended :: (MaybeApply f a -> b) -> MaybeApply f a -> MaybeApply f b Source #

# Bindable functors

class Apply m => Bind (m :: Type -> Type) where Source #

A `Monad` sans `return`.

Minimal definition: Either `join` or `>>-`

If defining both, then the following laws (the default definitions) must hold:

    join = (>>- id)
    m >>- f = join (fmap f m)

Laws:

    induced definition of <.>: f <.> x = f >>- (<$> x)

Finally, there are two associativity conditions:

    associativity of (>>-):    (m >>- f) >>- g == m >>- (\x -> f x >>- g)
    associativity of join:     join . join = join . fmap join

These can both be seen as special cases of the constraint that

    associativity of (->-): (f ->- g) ->- h = f ->- (g ->- h)

Minimal complete definition

(>>-) | join

Methods

(>>-) :: m a -> (a -> m b) -> m b infixl 1 Source #

join :: m (m a) -> m a Source #

#### Instances

Instances details

Bind Complex Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Complex a -> (a -> Complex b) -> Complex b Source # join :: Complex (Complex a) -> Complex a Source #
Bind First Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: First a -> (a -> First b) -> First b Source # join :: First (First a) -> First a Source #
Bind Last Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Last a -> (a -> Last b) -> Last b Source # join :: Last (Last a) -> Last a Source #
Bind Max Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Max a -> (a -> Max b) -> Max b Source # join :: Max (Max a) -> Max a Source #
Bind Min Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Min a -> (a -> Min b) -> Min b Source # join :: Min (Min a) -> Min a Source #
Bind IntMap Source # | An `IntMap` is not a `Monad`, but it is an instance of `Bind`
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: IntMap a -> (a -> IntMap b) -> IntMap b Source # join :: IntMap (IntMap a) -> IntMap a Source #
Bind Seq Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Seq a -> (a -> Seq b) -> Seq b Source # join :: Seq (Seq a) -> Seq a Source #
Bind Tree Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Tree a -> (a -> Tree b) -> Tree b Source # join :: Tree (Tree a) -> Tree a Source #
Bind NonEmpty Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: NonEmpty a -> (a -> NonEmpty b) -> NonEmpty b Source # join :: NonEmpty (NonEmpty a) -> NonEmpty a Source #
Bind Identity Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Identity a -> (a -> Identity b) -> Identity b Source # join :: Identity (Identity a) -> Identity a Source #
Bind First Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: First a -> (a -> First b) -> First b Source # join :: First (First a) -> First a Source #
Bind Last Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Last a -> (a -> Last b) -> Last b Source # join :: Last (Last a) -> Last a Source #
Bind Down Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Down a -> (a -> Down b) -> Down b Source # join :: Down (Down a) -> Down a Source #
Bind Dual Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Dual a -> (a -> Dual b) -> Dual b Source # join :: Dual (Dual a) -> Dual a Source #
Bind Product Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Product a -> (a -> Product b) -> Product b Source # join :: Product (Product a) -> Product a Source #
Bind Sum Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Sum a -> (a -> Sum b) -> Sum b Source # join :: Sum (Sum a) -> Sum a Source #
Bind Par1 Source # | Since: 5.3.8
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Par1 a -> (a -> Par1 b) -> Par1 b Source # join :: Par1 (Par1 a) -> Par1 a Source #
Bind IO Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: IO a -> (a -> IO b) -> IO b Source # join :: IO (IO a) -> IO a Source #
Bind Q Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Q a -> (a -> Q b) -> Q b Source # join :: Q (Q a) -> Q a Source #
Bind Maybe Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Maybe a -> (a -> Maybe b) -> Maybe b Source # join :: Maybe (Maybe a) -> Maybe a Source #
Bind [] Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: [a] -> (a -> [b]) -> [b] Source # join :: [[a]] -> [a] Source #
Monad m => Bind (WrappedMonad m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b Source # join :: WrappedMonad m (WrappedMonad m a) -> WrappedMonad m a Source #
Ord k => Bind (Map k) Source # | A 'Map k' is not a `Monad`, but it is an instance of `Bind`
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Map k a -> (a -> Map k b) -> Map k b Source # join :: Map k (Map k a) -> Map k a Source #
Bind (Either a) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Either a a0 -> (a0 -> Either a b) -> Either a b Source # join :: Either a (Either a a0) -> Either a a0 Source #
Bind (Proxy :: Type -> Type) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Proxy a -> (a -> Proxy b) -> Proxy b Source # join :: Proxy (Proxy a) -> Proxy a Source #
Bind (U1 :: Type -> Type) Source # | Since: 5.3.8
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: U1 a -> (a -> U1 b) -> U1 b Source # join :: U1 (U1 a) -> U1 a Source #
Bind (V1 :: Type -> Type) Source # | A `V1` is not a `Monad`, but it is an instance of `Bind`
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: V1 a -> (a -> V1 b) -> V1 b Source # join :: V1 (V1 a) -> V1 a Source #
(Functor m, Monad m) => Bind (MaybeT m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: MaybeT m a -> (a -> MaybeT m b) -> MaybeT m b Source # join :: MaybeT m (MaybeT m a) -> MaybeT m a Source #
(Hashable k, Eq k) => Bind (HashMap k) Source # | A 'HashMap k' is not a `Monad`, but it is an instance of `Bind`
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: HashMap k a -> (a -> HashMap k b) -> HashMap k b Source # join :: HashMap k (HashMap k a) -> HashMap k a Source #
Semigroup m => Bind ((,) m) Source # | A ``(,)` m` is not a `Monad` unless its `m` is a `Monoid`, but it is an instance of `Bind`
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: (m, a) -> (a -> (m, b)) -> (m, b) Source # join :: (m, (m, a)) -> (m, a) Source #
Bind f => Bind (Alt f) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Alt f a -> (a -> Alt f b) -> Alt f b Source # join :: Alt f (Alt f a) -> Alt f a Source #
Bind m => Bind (Rec1 m) Source # | Since: 5.3.8
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Rec1 m a -> (a -> Rec1 m b) -> Rec1 m b Source # join :: Rec1 m (Rec1 m a) -> Rec1 m a Source #
Bind (Tagged a) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Tagged a a0 -> (a0 -> Tagged a b) -> Tagged a b Source # join :: Tagged a (Tagged a a0) -> Tagged a a0 Source #
(Functor m, Monad m) => Bind (ExceptT e m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: ExceptT e m a -> (a -> ExceptT e m b) -> ExceptT e m b Source # join :: ExceptT e m (ExceptT e m a) -> ExceptT e m a Source #
Bind m => Bind (IdentityT m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: IdentityT m a -> (a -> IdentityT m b) -> IdentityT m b Source # join :: IdentityT m (IdentityT m a) -> IdentityT m a Source #
Bind m => Bind (ReaderT e m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: ReaderT e m a -> (a -> ReaderT e m b) -> ReaderT e m b Source # join :: ReaderT e m (ReaderT e m a) -> ReaderT e m a Source #
Bind m => Bind (StateT s m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: StateT s m a -> (a -> StateT s m b) -> StateT s m b Source # join :: StateT s m (StateT s m a) -> StateT s m a Source #
Bind m => Bind (StateT s m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: StateT s m a -> (a -> StateT s m b) -> StateT s m b Source # join :: StateT s m (StateT s m a) -> StateT s m a Source #
Bind m => Bind (WriterT w m) Source # | Since: 5.3.6
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: WriterT w m a -> (a -> WriterT w m b) -> WriterT w m b Source # join :: WriterT w m (WriterT w m a) -> WriterT w m a Source #
(Bind m, Semigroup w) => Bind (WriterT w m) Source # | A ``WriterT` w m` is not a `Monad` unless its `w` is a `Monoid`, but it is an instance of `Bind`
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: WriterT w m a -> (a -> WriterT w m b) -> WriterT w m b Source # join :: WriterT w m (WriterT w m a) -> WriterT w m a Source #
(Bind m, Semigroup w) => Bind (WriterT w m) Source # | A ``WriterT` w m` is not a `Monad` unless its `w` is a `Monoid`, but it is an instance of `Bind`
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: WriterT w m a -> (a -> WriterT w m b) -> WriterT w m b Source # join :: WriterT w m (WriterT w m a) -> WriterT w m a Source #
(Bind f, Bind g) => Bind (Product f g) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: Product f g a -> (a -> Product f g b) -> Product f g b Source # join :: Product f g (Product f g a) -> Product f g a Source #
(Bind f, Bind g) => Bind (f :*: g) Source # | Since: 5.3.8
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: (f :*: g) a -> (a -> (f :*: g) b) -> (f :*: g) b Source # join :: (f :*: g) ((f :*: g) a) -> (f :*: g) a Source #
Bind (ContT r m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: ContT r m a -> (a -> ContT r m b) -> ContT r m b Source # join :: ContT r m (ContT r m a) -> ContT r m a Source #
Bind ((->) m) Source # |
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: (m -> a) -> (a -> m -> b) -> m -> b Source # join :: (m -> (m -> a)) -> m -> a Source #
Bind f => Bind (M1 i c f) Source # | Since: 5.3.8
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: M1 i c f a -> (a -> M1 i c f b) -> M1 i c f b Source # join :: M1 i c f (M1 i c f a) -> M1 i c f a Source #
Bind m => Bind (RWST r w s m) Source # | Since: 5.3.6
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: RWST r w s m a -> (a -> RWST r w s m b) -> RWST r w s m b Source # join :: RWST r w s m (RWST r w s m a) -> RWST r w s m a Source #
(Bind m, Semigroup w) => Bind (RWST r w s m) Source # | An ``RWST` r w s m` is not a `Monad` unless its `w` is a `Monoid`, but it is an instance of `Bind`
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: RWST r w s m a -> (a -> RWST r w s m b) -> RWST r w s m b Source # join :: RWST r w s m (RWST r w s m a) -> RWST r w s m a Source #
(Bind m, Semigroup w) => Bind (RWST r w s m) Source # | An ``RWST` r w s m` is not a `Monad` unless its `w` is a `Monoid`, but it is an instance of `Bind`
Instance details Defined in Data.Functor.Bind.Class Methods (>>-) :: RWST r w s m a -> (a -> RWST r w s m b) -> RWST r w s m b Source # join :: RWST r w s m (RWST r w s m a) -> RWST r w s m a Source #

gbind :: (Generic1 m, Bind (Rep1 m)) => m a -> (a -> m b) -> m b Source #

Generic `(>>-)`. Caveats:

1. Will not compile if `m` is a sum type.
2. Will not compile if `m` contains fields that do not mention its type variable.
3. Will not compile if `m` contains fields where the type variable appears underneath the composition of type constructors (e.g., `f (g a)`).
4. May do redundant work, due to the nature of the `Bind` instance for (`:*:`)

Since: 5.3.8

(-<<) :: Bind m => (a -> m b) -> m a -> m b infixr 1 Source #

(-<-) :: Bind m => (b -> m c) -> (a -> m b) -> a -> m c infixr 1 Source #

(->-) :: Bind m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 Source #

apDefault :: Bind f => f (a -> b) -> f a -> f b Source #

returning :: Functor f => f a -> (a -> b) -> f b Source #