| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Control.Monad.Indexed
Description
This module defines the main indexed monad hierarchy and some standard
indexed monad combinators. This is meant to look familiar to Haskell
programmers. Notice how there is no indexed functor class as, thanks to
quantified constraints, this role is played by the Prelude's Functor class.
Notice also how some traditional classes like MonadPlus and Alternative
are synonyms thanks to the Additive type class.
Synopsis
- class (forall (i :: k) (j :: k). Functor (f i j), forall (i :: k). Applicative (f i i)) => Applicative (f :: k -> k -> Type -> Type) where
- pure :: forall a (i :: k). a -> f i i a
- (<*>) :: forall (i :: k) (j :: k) a b (k1 :: k). f i j (a -> b) -> f j k1 a -> f i k1 b
- liftA2 :: forall a b c (i :: k) (j :: k) (k1 :: k). (a -> b -> c) -> f i j a -> f j k1 b -> f i k1 c
- (*>) :: forall (i :: k) (j :: k) a (k1 :: k) b. f i j a -> f j k1 b -> f i k1 b
- (<*) :: forall (i :: k) (j :: k) a (k1 :: k) b. f i j a -> f j k1 b -> f i k1 a
- class (Applicative m, forall (i :: k). Monad (m i i)) => Monad (m :: k -> k -> Type -> Type) where
- (>>=) :: forall (i :: k) (j :: k) a (k1 :: k) b. m i j a -> (a -> m j k1 b) -> m i k1 b
- type Alternative (m :: k -> k -> Type -> Type) = (Applicative m, forall (r :: k) (r' :: k) a. Additive (m r r' a))
- type MonadPlus (m :: k -> k -> Type -> Type) = (Monad m, forall (r :: k) (r' :: k) a. Additive (m r r' a))
- guard :: forall {k} m (i :: k). Alternative m => Bool -> m i i ()
- class Fail (m :: k -> k1 -> k2 -> Type) where
- type MonadFail (m :: k -> k -> Type -> Type) = (Monad m, Fail m)
- guardF :: forall {k} m (i :: k). (Applicative m, Fail m) => Bool -> String -> m i i ()
- newtype FromIndexed (m :: k -> k1 -> k2 -> Type) (i :: k) (j :: k1) (a :: k2) = FromIndexed (m i j a)
- data ((f :: k -> k1 -> k2 -> Type) :*: (g :: k -> k1 -> k2 -> Type)) (i :: k) (j :: k1) (a :: k2) = (:*:) (f i j a) (g i j a)
- fst_star :: forall {k1} {k2} {k3} f (g :: k1 -> k2 -> k3 -> Type) (i :: k1) (j :: k2) (a :: k3). (f :*: g) i j a -> f i j a
- snd_star :: forall {k1} {k2} {k3} (f :: k1 -> k2 -> k3 -> Type) g (i :: k1) (j :: k2) (a :: k3). (f :*: g) i j a -> g i j a
- newtype IgnoreIndices (m :: k -> Type) (i :: k1) (j :: k2) (a :: k) = IgnoreIndices {
- unIgnoreIndices :: m a
- (>>) :: forall {k1} m (i :: k1) (j :: k1) (k2 :: k1) a. Applicative m => m i j () -> m j k2 a -> m i k2 a
Indexed monad hierarchy
class (forall (i :: k) (j :: k). Functor (f i j), forall (i :: k). Applicative (f i i)) => Applicative (f :: k -> k -> Type -> Type) where Source #
Minimal complete definition
Methods
pure :: forall a (i :: k). a -> f i i a Source #
(<*>) :: forall (i :: k) (j :: k) a b (k1 :: k). f i j (a -> b) -> f j k1 a -> f i k1 b infixl 4 Source #
default (<*>) :: forall (i :: k) (j :: k) a b (k1 :: k). Monad f => f i j (a -> b) -> f j k1 a -> f i k1 b Source #
liftA2 :: forall a b c (i :: k) (j :: k) (k1 :: k). (a -> b -> c) -> f i j a -> f j k1 b -> f i k1 c Source #
(*>) :: forall (i :: k) (j :: k) a (k1 :: k) b. f i j a -> f j k1 b -> f i k1 b infixl 4 Source #
(<*) :: forall (i :: k) (j :: k) a (k1 :: k) b. f i j a -> f j k1 b -> f i k1 a infixl 4 Source #
Instances
| Comonad w => Applicative (ContW w :: Type -> Type -> Type -> Type) Source # | |
Defined in Control.Monad.Indexed.Cont Methods pure :: a -> ContW w i i a Source # (<*>) :: ContW w i j (a -> b) -> ContW w j k1 a -> ContW w i k1 b Source # liftA2 :: (a -> b -> c) -> ContW w i j a -> ContW w j k1 b -> ContW w i k1 c Source # (*>) :: ContW w i j a -> ContW w j k1 b -> ContW w i k1 b Source # (<*) :: ContW w i j a -> ContW w j k1 b -> ContW w i k1 a Source # | |
| Comonad w => Applicative (Cont2W w :: Type -> Type -> Type -> Type) Source # | |
Defined in Control.Monad.Indexed.Cont2 Methods pure :: a -> Cont2W w i i a Source # (<*>) :: Cont2W w i j (a -> b) -> Cont2W w j k1 a -> Cont2W w i k1 b Source # liftA2 :: (a -> b -> c) -> Cont2W w i j a -> Cont2W w j k1 b -> Cont2W w i k1 c Source # (*>) :: Cont2W w i j a -> Cont2W w j k1 b -> Cont2W w i k1 b Source # (<*) :: Cont2W w i j a -> Cont2W w j k1 b -> Cont2W w i k1 a Source # | |
| Applicative f => Applicative (IgnoreIndices f :: k -> k -> Type -> Type) Source # | |
Defined in Control.Monad.Indexed Methods pure :: forall a (i :: k). a -> IgnoreIndices f i i a Source # (<*>) :: forall (i :: k) (j :: k) a b (k1 :: k). IgnoreIndices f i j (a -> b) -> IgnoreIndices f j k1 a -> IgnoreIndices f i k1 b Source # liftA2 :: forall a b c (i :: k) (j :: k) (k1 :: k). (a -> b -> c) -> IgnoreIndices f i j a -> IgnoreIndices f j k1 b -> IgnoreIndices f i k1 c Source # (*>) :: forall (i :: k) (j :: k) a (k1 :: k) b. IgnoreIndices f i j a -> IgnoreIndices f j k1 b -> IgnoreIndices f i k1 b Source # (<*) :: forall (i :: k) (j :: k) a (k1 :: k) b. IgnoreIndices f i j a -> IgnoreIndices f j k1 b -> IgnoreIndices f i k1 a Source # | |
| (Applicative f, Applicative g) => Applicative (f :*: g :: k -> k -> Type -> Type) Source # | |
Defined in Control.Monad.Indexed Methods pure :: forall a (i :: k). a -> (f :*: g) i i a Source # (<*>) :: forall (i :: k) (j :: k) a b (k1 :: k). (f :*: g) i j (a -> b) -> (f :*: g) j k1 a -> (f :*: g) i k1 b Source # liftA2 :: forall a b c (i :: k) (j :: k) (k1 :: k). (a -> b -> c) -> (f :*: g) i j a -> (f :*: g) j k1 b -> (f :*: g) i k1 c Source # (*>) :: forall (i :: k) (j :: k) a (k1 :: k) b. (f :*: g) i j a -> (f :*: g) j k1 b -> (f :*: g) i k1 b Source # (<*) :: forall (i :: k) (j :: k) a (k1 :: k) b. (f :*: g) i j a -> (f :*: g) j k1 b -> (f :*: g) i k1 a Source # | |
class (Applicative m, forall (i :: k). Monad (m i i)) => Monad (m :: k -> k -> Type -> Type) where Source #
Methods
(>>=) :: forall (i :: k) (j :: k) a (k1 :: k) b. m i j a -> (a -> m j k1 b) -> m i k1 b Source #
Instances
| Comonad w => Monad (ContW w :: Type -> Type -> Type -> Type) Source # | |
| Comonad w => Monad (Cont2W w :: Type -> Type -> Type -> Type) Source # | |
| Monad m => Monad (IgnoreIndices m :: k -> k -> Type -> Type) Source # | |
Defined in Control.Monad.Indexed Methods (>>=) :: forall (i :: k) (j :: k) a (k1 :: k) b. IgnoreIndices m i j a -> (a -> IgnoreIndices m j k1 b) -> IgnoreIndices m i k1 b Source # | |
| (Monad f, Monad g) => Monad (f :*: g :: k -> k -> Type -> Type) Source # | |
type Alternative (m :: k -> k -> Type -> Type) = (Applicative m, forall (r :: k) (r' :: k) a. Additive (m r r' a)) Source #
type MonadPlus (m :: k -> k -> Type -> Type) = (Monad m, forall (r :: k) (r' :: k) a. Additive (m r r' a)) Source #
guard :: forall {k} m (i :: k). Alternative m => Bool -> m i i () Source #
class Fail (m :: k -> k1 -> k2 -> Type) where Source #
This class is mainly used for the qualified `do`-notation, as described in
the documentation for MonadFail. Occasionally used to fail with an
error message in monads which support it, see for instance guardF below.
Deriving-via combinators
newtype FromIndexed (m :: k -> k1 -> k2 -> Type) (i :: k) (j :: k1) (a :: k2) Source #
A deriving via combinator
Constructors
| FromIndexed (m i j a) |
Instances
Index monad combinators
Product of indexed gadgets
data ((f :: k -> k1 -> k2 -> Type) :*: (g :: k -> k1 -> k2 -> Type)) (i :: k) (j :: k1) (a :: k2) Source #
Constructors
| (:*:) (f i j a) (g i j a) |
Instances
| (Fail f, Fail g) => Fail (f :*: g :: k1 -> k2 -> k3 -> Type) Source # | |
| (Applicative f, Applicative g) => Applicative (f :*: g :: k -> k -> Type -> Type) Source # | |
Defined in Control.Monad.Indexed Methods pure :: forall a (i :: k). a -> (f :*: g) i i a Source # (<*>) :: forall (i :: k) (j :: k) a b (k1 :: k). (f :*: g) i j (a -> b) -> (f :*: g) j k1 a -> (f :*: g) i k1 b Source # liftA2 :: forall a b c (i :: k) (j :: k) (k1 :: k). (a -> b -> c) -> (f :*: g) i j a -> (f :*: g) j k1 b -> (f :*: g) i k1 c Source # (*>) :: forall (i :: k) (j :: k) a (k1 :: k) b. (f :*: g) i j a -> (f :*: g) j k1 b -> (f :*: g) i k1 b Source # (<*) :: forall (i :: k) (j :: k) a (k1 :: k) b. (f :*: g) i j a -> (f :*: g) j k1 b -> (f :*: g) i k1 a Source # | |
| (Monad f, Monad g) => Monad (f :*: g :: k -> k -> Type -> Type) Source # | |
| (Shifty f, Shifty g) => Shifty (f :*: g) Source # | |
| (Stacked f, Stacked g) => Stacked (f :*: g) Source # | |
| (Alternative (f i j), Alternative (g i j)) => Alternative ((f :*: g) i j) Source # | |
| (Applicative (f i j), Applicative (g i j)) => Applicative ((f :*: g) i j) Source # | |
Defined in Control.Monad.Indexed Methods pure :: a -> (f :*: g) i j a # (<*>) :: (f :*: g) i j (a -> b) -> (f :*: g) i j a -> (f :*: g) i j b # liftA2 :: (a -> b -> c) -> (f :*: g) i j a -> (f :*: g) i j b -> (f :*: g) i j c # (*>) :: (f :*: g) i j a -> (f :*: g) i j b -> (f :*: g) i j b # (<*) :: (f :*: g) i j a -> (f :*: g) i j b -> (f :*: g) i j a # | |
| (Functor (f i j), Functor (g i j)) => Functor ((f :*: g) i j) Source # | |
| (Monad (f i j), Monad (g i j)) => Monad ((f :*: g) i j) Source # | |
| (MonadPlus (f i j), MonadPlus (g i j)) => MonadPlus ((f :*: g) i j) Source # | |
| (Additive (f r r' a), Additive (g r r' a)) => Additive ((f :*: g) r r' a) Source # | |
fst_star :: forall {k1} {k2} {k3} f (g :: k1 -> k2 -> k3 -> Type) (i :: k1) (j :: k2) (a :: k3). (f :*: g) i j a -> f i j a Source #
snd_star :: forall {k1} {k2} {k3} (f :: k1 -> k2 -> k3 -> Type) g (i :: k1) (j :: k2) (a :: k3). (f :*: g) i j a -> g i j a Source #
Lift non-indexed gadgets to indexed
newtype IgnoreIndices (m :: k -> Type) (i :: k1) (j :: k2) (a :: k) Source #
Constructors
| IgnoreIndices | |
Fields
| |
Instances
Additional technical definitions
(>>) :: forall {k1} m (i :: k1) (j :: k1) (k2 :: k1) a. Applicative m => m i j () -> m j k2 a -> m i k2 a Source #
Synonym of *> used for QualifiedDo notation.