| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Promonad
Contents
Description
Promonads as effects: a Promonad (Proarrow.Core) that is Representable is an ordinary Monad
on objects (return, bind); a Promonad that is Corepresentable is a Comonad (extract,
extend). Also Procomonads and relative (co)monads (RelativeMonad, RelativeComonad). Concrete
promonads live in Proarrow.Promonad.*.
Synopsis
- class Profunctor p => Promonad (p :: CAT k) where
- class Profunctor p => Procomonad (p :: k +-> k) where
- proextract :: p :~> ((~>) :: CAT k)
- produplicate :: p :~> (p :.: p)
- type Monad (m :: CAT j) = (Promonad m, Representable m)
- return :: forall {j} (m :: CAT j) (a :: j). (Monad m, Ob a) => a ~> (m % a)
- bind :: forall {j} (m :: CAT j) (b :: j) (a :: j). (Monad m, Ob b) => (a ~> (m % b)) -> (m % a) ~> (m % b)
- type Comonad (w :: CAT j) = (Promonad w, Corepresentable w)
- extract :: forall {k} (w :: CAT k) (a :: k). (Comonad w, Ob a) => (w %% a) ~> a
- extend :: forall {j} (w :: CAT j) (a :: j) (b :: j). (Comonad w, Ob a) => ((w %% a) ~> b) -> (w %% a) ~> (w %% b)
- newtype AsRelative (m :: k +-> i) (a :: i) (b :: k) = AsRelative {
- unAsRelative :: m a b
- class (Representable m, Profunctor j) => RelativeMonad (j :: i +-> k) (m :: k +-> i) where
- type RelAlgebra (j1 :: j -> k -> Type) (m :: j +-> k) (a :: j) (b :: k) = j1 a b -> (m % a) ~> b
- class (Corepresentable w, Profunctor j) => RelativeComonad (j :: i +-> k) (w :: k +-> i) where
- type RelCoalgebra (j :: k -> k1 -> Type) (w :: k +-> k1) (a :: k) (b :: k1) = j a b -> a ~> (w %% b)
Documentation
class Profunctor p => Promonad (p :: CAT k) where Source Github #
A promonad is a category-like profunctor with identity morphisms and composition.
This is also known as a category structure, or an identity-on-objects functor.
Laws:
Minimal complete definition
Methods
id :: forall (a :: k). Ob a => p a a Source Github #
Identity morphisms.
Defaults to objId for a category's own hom-profunctor, so a category that leaves Ob at
its ObId default gets id for free.
(.) :: forall (b :: k) (c :: k) (a :: k). p b c -> p a b -> p a c infixr 9 Source Github #
Composition (note the parameter order matches function composition).
Instances
class Profunctor p => Procomonad (p :: k +-> k) where Source Github #
Instances
| CategoryOf k => Procomonad (Fold :: k -> k -> Type) Source Github # | |
| CategoryOf k => Procomonad (Id :: k -> k -> Type) Source Github # | |
| (Monoid r, Monoidal k) => Procomonad (Reader ('OP r) :: k -> k -> Type) Source Github # | |
| (Comonoid w, Monoidal k) => Procomonad (Writer w :: k -> k -> Type) Source Github # | |
| Monad m => Procomonad (Costar (Prelude m) :: Type -> Type -> Type) Source Github # | |
| (Procomonad p, Procomonad q, Monoidal k) => Procomonad (Day p q :: k -> k -> Type) Source Github # | |
| Proadjunction p q => Procomonad (p :.: q :: k -> k -> Type) Source Github # | |
return :: forall {j} (m :: CAT j) (a :: j). (Monad m, Ob a) => a ~> (m % a) Source Github #
The unit of the monad m.
bind :: forall {j} (m :: CAT j) (b :: j) (a :: j). (Monad m, Ob b) => (a ~> (m % b)) -> (m % a) ~> (m % b) Source Github #
Kleisli extension: run a Kleisli arrow under m.
extract :: forall {k} (w :: CAT k) (a :: k). (Comonad w, Ob a) => (w %% a) ~> a Source Github #
The counit of the comonad w.
extend :: forall {j} (w :: CAT j) (a :: j) (b :: j). (Comonad w, Ob a) => ((w %% a) ~> b) -> (w %% a) ~> (w %% b) Source Github #
CoKleisli extension: run a coKleisli arrow under w.
newtype AsRelative (m :: k +-> i) (a :: i) (b :: k) Source Github #
A Monad or Comonad seen as a relative (co)monad along Id.
The wrapper is needed: a direct instance would unify at RelativeMonad Id mj = with
carrier-specific ones such as the codensity monad's, with neither more specific, so no overlap
pragma could order them.Id
Constructors
| AsRelative | |
Fields
| |
Instances
| Comonad w => RelativeComonad (Id :: i -> i -> Type) (AsRelative w :: i -> i -> Type) Source Github # | |
Defined in Proarrow.Promonad Methods relExtract :: forall (a :: i). Ob a => Id (AsRelative w %% a) a Source Github # relExtend :: forall (a :: i) (b :: i). Ob a => Id (AsRelative w %% a) b -> (AsRelative w %% a) ~> (AsRelative w %% b) Source Github # | |
| Monad m => RelativeMonad (Id :: i -> i -> Type) (AsRelative m :: i -> i -> Type) Source Github # | |
Defined in Proarrow.Promonad | |
| Profunctor m => Profunctor (AsRelative m :: k -> j -> Type) Source Github # | |
Defined in Proarrow.Promonad Methods dimap :: forall (c :: k) (a :: k) (b :: j) (d :: j). (c ~> a) -> (b ~> d) -> AsRelative m a b -> AsRelative m c d Source Github # lmap :: forall (c :: k) (a :: k) (b :: j). (c ~> a) -> AsRelative m a b -> AsRelative m c b Source Github # rmap :: forall (b :: j) (d :: j) (a :: k). (b ~> d) -> AsRelative m a b -> AsRelative m a d Source Github # (\\) :: forall (a :: k) (b :: j) r. ((Ob a, Ob b) => r) -> AsRelative m a b -> r Source Github # | |
| Corepresentable m => Corepresentable (AsRelative m :: k -> j -> Type) Source Github # | |
Defined in Proarrow.Promonad Methods coindex :: forall (a :: k) (b :: j). AsRelative m a b -> (AsRelative m %% a) ~> b Source Github # cotabulate :: forall (a :: k) (b :: j). Ob a => ((AsRelative m %% a) ~> b) -> AsRelative m a b Source Github # corepMap :: forall (a :: k) (b :: k). (a ~> b) -> (AsRelative m %% a) ~> (AsRelative m %% b) Source Github # corepUniv :: forall (a :: k). Ob a => AsRelative m a (AsRelative m %% a) Source Github # | |
| Representable m => Representable (AsRelative m :: k -> j -> Type) Source Github # | |
Defined in Proarrow.Promonad Methods index :: forall (a :: k) (b :: j). AsRelative m a b -> a ~> (AsRelative m % b) Source Github # tabulate :: forall (b :: j) (a :: k). Ob b => (a ~> (AsRelative m % b)) -> AsRelative m a b Source Github # repMap :: forall (a :: j) (b :: j). (a ~> b) -> (AsRelative m % a) ~> (AsRelative m % b) Source Github # repUniv :: forall (a :: j). Ob a => AsRelative m (AsRelative m % a) a Source Github # | |
| Promonad m => Promonad (AsRelative m :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Promonad Methods id :: forall (a :: k). Ob a => AsRelative m a a Source Github # (.) :: forall (b :: k) (c :: k) (a :: k). AsRelative m b c -> AsRelative m a b -> AsRelative m a c Source Github # | |
| type (AsRelative m :: k -> j -> Type) %% (a :: k) Source Github # | |
Defined in Proarrow.Promonad | |
| type (AsRelative m :: k -> j -> Type) % (a :: j) Source Github # | |
Defined in Proarrow.Promonad | |
class (Representable m, Profunctor j) => RelativeMonad (j :: i +-> k) (m :: k +-> i) where Source Github #
Methods
relReturn :: forall (a :: k). Ob a => j a (m % a) Source Github #
relBind :: forall (b :: k) (a :: k). Ob b => j a (m % b) -> (m % a) ~> (m % b) Source Github #
Instances
| (Corepresentable g, Corepresentable f, Profunctor j, f ~ (g |> j)) => RelativeMonad (j :: k1 +-> i) (CorepStar g :.: CorepStar f :: k1 -> i -> Type) Source Github # | |
Defined in Proarrow.Profunctor.Instance.Ran | |
| Monad m => RelativeMonad (Id :: i -> i -> Type) (AsRelative m :: i -> i -> Type) Source Github # | |
Defined in Proarrow.Promonad | |
type RelAlgebra (j1 :: j -> k -> Type) (m :: j +-> k) (a :: j) (b :: k) = j1 a b -> (m % a) ~> b Source Github #
class (Corepresentable w, Profunctor j) => RelativeComonad (j :: i +-> k) (w :: k +-> i) where Source Github #
Methods
relExtract :: forall (a :: i). Ob a => j (w %% a) a Source Github #
relExtend :: forall (a :: i) (b :: i). Ob a => j (w %% a) b -> (w %% a) ~> (w %% b) Source Github #
Instances
| (Representable g, Representable f, Profunctor j, f ~ (j <| g)) => RelativeComonad (j :: k2 +-> i) (RepCostar f :.: RepCostar g :: k2 -> i -> Type) Source Github # | |
Defined in Proarrow.Profunctor.Instance.Rift | |
| Comonad w => RelativeComonad (Id :: i -> i -> Type) (AsRelative w :: i -> i -> Type) Source Github # | |
Defined in Proarrow.Promonad Methods relExtract :: forall (a :: i). Ob a => Id (AsRelative w %% a) a Source Github # relExtend :: forall (a :: i) (b :: i). Ob a => Id (AsRelative w %% a) b -> (AsRelative w %% a) ~> (AsRelative w %% b) Source Github # | |
type RelCoalgebra (j :: k -> k1 -> Type) (w :: k +-> k1) (a :: k) (b :: k1) = j a b -> a ~> (w %% b) Source Github #