comparison src/corify.sml @ 45:3c1ce1b4eb3d

Explifying functors
author Adam Chlipala <adamc@hcoop.net>
date Thu, 19 Jun 2008 17:11:24 -0400
parents 02f42e9a1825
children 44a1bc863f0f
comparison
equal deleted inserted replaced
44:a9f3ce2d1b9b 45:3c1ce1b4eb3d
255 let 255 let
256 val (ds, {inner, outer}) = corifyStr (str, st) 256 val (ds, {inner, outer}) = corifyStr (str, st)
257 in 257 in
258 (ds, {inner = St.lookupStrByName (x, inner), outer = outer}) 258 (ds, {inner = St.lookupStrByName (x, inner), outer = outer})
259 end 259 end
260 | L.StrFun _ => raise Fail "Corify functor"
261 | L.StrApp _ => raise Fail "Corify functor app"
260 262
261 fun maxName ds = foldl (fn ((d, _), n) => 263 fun maxName ds = foldl (fn ((d, _), n) =>
262 case d of 264 case d of
263 L.DCon (_, n', _, _) => Int.max (n, n') 265 L.DCon (_, n', _, _) => Int.max (n, n')
264 | L.DVal (_, n', _ , _) => Int.max (n, n') 266 | L.DVal (_, n', _ , _) => Int.max (n, n')
269 and maxNameStr (str, _) = 271 and maxNameStr (str, _) =
270 case str of 272 case str of
271 L.StrConst ds => maxName ds 273 L.StrConst ds => maxName ds
272 | L.StrVar n => n 274 | L.StrVar n => n
273 | L.StrProj (str, _) => maxNameStr str 275 | L.StrProj (str, _) => maxNameStr str
276 | L.StrFun (_, _, _, _, str) => maxNameStr str
277 | L.StrApp (str1, str2) => Int.max (maxNameStr str1, maxNameStr str2)
274 278
275 fun corify ds = 279 fun corify ds =
276 let 280 let
277 val () = reset (maxName ds + 1) 281 val () = reset (maxName ds + 1)
278 val (ds, _) = ListUtil.foldlMapConcat corifyDecl St.empty ds 282 val (ds, _) = ListUtil.foldlMapConcat corifyDecl St.empty ds