diff src/mono_shake.sml @ 164:6847741e1f5f

Datatypes through monoize
author Adam Chlipala <adamc@hcoop.net>
date Tue, 29 Jul 2008 13:32:07 -0400
parents f0d3402184d1
children 25b169416ea8
line wrap: on
line diff
--- a/src/mono_shake.sml	Tue Jul 29 13:16:21 2008 -0400
+++ b/src/mono_shake.sml	Tue Jul 29 13:32:07 2008 -0400
@@ -47,13 +47,22 @@
                           (fn ((DExport (_, _, n, _), _), page_es) => n :: page_es
                             | (_, page_es) => page_es) [] file
 
-        val (cdef, edef) = foldl (fn ((DVal (_, n, t, e, _), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e)))
+        val (cdef, edef) = foldl (fn ((DDatatype _, _), acc) => acc
+                                   | ((DVal (_, n, t, e, _), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e)))
                                    | ((DValRec vis, _), (cdef, edef)) =>
                                      (cdef, foldl (fn ((_, n, t, e, _), edef) => IM.insert (edef, n, (t, e))) edef vis)
                                    | ((DExport _, _), acc) => acc)
                                  (IM.empty, IM.empty) file
 
-        fun typ (_, s) = s
+        fun typ (c, s) =
+            case c of
+                TNamed n =>
+                if IS.member (#con s, n) then
+                    s
+                else
+                    {exp = #exp s,
+                     con = IS.add (#con s, n)}
+              | _ => s
 
         fun exp (e, s) =
             case e of
@@ -80,7 +89,8 @@
                               NONE => raise Fail "Shake: Couldn't find 'val'"
                             | SOME (t, e) => shakeExp s e) s page_es
     in
-        List.filter (fn (DVal (_, n, _, _, _), _) => IS.member (#exp s, n)
+        List.filter (fn (DDatatype (_, n, _), _) => IS.member (#con s, n)
+                      | (DVal (_, n, _, _, _), _) => IS.member (#exp s, n)
                       | (DValRec vis, _) => List.exists (fn (_, n, _, _, _) => IS.member (#exp s, n)) vis
                       | (DExport _, _) => true) file
     end