1+ Require Import Coq.Strings.String.
12(** Require the monad definitions * *)
23Require Import ExtLib.Structures.Monads.
34(** Use the instances for exceptions * *)
45Require Import ExtLib.Data.Monads.EitherMonad.
56(** Strings will be used for error messages * *)
6- Require Import String.
7+ Require Import ExtLib.Data. String.
78
89Set Implicit Arguments .
910Set Strict Implicit .
@@ -27,16 +28,16 @@ Section monadic.
2728 Variable m : Type -> Type.
2829 Context {Monad_m : Monad m}.
2930 Context {MonadExc_m : MonadExc string m}.
30-
31+
3132 (** Use the notation for monads * *)
3233 Import MonadNotation.
3334 Local Open Scope monad_scope.
34-
35+
3536 (** Functions that get [nat] or [bool] values from a [value] * *)
3637 Definition asInt (v : value) : m nat :=
3738 match v with
38- | Int n => ret n
39- | _ =>
39+ | Int n => ret n
40+ | _ =>
4041 (** if we don't have an integer, signal an error using
4142 ** [raise] from the MoandExc instance
4243 * *)
@@ -54,7 +55,7 @@ Section monadic.
5455 * *)
5556 Fixpoint eval' (e : exp) : m value :=
5657 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])
5859 ** the answer
5960 * *)
6061 | ConstI i => ret (Int i)
@@ -72,7 +73,7 @@ Section monadic.
7273 t <- eval' t ;;
7374 t <- asBool t ;;
7475 (** case split and perform the appropriate recursion * *)
75- if t then
76+ if (t : bool) then
7677 eval' tr
7778 else
7879 eval' fa
@@ -83,7 +84,7 @@ End monadic.
8384(** Wrap the [eval] function up with the monad instance that we
8485 ** want to use
8586 * *)
86- Definition eval : exp -> string + value :=
87+ Definition eval : exp -> string + value :=
8788 eval' (m := sum string).
8889
8990(** Some tests * *)
0 commit comments