comparison src/elab_util.sml @ 711:7292bcb7c02d

Made type class system very general; demo compiles
author Adam Chlipala <adamc@hcoop.net>
date Thu, 09 Apr 2009 12:31:56 -0400
parents d8217b4cb617
children f152f215a02c
comparison
equal deleted inserted replaced
710:71409a4ccb67 711:7292bcb7c02d
242 case mapfold {kind = fn k => fn () => S.Continue (kind k, ()), 242 case mapfold {kind = fn k => fn () => S.Continue (kind k, ()),
243 con = fn c => fn () => S.Continue (con c, ())} s () of 243 con = fn c => fn () => S.Continue (con c, ())} s () of
244 S.Return () => raise Fail "ElabUtil.Con.map: Impossible" 244 S.Return () => raise Fail "ElabUtil.Con.map: Impossible"
245 | S.Continue (s, ()) => s 245 | S.Continue (s, ()) => s
246 246
247 fun exists {kind, con} k = 247 fun existsB {kind, con, bind} ctx c =
248 case mapfoldB {kind = fn ctx => fn k => fn () =>
249 if kind (ctx, k) then
250 S.Return ()
251 else
252 S.Continue (k, ()),
253 con = fn ctx => fn c => fn () =>
254 if con (ctx, c) then
255 S.Return ()
256 else
257 S.Continue (c, ()),
258 bind = bind} ctx c () of
259 S.Return _ => true
260 | S.Continue _ => false
261
262 fun exists {kind, con} c =
248 case mapfold {kind = fn k => fn () => 263 case mapfold {kind = fn k => fn () =>
249 if kind k then 264 if kind k then
250 S.Return () 265 S.Return ()
251 else 266 else
252 S.Continue (k, ()), 267 S.Continue (k, ()),
253 con = fn c => fn () => 268 con = fn c => fn () =>
254 if con c then 269 if con c then
255 S.Return () 270 S.Return ()
256 else 271 else
257 S.Continue (c, ())} k () of 272 S.Continue (c, ())} c () of
258 S.Return _ => true 273 S.Return _ => true
259 | S.Continue _ => false 274 | S.Continue _ => false
260 275
261 fun foldB {kind, con, bind} ctx st c = 276 fun foldB {kind, con, bind} ctx st c =
262 case mapfoldB {kind = fn ctx => fn k => fn st => S.Continue (k, kind (ctx, k, st)), 277 case mapfoldB {kind = fn ctx => fn k => fn st => S.Continue (k, kind (ctx, k, st)),