Copyright | (C) 2011-2018 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.Class
Description
This module is used to resolve the cyclic we get from defining these
classes here rather than in a package upstream. Otherwise we'd get
orphaned heads for many instances on the types in transformers
and bifunctors
.
Synopsis
- class Functor f => Apply f where
- newtype WrappedApplicative f a = WrapApplicative {
- unwrapApplicative :: f a
- newtype MaybeApply f a = MaybeApply {
- runMaybeApply :: Either (f a) a
- (<.*>) :: Apply f => f (a -> b) -> MaybeApply f a -> f b
- (<*.>) :: Apply f => MaybeApply f (a -> b) -> f a -> f b
- traverse1Maybe :: (Traversable t, Apply f) => (a -> f b) -> t a -> MaybeApply f (t b)
- class Apply m => Bind m where
- apDefault :: Bind f => f (a -> b) -> f a -> f b
- returning :: Functor f => f a -> (a -> b) -> f b
- class Bifunctor p => Biapply p where
Applyable functors
class Functor f => Apply f 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)
Methods
(<.>) :: f (a -> b) -> f a -> f b infixl 4 Source #
(.>) :: f a -> f b -> f b infixl 4 Source #
(<.) :: f a -> f b -> f a infixl 4 Source #
liftF2 :: (a -> b -> c) -> f a -> f b -> f c Source #
Lift a binary function into a comonad with zipping
Instances
Apply ZipList Source # | |
Apply Complex Source # | |
Apply Identity Source # | |
Apply First Source # | |
Apply Last Source # | |
Apply Down Source # | |
Apply First Source # | |
Apply Last Source # | |
Apply Max Source # | |
Apply Min Source # | |
Apply Dual Source # | |
Apply Product Source # | |
Apply Sum Source # | |
Apply Par1 Source # | |
Apply IntMap Source # | An |
Apply Seq Source # | |
Apply Tree Source # | |
Apply IO Source # | |
Apply Q Source # | |
Apply NonEmpty Source # | |
Apply Maybe Source # | |
Apply [] Source # | |
Monad m => Apply (WrappedMonad m) Source # | |
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 # | |
Apply (Either a) Source # | |
Apply (Proxy :: Type -> Type) Source # | |
Apply (U1 :: Type -> Type) Source # | |
Apply (V1 :: Type -> Type) Source # | A |
Ord k => Apply (Map k) Source # | A 'Map k' is not |
Apply f => Apply (MaybeApply f) Source # | |
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 # | |
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 # | |
Apply m => Apply (ListT m) Source # | |
(Functor m, Monad m) => Apply (MaybeT m) Source # | |
(Hashable k, Eq k) => Apply (HashMap k) Source # | A 'HashMap k' is not |
Defined in Data.Functor.Bind.Class | |
Semigroup m => Apply ((,) m) Source # | A |
Arrow a => Apply (WrappedArrow a b) Source # | |
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 # | |
Semigroup m => Apply (Const m :: Type -> Type) Source # | A |
Apply f => Apply (Alt f) Source # | |
Apply f => Apply (Rec1 f) Source # | |
Biapply p => Apply (Join p) Source # | |
(Semigroup e, Apply w) => Apply (EnvT e w) Source # | An |
(Apply w, Semigroup s) => Apply (StoreT s w) Source # | A |
Defined in Data.Functor.Bind.Class | |
Apply w => Apply (TracedT m w) Source # | |
Defined in Data.Functor.Bind.Class | |
Apply f => Apply (Static f a) Source # | |
Defined in Data.Semigroupoid.Static | |
Apply (Tagged a) Source # | |
Apply f => Apply (Backwards f) Source # | |
Defined in Data.Functor.Bind.Class | |
(Functor m, Monad m) => Apply (ErrorT e m) Source # | |
Defined in Data.Functor.Bind.Class | |
(Functor m, Monad m) => Apply (ExceptT e m) Source # | |
Defined in Data.Functor.Bind.Class | |
Apply w => Apply (IdentityT w) Source # | |
Defined in Data.Functor.Bind.Class | |
Apply m => Apply (ReaderT e m) Source # | |
Defined in Data.Functor.Bind.Class | |
Bind m => Apply (StateT s m) Source # | |
Defined in Data.Functor.Bind.Class | |
Bind m => Apply (StateT s m) Source # | |
Defined in Data.Functor.Bind.Class | |
Bind m => Apply (WriterT w m) Source # | Since: 5.3.6 |
Defined in Data.Functor.Bind.Class | |
(Apply m, Semigroup w) => Apply (WriterT w m) Source # | A |
Defined in Data.Functor.Bind.Class | |
(Apply m, Semigroup w) => Apply (WriterT w m) Source # | A |
Defined in Data.Functor.Bind.Class | |
Semigroup f => Apply (Constant f :: Type -> Type) Source # | A |
Defined in Data.Functor.Bind.Class | |
Apply f => Apply (Reverse f) Source # | |
Defined in Data.Functor.Bind.Class | |
(Apply f, Apply g) => Apply (Product f g) Source # | |
Defined in Data.Functor.Bind.Class | |
(Apply f, Apply g) => Apply (f :*: g) Source # | |
Defined in Data.Functor.Bind.Class | |
Semigroup c => Apply (K1 i c :: Type -> Type) Source # | A |
Apply (Cokleisli w a) Source # | |
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 (ContT r m) Source # | |
Defined in Data.Functor.Bind.Class | |
Apply ((->) m) Source # | |
(Apply f, Apply g) => Apply (Compose f g) Source # | |
Defined in Data.Functor.Bind.Class | |
(Apply f, Apply g) => Apply (f :.: g) Source # | |
Defined in Data.Functor.Bind.Class | |
Apply f => Apply (M1 i t f) Source # | |
Bind m => Apply (RWST r w s m) Source # | Since: 5.3.6 |
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 |
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 |
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 # |
Wrappers
newtype WrappedApplicative f a Source #
Wrap an Applicative
to be used as a member of Apply
Constructors
WrapApplicative | |
Fields
|
Instances
newtype MaybeApply f a Source #
Transform an Apply into an Applicative by adding a unit.
Constructors
MaybeApply | |
Fields
|
Instances
(<.*>) :: Apply f => f (a -> b) -> MaybeApply f a -> f b infixl 4 Source #
Apply a non-empty container of functions to a possibly-empty-with-unit container of values.
(<*.>) :: Apply f => MaybeApply f (a -> b) -> f a -> f b infixl 4 Source #
Apply a possibly-empty-with-unit container of functions to a non-empty container of values.
traverse1Maybe :: (Traversable t, Apply f) => (a -> f b) -> t a -> MaybeApply f (t b) Source #
Traverse a Traversable
using Apply
, getting the results back in a MaybeApply
.
Bindable functors
class Apply m => Bind m 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)
Instances
Bind Complex Source # | |
Bind Identity Source # | |
Bind First Source # | |
Bind Last Source # | |
Bind Down Source # | |
Bind First Source # | |
Bind Last Source # | |
Bind Max Source # | |
Bind Min Source # | |
Bind Dual Source # | |
Bind Product Source # | |
Bind Sum Source # | |
Bind IntMap Source # | An |
Bind Seq Source # | |
Bind Tree Source # | |
Bind IO Source # | |
Bind Q Source # | |
Bind NonEmpty Source # | |
Bind Maybe Source # | |
Bind [] Source # | |
Monad m => Bind (WrappedMonad m) Source # | |
Bind (Either a) Source # | |
Bind (Proxy :: Type -> Type) Source # | |
Bind (V1 :: Type -> Type) Source # | A |
Ord k => Bind (Map k) Source # | A 'Map k' is not a |
(Apply m, Monad m) => Bind (ListT m) Source # | |
(Functor m, Monad m) => Bind (MaybeT m) Source # | |
(Hashable k, Eq k) => Bind (HashMap k) Source # | A 'HashMap k' is not a |
Semigroup m => Bind ((,) m) Source # | A |
Bind f => Bind (Alt f) Source # | |
Bind (Tagged a) Source # | |
(Functor m, Monad m) => Bind (ErrorT e m) Source # | |
(Functor m, Monad m) => Bind (ExceptT e m) Source # | |
Bind m => Bind (IdentityT m) Source # | |
Bind m => Bind (ReaderT e m) Source # | |
Bind m => Bind (StateT s m) Source # | |
Bind m => Bind (StateT s m) Source # | |
Bind m => Bind (WriterT w m) Source # | Since: 5.3.6 |
(Bind m, Semigroup w) => Bind (WriterT w m) Source # | A |
(Bind m, Semigroup w) => Bind (WriterT w m) Source # | A |
(Bind f, Bind g) => Bind (Product f g) Source # | |
Bind (ContT r m) Source # | |
Bind ((->) m) Source # | |
Bind m => Bind (RWST r w s m) Source # | Since: 5.3.6 |
(Bind m, Semigroup w) => Bind (RWST r w s m) Source # | An |
(Bind m, Semigroup w) => Bind (RWST r w s m) Source # | An |
Biappliable bifunctors
class Bifunctor p => Biapply p where Source #
Minimal complete definition
Methods
(<<.>>) :: p (a -> b) (c -> d) -> p a c -> p b d infixl 4 Source #
Instances
Biapply Arg Source # | |
Biapply (,) Source # | |
Biapply (Const :: Type -> Type -> Type) Source # | |
Biapply (Tagged :: Type -> Type -> Type) Source # | |
Semigroup x => Biapply ((,,) x) Source # | |
(Semigroup x, Semigroup y) => Biapply ((,,,) x y) Source # | |
Apply f => Biapply (Clown f :: Type -> Type -> Type) Source # | |
Biapply p => Biapply (Flip p) Source # | |
Apply g => Biapply (Joker g :: Type -> Type -> Type) Source # | |
Biapply p => Biapply (WrappedBifunctor p) Source # | |
Defined in Data.Functor.Bind.Class | |
(Semigroup x, Semigroup y, Semigroup z) => Biapply ((,,,,) x y z) Source # | |
(Biapply p, Biapply q) => Biapply (Product p q) Source # | |
(Apply f, Biapply p) => Biapply (Tannen f p) Source # | |
(Biapply p, Apply f, Apply g) => Biapply (Biff p f g) Source # | |