1
+ Require Import Coq.Strings.String.
1
2
(** Require the monad definitions * *)
2
3
Require Import ExtLib.Structures.Monads.
3
4
(** Use the instances for exceptions * *)
4
5
Require Import ExtLib.Data.Monads.EitherMonad.
5
6
(** Strings will be used for error messages * *)
6
- Require Import String.
7
+ Require Import ExtLib.Data. String.
7
8
8
9
Set Implicit Arguments .
9
10
Set Strict Implicit .
@@ -27,16 +28,16 @@ Section monadic.
27
28
Variable m : Type -> Type.
28
29
Context {Monad_m : Monad m}.
29
30
Context {MonadExc_m : MonadExc string m}.
30
-
31
+
31
32
(** Use the notation for monads * *)
32
33
Import MonadNotation.
33
34
Local Open Scope monad_scope.
34
-
35
+
35
36
(** Functions that get [nat] or [bool] values from a [value] * *)
36
37
Definition asInt (v : value) : m nat :=
37
38
match v with
38
- | Int n => ret n
39
- | _ =>
39
+ | Int n => ret n
40
+ | _ =>
40
41
(** if we don't have an integer, signal an error using
41
42
** [raise] from the MoandExc instance
42
43
* *)
@@ -54,7 +55,7 @@ Section monadic.
54
55
* *)
55
56
Fixpoint eval' (e : exp) : m value :=
56
57
match e with
57
- (** when there is no error, we can just return (i.e. [ret])
58
+ (** when there is no error, we can just return (i.e. [ret])
58
59
** the answer
59
60
* *)
60
61
| ConstI i => ret (Int i)
@@ -72,7 +73,7 @@ Section monadic.
72
73
t <- eval' t ;;
73
74
t <- asBool t ;;
74
75
(** case split and perform the appropriate recursion * *)
75
- if t then
76
+ if (t : bool) then
76
77
eval' tr
77
78
else
78
79
eval' fa
@@ -83,7 +84,7 @@ End monadic.
83
84
(** Wrap the [eval] function up with the monad instance that we
84
85
** want to use
85
86
* *)
86
- Definition eval : exp -> string + value :=
87
+ Definition eval : exp -> string + value :=
87
88
eval' (m := sum string).
88
89
89
90
(** Some tests * *)
0 commit comments