comparison src/shake.sml @ 192:9bbf4d383381

Parametrized datatypes through corify
author Adam Chlipala <adamc@hcoop.net>
date Fri, 08 Aug 2008 10:59:06 -0400
parents 80192edca30d
children 5c50b17f5e4a
comparison
equal deleted inserted replaced
191:aa54250f58ac 192:9bbf4d383381
46 val page_es = List.foldl 46 val page_es = List.foldl
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 | ((DDatatype (_, n, xncs), _), (cdef, edef)) => 51 | ((DDatatype (_, n, _, xncs), _), (cdef, edef)) =>
52 (IM.insert (cdef, n, List.mapPartial #3 xncs), edef) 52 (IM.insert (cdef, n, List.mapPartial #3 xncs), edef)
53 | ((DVal (_, n, t, e, _), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e))) 53 | ((DVal (_, n, t, e, _), _), (cdef, edef)) => (cdef, IM.insert (edef, n, (t, e)))
54 | ((DValRec vis, _), (cdef, edef)) => 54 | ((DValRec vis, _), (cdef, edef)) =>
55 (cdef, foldl (fn ((_, n, t, e, _), edef) => IM.insert (edef, n, (t, e))) edef vis) 55 (cdef, foldl (fn ((_, n, t, e, _), edef) => IM.insert (edef, n, (t, e))) edef vis)
56 | ((DExport _, _), acc) => acc) 56 | ((DExport _, _), acc) => acc)
100 case IM.find (edef, n) of 100 case IM.find (edef, n) of
101 NONE => raise Fail "Shake: Couldn't find 'val'" 101 NONE => raise Fail "Shake: Couldn't find 'val'"
102 | SOME (t, e) => shakeExp (shakeCon s t) e) s page_es 102 | SOME (t, e) => shakeExp (shakeCon s t) e) s page_es
103 in 103 in
104 List.filter (fn (DCon (_, n, _, _), _) => IS.member (#con s, n) 104 List.filter (fn (DCon (_, n, _, _), _) => IS.member (#con s, n)
105 | (DDatatype (_, n, _), _) => IS.member (#con s, n) 105 | (DDatatype (_, n, _, _), _) => IS.member (#con s, n)
106 | (DVal (_, n, _, _, _), _) => IS.member (#exp s, n) 106 | (DVal (_, n, _, _, _), _) => IS.member (#exp s, n)
107 | (DValRec vis, _) => List.exists (fn (_, n, _, _, _) => IS.member (#exp s, n)) vis 107 | (DValRec vis, _) => List.exists (fn (_, n, _, _, _) => IS.member (#exp s, n)) vis
108 | (DExport _, _) => true) file 108 | (DExport _, _) => true) file
109 end 109 end
110 110