From 7c37a6336fb1a56fee80e94f9e5188c3436102cd Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Wed, 25 Jul 2012 14:04:59 -0400 Subject: Allow type class instances with hypotheses via local ('let') definitions --- src/elab_util.sml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/elab_util.sml') diff --git a/src/elab_util.sml b/src/elab_util.sml index b799bbc4..97e3b572 100644 --- a/src/elab_util.sml +++ b/src/elab_util.sml @@ -568,6 +568,26 @@ fun mapfold {kind = fk, con = fc, exp = fe} = exp = fn () => fe, bind = fn ((), _) => ()} () +fun existsB {kind, con, exp, bind} ctx e = + case mapfoldB {kind = fn ctx => fn k => fn () => + if kind (ctx, k) then + S.Return () + else + S.Continue (k, ()), + con = fn ctx => fn c => fn () => + if con (ctx, c) then + S.Return () + else + S.Continue (c, ()), + exp = fn ctx => fn e => fn () => + if exp (ctx, e) then + S.Return () + else + S.Continue (e, ()), + bind = bind} ctx e () of + S.Return _ => true + | S.Continue _ => false + fun exists {kind, con, exp} k = case mapfold {kind = fn k => fn () => if kind k then -- cgit v1.2.3