Skip to content

Commit b480c83

Browse files
committed
defined mcompose
1 parent c986741 commit b480c83

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

theories/Structures/Monad.v

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff 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+
5564
End monadic.
5665

5766
Module MonadNotation.
@@ -60,9 +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.
63-
64-
(* Left-to-right composition of Kleisli arrows. *)
65-
Notation "f >=> g" := (fun x => @pbind _ _ _ _ _ (f x) g) (at level 50, left associativity) : monad_scope.
72+
Notation "f >=> g" := (@mcompose _ _ _ _ _ f g) (at level 50, left associativity) : monad_scope.
6673

6774
Notation "x <- c1 ;; c2" := (@pbind _ _ _ _ _ c1 (fun x => c2))
6875
(at level 100, c1 at next level, right associativity) : monad_scope.

0 commit comments

Comments
 (0)