82 and print_plain_dict is_pseudo_fun fxy (Dict_Const (inst, dss)) = |
82 and print_plain_dict is_pseudo_fun fxy (Dict_Const (inst, dss)) = |
83 ((str o deresolve_inst) inst :: |
83 ((str o deresolve_inst) inst :: |
84 (if is_pseudo_fun (Class_Instance inst) then [str "()"] |
84 (if is_pseudo_fun (Class_Instance inst) then [str "()"] |
85 else map_filter (print_dicts is_pseudo_fun BR) dss)) |
85 else map_filter (print_dicts is_pseudo_fun BR) dss)) |
86 | print_plain_dict is_pseudo_fun fxy (Dict_Var (v, (i, k))) = |
86 | print_plain_dict is_pseudo_fun fxy (Dict_Var (v, (i, k))) = |
87 [str (if k = 1 then first_upper v ^ "_" |
87 [str (if k = 1 then Name.enforce_case true v ^ "_" |
88 else first_upper v ^ string_of_int (i+1) ^ "_")] |
88 else Name.enforce_case true v ^ string_of_int (i+1) ^ "_")] |
89 and print_dicts is_pseudo_fun = tuplify (print_dict is_pseudo_fun); |
89 and print_dicts is_pseudo_fun = tuplify (print_dict is_pseudo_fun); |
90 val print_dict_args = map_filter (fn (v, sort) => print_dicts (K false) BR |
90 val print_dict_args = map_filter (fn (v, sort) => print_dicts (K false) BR |
91 (map_index (fn (i, _) => Dict ([], Dict_Var (v, (i, length sort)))) sort)); |
91 (map_index (fn (i, _) => Dict ([], Dict_Var (v, (i, length sort)))) sort)); |
92 fun print_term is_pseudo_fun some_thm vars fxy (IConst const) = |
92 fun print_term is_pseudo_fun some_thm vars fxy (IConst const) = |
93 print_app is_pseudo_fun some_thm vars fxy (const, []) |
93 print_app is_pseudo_fun some_thm vars fxy (const, []) |
393 and print_plain_dict is_pseudo_fun fxy (Dict_Const (inst, dss)) = |
393 and print_plain_dict is_pseudo_fun fxy (Dict_Const (inst, dss)) = |
394 brackify BR ((str o deresolve_inst) inst :: |
394 brackify BR ((str o deresolve_inst) inst :: |
395 (if is_pseudo_fun (Class_Instance inst) then [str "()"] |
395 (if is_pseudo_fun (Class_Instance inst) then [str "()"] |
396 else map_filter (print_dicts is_pseudo_fun BR) dss)) |
396 else map_filter (print_dicts is_pseudo_fun BR) dss)) |
397 | print_plain_dict is_pseudo_fun fxy (Dict_Var (v, (i, k))) = |
397 | print_plain_dict is_pseudo_fun fxy (Dict_Var (v, (i, k))) = |
398 str (if k = 1 then "_" ^ first_upper v |
398 str (if k = 1 then "_" ^ Name.enforce_case true v |
399 else "_" ^ first_upper v ^ string_of_int (i+1)) |
399 else "_" ^ Name.enforce_case true v ^ string_of_int (i+1)) |
400 and print_dicts is_pseudo_fun = tuplify (print_dict is_pseudo_fun); |
400 and print_dicts is_pseudo_fun = tuplify (print_dict is_pseudo_fun); |
401 val print_dict_args = map_filter (fn (v, sort) => print_dicts (K false) BR |
401 val print_dict_args = map_filter (fn (v, sort) => print_dicts (K false) BR |
402 (map_index (fn (i, _) => Dict ([], Dict_Var (v, (i, length sort)))) sort)); |
402 (map_index (fn (i, _) => Dict ([], Dict_Var (v, (i, length sort)))) sort)); |
403 fun print_term is_pseudo_fun some_thm vars fxy (IConst const) = |
403 fun print_term is_pseudo_fun some_thm vars fxy (IConst const) = |
404 print_app is_pseudo_fun some_thm vars fxy (const, []) |
404 print_app is_pseudo_fun some_thm vars fxy (const, []) |
653 fun print_classparam_decl (classparam, ty) = |
653 fun print_classparam_decl (classparam, ty) = |
654 print_val_decl print_typscheme |
654 print_val_decl print_typscheme |
655 (Constant classparam, ([(v, [class])], ty)); |
655 (Constant classparam, ([(v, [class])], ty)); |
656 fun print_classparam_field (classparam, ty) = |
656 fun print_classparam_field (classparam, ty) = |
657 print_field (deresolve_const classparam) (print_typ NOBR ty); |
657 print_field (deresolve_const classparam) (print_typ NOBR ty); |
658 val w = "_" ^ first_upper v; |
658 val w = "_" ^ Name.enforce_case true v; |
659 fun print_classparam_proj (classparam, _) = |
659 fun print_classparam_proj (classparam, _) = |
660 (concat o map str) ["let", deresolve_const classparam, w, "=", |
660 (concat o map str) ["let", deresolve_const classparam, w, "=", |
661 w ^ "." ^ deresolve_const classparam ^ ";;"]; |
661 w ^ "." ^ deresolve_const classparam ^ ";;"]; |
662 val type_decl_p = concat [ |
662 val type_decl_p = concat [ |
663 str "type", |
663 str "type", |
722 fun ml_program_of_program ctxt module_name reserved identifiers = |
722 fun ml_program_of_program ctxt module_name reserved identifiers = |
723 let |
723 let |
724 fun namify_const upper base (nsp_const, nsp_type) = |
724 fun namify_const upper base (nsp_const, nsp_type) = |
725 let |
725 let |
726 val (base', nsp_const') = |
726 val (base', nsp_const') = |
727 Name.variant (if upper then first_upper base else base) nsp_const |
727 Name.variant (if upper then Name.enforce_case true base else base) nsp_const |
728 in (base', (nsp_const', nsp_type)) end; |
728 in (base', (nsp_const', nsp_type)) end; |
729 fun namify_type base (nsp_const, nsp_type) = |
729 fun namify_type base (nsp_const, nsp_type) = |
730 let |
730 let |
731 val (base', nsp_type') = Name.variant base nsp_type |
731 val (base', nsp_type') = Name.variant base nsp_type |
732 in (base', (nsp_const, nsp_type')) end; |
732 in (base', (nsp_const, nsp_type')) end; |