comparison src/shake.sml @ 39:02f42e9a1825

Corify removes modules
author Adam Chlipala <adamc@hcoop.net>
date Thu, 19 Jun 2008 12:39:22 -0400
parents bfa2e9ae4df8
children f0f59e918cac
comparison
equal deleted inserted replaced
38:d16ef24de78b 39:02f42e9a1825
40 con : IS.set, 40 con : IS.set,
41 exp : IS.set 41 exp : IS.set
42 } 42 }
43 43
44 fun shake file = 44 fun shake file =
45 case List.foldl (fn ((DVal ("main", n, _, e), _), _) => SOME (n, e) 45 case List.foldl (fn ((DVal ("main", n, t, e), _), _) => SOME (n, t, e)
46 | (_, s) => s) NONE file of 46 | (_, s) => s) NONE file of
47 NONE => [] 47 NONE => []
48 | SOME (main, body) => 48 | SOME (main, mainT, body) =>
49 let 49 let
50 val (cdef, edef) = foldl (fn ((DCon (_, n, _, c), _), (cdef, edef)) => (IM.insert (cdef, n, c), edef) 50 val (cdef, edef) = foldl (fn ((DCon (_, n, _, c), _), (cdef, edef)) => (IM.insert (cdef, n, c), edef)
51 | ((DVal (_, n, t, e), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e)))) 51 | ((DVal (_, n, t, e), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e))))
52 (IM.empty, IM.empty) file 52 (IM.empty, IM.empty) file
53 53
90 and shakeExp s = U.Exp.fold {kind = kind, con = con, exp = exp} s 90 and shakeExp s = U.Exp.fold {kind = kind, con = con, exp = exp} s
91 91
92 val s = {con = IS.empty, 92 val s = {con = IS.empty,
93 exp = IS.singleton main} 93 exp = IS.singleton main}
94 94
95 val s = U.Con.fold {kind = kind, con = con} s mainT
95 val s = U.Exp.fold {kind = kind, con = con, exp = exp} s body 96 val s = U.Exp.fold {kind = kind, con = con, exp = exp} s body
96 in 97 in
97 List.filter (fn (DCon (_, n, _, _), _) => IS.member (#con s, n) 98 List.filter (fn (DCon (_, n, _, _), _) => IS.member (#con s, n)
98 | (DVal (_, n, _, _), _) => IS.member (#exp s, n)) file 99 | (DVal (_, n, _, _), _) => IS.member (#exp s, n)) file
99 end 100 end