diff src/mono_env.sml @ 164:6847741e1f5f

Datatypes through monoize
author Adam Chlipala <adamc@hcoop.net>
date Tue, 29 Jul 2008 13:32:07 -0400
parents 76a4d69719d8
children 25b169416ea8
line wrap: on
line diff
--- a/src/mono_env.sml	Tue Jul 29 13:16:21 2008 -0400
+++ b/src/mono_env.sml	Tue Jul 29 13:32:07 2008 -0400
@@ -81,9 +81,17 @@
         NONE => raise UnboundNamed n
       | SOME x => x
 
-fun declBinds env (d, _) =
+fun declBinds env (d, loc) =
     case d of
-        DVal (x, n, t, e, s) => pushENamed env x n t (SOME e) s
+        DDatatype (x, n, xncs) =>
+        let
+            val env = pushTNamed env x n NONE
+        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 "")
+            env xncs
+        end
+      | DVal (x, n, t, e, s) => pushENamed env x n t (SOME e) s
       | DValRec vis => foldl (fn ((x, n, t, e, s), env) => pushENamed env x n t NONE s) env vis
       | DExport _ => env