diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-08-03 09:26:49 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-08-03 09:26:49 -0400 |
commit | 5e0563d3b00303d5053827e46811c93077455208 (patch) | |
tree | 84de1a0972562b31942273587987b2a27f615d8b /src/mono_shake.sml | |
parent | 49c123050b2bc8a24f250fcc0d55e49484bc604c (diff) |
First part of getting cases through monoize
Diffstat (limited to 'src/mono_shake.sml')
-rw-r--r-- | src/mono_shake.sml | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/mono_shake.sml b/src/mono_shake.sml index 55054f15..e694c0dd 100644 --- a/src/mono_shake.sml +++ b/src/mono_shake.sml @@ -47,8 +47,10 @@ fun shake file = (fn ((DExport (_, _, n, _), _), page_es) => n :: page_es | (_, page_es) => page_es) [] file - val (cdef, edef) = foldl (fn ((DDatatype _, _), acc) => acc - | ((DVal (_, n, t, e, _), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e))) + val (cdef, edef) = foldl (fn ((DDatatype (_, n, xncs), _), (cdef, edef)) => + (IM.insert (cdef, n, xncs), edef) + | ((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) @@ -60,10 +62,22 @@ fun shake file = if IS.member (#con s, n) then s else - {exp = #exp s, - con = IS.add (#con s, n)} + let + val s' = {exp = #exp s, + con = IS.add (#con s, n)} + in + case IM.find (cdef, n) of + NONE => s' + | SOME xncs => foldl (fn ((_, _, to), s) => + case to of + NONE => s + | SOME t => shakeTyp s t) + s' xncs + end | _ => s + and shakeTyp s = U.Typ.fold typ s + fun exp (e, s) = case e of ENamed n => |