Use newtype pattern in Env
This commit is contained in:
parent
019e3d7bd1
commit
1784f83887
1 changed files with 7 additions and 7 deletions
14
eval.ml
14
eval.ml
|
@ -15,7 +15,7 @@ type value =
|
|||
and expr = Ast.t
|
||||
|
||||
(* environment for eval *)
|
||||
and env = (string * value) list
|
||||
and env = Env of (string * value) list
|
||||
|
||||
exception No_operation
|
||||
exception Too_many_arguments
|
||||
|
@ -79,16 +79,16 @@ end
|
|||
module Env = struct
|
||||
type t = env
|
||||
|
||||
let empty = []
|
||||
let empty = Env []
|
||||
|
||||
let get_opt e name =
|
||||
let get_opt (Env e) name =
|
||||
List.assoc_opt name e
|
||||
|
||||
let bind v e =
|
||||
v::e
|
||||
let bind v (Env e) =
|
||||
Env (v::e)
|
||||
|
||||
let bind_seq seq e =
|
||||
List.of_seq seq @ e
|
||||
let bind_seq seq (Env e) =
|
||||
Env (List.of_seq seq @ e)
|
||||
end
|
||||
|
||||
(* operators *)
|
||||
|
|
Loading…
Add table
Reference in a new issue