comparison src/shake.sml @ 125:fd98dd10dce7

Corifying (non-mutual) 'val rec'
author Adam Chlipala <adamc@hcoop.net>
date Thu, 17 Jul 2008 10:23:04 -0400
parents 813e5a52063d
children f0d3402184d1
comparison
equal deleted inserted replaced
124:541282b81454 125:fd98dd10dce7
47 (fn ((DExport n, _), page_es) => n :: page_es 47 (fn ((DExport n, _), page_es) => n :: page_es
48 | (_, page_es) => page_es) [] file 48 | (_, page_es) => page_es) [] file
49 49
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 | ((DValRec vis, _), (cdef, edef)) =>
53 (cdef, foldl (fn ((_, n, t, e, _), edef) => IM.insert (edef, n, (t, e))) edef vis)
52 | ((DExport _, _), acc) => acc) 54 | ((DExport _, _), acc) => acc)
53 (IM.empty, IM.empty) file 55 (IM.empty, IM.empty) file
54 56
55 fun kind (_, s) = s 57 fun kind (_, s) = s
56 58
97 NONE => raise Fail "Shake: Couldn't find 'val'" 99 NONE => raise Fail "Shake: Couldn't find 'val'"
98 | SOME (t, e) => shakeExp (shakeCon s t) e) s page_es 100 | SOME (t, e) => shakeExp (shakeCon s t) e) s page_es
99 in 101 in
100 List.filter (fn (DCon (_, n, _, _), _) => IS.member (#con s, n) 102 List.filter (fn (DCon (_, n, _, _), _) => IS.member (#con s, n)
101 | (DVal (_, n, _, _, _), _) => IS.member (#exp s, n) 103 | (DVal (_, n, _, _, _), _) => IS.member (#exp s, n)
104 | (DValRec vis, _) => List.exists (fn (_, n, _, _, _) => IS.member (#exp s, n)) vis
102 | (DExport _, _) => true) file 105 | (DExport _, _) => true) file
103 end 106 end
104 107
105 end 108 end