From b4f1361d2dff2e180e4656efa491b275707cdf02 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 16 Aug 2008 14:32:18 -0400 Subject: Initial type class support --- src/elab_util.sml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/elab_util.sml') diff --git a/src/elab_util.sml b/src/elab_util.sml index b0bca7bf..c3ed2d19 100644 --- a/src/elab_util.sml +++ b/src/elab_util.sml @@ -376,6 +376,14 @@ fun exists {kind, con, exp} k = S.Return _ => true | S.Continue _ => false +fun mapB {kind, con, exp, bind} ctx e = + case mapfoldB {kind = fn k => fn () => S.Continue (kind k, ()), + con = fn ctx => fn c => fn () => S.Continue (con ctx c, ()), + exp = fn ctx => fn e => fn () => S.Continue (exp ctx e, ()), + bind = bind} ctx e () of + S.Continue (e, ()) => e + | S.Return _ => raise Fail "ElabUtil.Exp.mapB: Impossible" + end structure Sgn = struct @@ -455,6 +463,11 @@ fun mapfoldB {kind, con, sgn_item, sgn, bind} = S.map2 (con ctx c, fn c' => (SgiTable (tn, x, n, c'), loc)) + | SgiClassAbs _ => S.return2 siAll + | SgiClass (x, n, c) => + S.map2 (con ctx c, + fn c' => + (SgiClass (x, n, c'), loc)) and sg ctx s acc = S.bindP (sg' ctx s acc, sgn ctx) @@ -478,7 +491,11 @@ fun mapfoldB {kind, con, sgn_item, sgn, bind} = | SgiSgn (x, _, sgn) => bind (ctx, Sgn (x, sgn)) | SgiConstraint _ => ctx - | SgiTable _ => ctx, + | SgiTable _ => ctx + | SgiClassAbs (x, _) => + bind (ctx, NamedC (x, (KArrow ((KType, loc), (KType, loc)), loc))) + | SgiClass (x, _, _) => + bind (ctx, NamedC (x, (KArrow ((KType, loc), (KType, loc)), loc))), sgi ctx si)) ctx sgis, fn sgis' => (SgnConst sgis', loc)) -- cgit v1.2.3