comparison src/core_util.sml @ 247:5c50b17f5e4a

Corify tables
author Adam Chlipala <adamc@hcoop.net>
date Sun, 31 Aug 2008 09:00:28 -0400
parents 766b5475477f
children 98f551ddd54b
comparison
equal deleted inserted replaced
246:3aa010e97db9 247:5c50b17f5e4a
619 S.map2 (ListUtil.mapfold (mfvi ctx) vis, 619 S.map2 (ListUtil.mapfold (mfvi ctx) vis,
620 fn vis' => 620 fn vis' =>
621 (DValRec vis', loc)) 621 (DValRec vis', loc))
622 end 622 end
623 | DExport _ => S.return2 dAll 623 | DExport _ => S.return2 dAll
624 | DTable (x, n, c, s) =>
625 S.map2 (mfc ctx c,
626 fn c' =>
627 (DTable (x, n, c', s), loc))
624 628
625 and mfvi ctx (x, n, t, e, s) = 629 and mfvi ctx (x, n, t, e, s) =
626 S.bind2 (mfc ctx t, 630 S.bind2 (mfc ctx t,
627 fn t' => 631 fn t' =>
628 S.map2 (mfe ctx e, 632 S.map2 (mfe ctx e,
701 | DVal (x, n, t, e, s) => bind (ctx, NamedE (x, n, t, SOME e, s)) 705 | DVal (x, n, t, e, s) => bind (ctx, NamedE (x, n, t, SOME e, s))
702 | DValRec vis => 706 | DValRec vis =>
703 foldl (fn ((x, n, t, e, s), ctx) => bind (ctx, NamedE (x, n, t, NONE, s))) 707 foldl (fn ((x, n, t, e, s), ctx) => bind (ctx, NamedE (x, n, t, NONE, s)))
704 ctx vis 708 ctx vis
705 | DExport _ => ctx 709 | DExport _ => ctx
710 | DTable (x, n, c, s) =>
711 let
712 val t = (CApp ((CFfi ("Basis", "table"), #2 d'), c), #2 d')
713 in
714 bind (ctx, NamedE (x, n, t, NONE, s))
715 end
706 in 716 in
707 S.map2 (mff ctx' ds', 717 S.map2 (mff ctx' ds',
708 fn ds' => 718 fn ds' =>
709 d' :: ds') 719 d' :: ds')
710 end) 720 end)
748 case d of 758 case d of
749 DCon (_, n, _, _) => Int.max (n, count) 759 DCon (_, n, _, _) => Int.max (n, count)
750 | DDatatype (_, n, _, _) => Int.max (n, count) 760 | DDatatype (_, n, _, _) => Int.max (n, count)
751 | DVal (_, n, _, _, _) => Int.max (n, count) 761 | DVal (_, n, _, _, _) => Int.max (n, count)
752 | DValRec vis => foldl (fn ((_, n, _, _, _), count) => Int.max (n, count)) count vis 762 | DValRec vis => foldl (fn ((_, n, _, _, _), count) => Int.max (n, count)) count vis
753 | DExport _ => count) 0 763 | DExport _ => count
764 | DTable (_, n, _, _) => Int.max (n, count)) 0
754 765
755 end 766 end
756 767
757 end 768 end