comparison src/expl_rename.sml @ 1990:7bd2ecf96bb0

Fixed issue with datatype constructors inside functors; now on to some problem with modules inside functors
author Adam Chlipala <adam@chlipala.net>
date Thu, 20 Feb 2014 10:48:17 -0500
parents 210fb3dfc483
children 7db8356caef5
comparison
equal deleted inserted replaced
1989:210fb3dfc483 1990:7bd2ecf96bb0
250 (DCon (x, n', k, (CNamed n, loc)), loc)], 250 (DCon (x, n', k, (CNamed n, loc)), loc)],
251 st) 251 st)
252 end 252 end
253 | DDatatype dts => 253 | DDatatype dts =>
254 let 254 let
255 val d = (DDatatype (map (fn (x, n, xs, cns) =>
256 (x, n, xs,
257 map (fn (x, n, co) =>
258 (x, n, Option.map (renameCon st) co)) cns)) dts),
259 loc)
260
255 val (dts', st) = ListUtil.foldlMap (fn ((x, n, xs, cns), st) => 261 val (dts', st) = ListUtil.foldlMap (fn ((x, n, xs, cns), st) =>
256 let 262 let
257 val (st, n') = St.bind (st, n) 263 val (st, n') = St.bind (st, n)
258 264
259 val (cns', st) = ListUtil.foldlMap 265 val (cns', st) = ListUtil.foldlMap
266 end) st cns 272 end) st cns
267 in 273 in
268 ((x, n, length xs, n', cns'), st) 274 ((x, n, length xs, n', cns'), st)
269 end) st dts 275 end) st dts
270 276
271 val d = (DDatatype (map (fn (x, n, xs, cns) =>
272 (x, n, xs,
273 map (fn (x, n, co) =>
274 (x, n, Option.map (renameCon st) co)) cns)) dts),
275 loc)
276
277 val env = E.declBinds E.empty d 277 val env = E.declBinds E.empty d
278 in 278 in
279 (d 279 (d
280 :: map (fn (x, n, arity, n', _) => 280 :: map (fn (x, n, arity, n', _) =>
281 (DCon (x, n', fromArity (arity, loc), (CNamed n, loc)), loc)) dts' 281 (DCon (x, n', fromArity (arity, loc), (CNamed n, loc)), loc)) dts'
285 loc)) cns') dts', 285 loc)) cns') dts',
286 st) 286 st)
287 end 287 end
288 | DDatatypeImp (x, n, n', xs, x', xs', cns) => 288 | DDatatypeImp (x, n, n', xs, x', xs', cns) =>
289 let 289 let
290 val d = (DDatatypeImp (x, n, n', xs, x', xs',
291 map (fn (x, n, co) =>
292 (x, n, Option.map (renameCon st) co)) cns), loc)
293
290 val (cns', st) = ListUtil.foldlMap 294 val (cns', st) = ListUtil.foldlMap
291 (fn ((x, n, _), st) => 295 (fn ((x, n, _), st) =>
292 let 296 let
293 val (st, n') = 297 val (st, n') =
294 St.bind (st, n) 298 St.bind (st, n)
296 ((x, n, n'), st) 300 ((x, n, n'), st)
297 end) st cns 301 end) st cns
298 302
299 val (st, n') = St.bind (st, n) 303 val (st, n') = St.bind (st, n)
300 304
301 val d = (DDatatypeImp (x, n, n', xs, x', xs',
302 map (fn (x, n, co) =>
303 (x, n, Option.map (renameCon st) co)) cns), loc)
304
305 val env = E.declBinds E.empty d 305 val env = E.declBinds E.empty d
306 in 306 in
307 (d 307 (d
308 :: (DCon (x, n', fromArity (length xs, loc), (CNamed n, loc)), loc) 308 :: (DCon (x, n', fromArity (length xs, loc), (CNamed n, loc)), loc)
309 :: map (fn (x, n, n') => 309 :: map (fn (x, n, n') =>