-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inspired by the notation introduced by OCaml 4.08, we propose to introduce a new notation following the same principle. let* x := p in q is strictly equivalent to x <- p;; q
- Loading branch information
Showing
3 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Require Import ExtLib.Structures.Monad. | ||
Generalizable All Variables. | ||
|
||
Module NotationExample. | ||
|
||
Import MonadNotation. | ||
Open Scope monad_scope. | ||
|
||
Fixpoint repeatM `{Monad M} (n : nat) `(x : A) (p : A -> M A) : M unit := | ||
match n with | ||
| O => ret tt | ||
| S n => y <- p x;; | ||
repeatM n y p | ||
end. | ||
|
||
End NotationExample. | ||
|
||
Module LetNotationExample. | ||
|
||
Import MonadLetNotation. | ||
Open Scope monad_scope. | ||
|
||
Fixpoint repeatM `{Monad M} (n : nat) `(x : A) (p : A -> M A) : M unit := | ||
match n with | ||
| O => ret tt | ||
| S n => let* y := p x in | ||
repeatM n y p | ||
end. | ||
|
||
End LetNotationExample. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ MonadReasoning.v | |
Printing.v | ||
UsingSets.v | ||
WithDemo.v | ||
Nonations.v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters