389 text {* information about map-functions for type-constructor *} |
390 text {* information about map-functions for type-constructor *} |
390 ML {* |
391 ML {* |
391 type typ_info = {mapfun: string} |
392 type typ_info = {mapfun: string} |
392 |
393 |
393 local |
394 local |
394 structure Data = GenericDataFun |
395 structure Data = TheoryDataFun |
395 (type T = typ_info Symtab.table |
396 (type T = typ_info Symtab.table |
396 val empty = Symtab.empty |
397 val empty = Symtab.empty |
|
398 val copy = I |
397 val extend = I |
399 val extend = I |
398 fun merge _ = Symtab.merge (K true)) |
400 fun merge _ = Symtab.merge (K true)) |
399 in |
401 in |
400 val lookup = Symtab.lookup o Data.get |
402 val lookup = Symtab.lookup o Data.get |
401 fun update k v = Data.map (Symtab.update (k, v)) |
403 fun update k v = Data.map (Symtab.update (k, v)) |
402 end |
404 end |
403 *} |
405 *} |
404 |
406 |
405 (* mapfuns for some standard types *) |
407 (* mapfuns for some standard types *) |
406 setup {* |
408 setup {* |
407 Context.theory_map (update @{type_name "list"} {mapfun = @{const_name "map"}}) |
409 update @{type_name "list"} {mapfun = @{const_name "map"}} #> |
408 #> Context.theory_map (update @{type_name "*"} {mapfun = @{const_name "prod_fun"}}) |
410 update @{type_name "*"} {mapfun = @{const_name "prod_fun"}} #> |
409 #> Context.theory_map (update @{type_name "fun"} {mapfun = @{const_name "fun_map"}}) |
411 update @{type_name "fun"} {mapfun = @{const_name "fun_map"}} |
410 *} |
412 *} |
411 |
413 |
412 ML {* lookup (Context.Proof @{context}) @{type_name list} *} |
414 ML {* lookup @{theory} @{type_name list} *} |
413 |
415 |
414 ML {* |
416 ML {* |
415 datatype flag = absF | repF |
417 datatype flag = absF | repF |
416 |
418 |
417 fun get_fun flag rty qty lthy ty = |
419 fun get_fun flag rty qty lthy ty = |
424 val (otys, ntys) = split_list tys |
426 val (otys, ntys) = split_list tys |
425 val oty = Type (s, otys) |
427 val oty = Type (s, otys) |
426 val nty = Type (s, ntys) |
428 val nty = Type (s, ntys) |
427 val ftys = map (op -->) tys |
429 val ftys = map (op -->) tys |
428 in |
430 in |
429 (case (lookup (Context.Proof lthy) s) of |
431 (case (lookup (ProofContext.theory_of lthy) s) of |
430 SOME info => (list_comb (Const (#mapfun info, ftys ---> oty --> nty), fs), (oty, nty)) |
432 SOME info => (list_comb (Const (#mapfun info, ftys ---> oty --> nty), fs), (oty, nty)) |
431 | NONE => raise ERROR ("no map association for type " ^ s)) |
433 | NONE => raise ERROR ("no map association for type " ^ s)) |
432 end |
434 end |
433 |
435 |
434 fun get_const absF = (Const ("QuotMain.ABS_" ^ qty_name, rty --> qty), (rty, qty)) |
436 fun get_const absF = (Const ("QuotMain.ABS_" ^ qty_name, rty --> qty), (rty, qty)) |