File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,15 @@ Section monadic.
5252 {M : Monad m}
5353 {A B : Type @{d}} (fM:m (A -> B)) (aM:m A) : m B :=
5454 bind fM (fun f => liftM f aM).
55+
56+ (* Left-to-right composition of Kleisli arrows. *)
57+ Definition mcompose@{c d}
58+ {m:Type @{d}->Type @{c}}
59+ {M: Monad m}
60+ {T U V:Type @{d}}
61+ (f: T -> m U) (g: U -> m V): (T -> m V) :=
62+ fun x => bind (f x) g.
63+
5564End monadic.
5665
5766Module MonadNotation.
@@ -60,6 +69,7 @@ Module MonadNotation.
6069
6170 Notation "c >>= f" := (@pbind _ _ _ _ _ c f) (at level 50, left associativity) : monad_scope.
6271 Notation "f =<< c" := (@pbind _ _ _ _ _ c f) (at level 51, right associativity) : monad_scope.
72+ Notation "f >=> g" := (@mcompose _ _ _ _ _ f g) (at level 50, left associativity) : monad_scope.
6373
6474 Notation "x <- c1 ;; c2" := (@pbind _ _ _ _ _ c1 (fun x => c2))
6575 (at level 100, c1 at next level, right associativity) : monad_scope.
You can’t perform that action at this time.
0 commit comments