diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-07-29 15:43:17 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-07-29 15:43:17 -0400 |
commit | 846cf3f1661a8c91e40d80382db28c76dceaf1f0 (patch) | |
tree | fe42c0c78660d50832719e1ae9fd9cda2d7e603f /src/mono_env.sml | |
parent | cb3b3831a07d6674a5fa02e3e8a1e4329b58cb34 (diff) |
Storing datatype constructors in type references past monoize
Diffstat (limited to 'src/mono_env.sml')
-rw-r--r-- | src/mono_env.sml | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/mono_env.sml b/src/mono_env.sml index 00f31c16..3a6a20ba 100644 --- a/src/mono_env.sml +++ b/src/mono_env.sml @@ -36,32 +36,32 @@ exception UnboundRel of int exception UnboundNamed of int type env = { - namedT : (string * typ option) IM.map, + datatypes : (string * (string * int * typ option) list) IM.map, relE : (string * typ) list, namedE : (string * typ * exp option * string) IM.map } val empty = { - namedT = IM.empty, + datatypes = IM.empty, relE = [], namedE = IM.empty } -fun pushTNamed (env : env) x n co = - {namedT = IM.insert (#namedT env, n, (x, co)), +fun pushDatatype (env : env) x n xncs = + {datatypes = IM.insert (#datatypes env, n, (x, xncs)), relE = #relE env, namedE = #namedE env} -fun lookupTNamed (env : env) n = - case IM.find (#namedT env, n) of +fun lookupDatatype (env : env) n = + case IM.find (#datatypes env, n) of NONE => raise UnboundNamed n | SOME x => x fun pushERel (env : env) x t = - {namedT = #namedT env, + {datatypes = #datatypes env, relE = (x, t) :: #relE env, namedE = #namedE env} @@ -71,7 +71,7 @@ fun lookupERel (env : env) n = handle Subscript => raise UnboundRel n fun pushENamed (env : env) x n t eo s = - {namedT = #namedT env, + {datatypes = #datatypes env, relE = #relE env, namedE = IM.insert (#namedE env, n, (x, t, eo, s))} @@ -85,10 +85,10 @@ fun declBinds env (d, loc) = case d of DDatatype (x, n, xncs) => let - val env = pushTNamed env x n NONE + val env = pushDatatype env x n xncs in - foldl (fn ((x', n', NONE), env) => pushENamed env x' n' (TNamed n, loc) NONE "" - | ((x', n', SOME t), env) => pushENamed env x' n' (TFun (t, (TNamed n, loc)), loc) NONE "") + foldl (fn ((x', n', NONE), env) => pushENamed env x' n' (TDatatype (n, xncs), loc) NONE "" + | ((x', n', SOME t), env) => pushENamed env x' n' (TFun (t, (TDatatype (n, xncs), loc)), loc) NONE "") env xncs end | DVal (x, n, t, e, s) => pushENamed env x n t (SOME e) s |