1 (* Title: BaseDefinitions/unparseC.sml
2 Author: Walther Neuper 2018
3 (c) copyright due to lincense terms
6 signature UNPARSE_ISAC =
13 val term: term -> term_as_string
14 val term_in_ctxt: Proof.context -> term -> term_as_string
15 val term_in_thy: theory -> term -> term_as_string
17 val term_opt: term option -> term_as_string
19 val terms_short: term list -> term_as_string
20 val terms_in_thy: theory -> term list -> term_as_string
22 val typ: typ -> term_as_string
23 val typ_by_thyID: ThyC.id -> typ -> term_as_string
25 val terms: term list -> term_as_string
28 val term_by_thyID: ThyC.id -> term -> term_as_string
29 val terms_to_strings: term list -> term_as_string list
34 structure UnparseC(**): UNPARSE_ISAC(**) =
38 type term_as_string = string;
40 fun term_in_ctxt ctxt t =
42 val ctxt' = Config.put show_markup false ctxt;
44 Print_Mode.setmp [] (Syntax.string_of_term ctxt') t
47 fun term_by_thyID thyID t =
49 val ctxt' = Config.put show_markup false (Proof_Context.init_global
50 (ThyC.get_theory thyID));
52 Print_Mode.setmp [] (Syntax.string_of_term ctxt') t
56 fun term t = term_in_ctxt (ThyC.id_to_ctxt "Isac_Knowledge") t;
57 fun term_in_thy thy t = term_in_ctxt (Proof_Context.init_global thy) t;
58 fun terms_in_thy thy ts = ts |> map (term_in_thy thy) |> strs2str';
59 fun terms_to_strings ts = map term ts; (* terms_to_strings [t1,t2] = ["1 + 2", "abc"]; *)
60 val terms = strs2str o terms_to_strings; (* terms [t1,t2] = "[\"1 + 2\",\"abc\"]"; *)
62 val terms_short = strs2str' o terms_to_strings; (* terms_short [t1,t2] = "[1 + 2,abc]"; *)
63 fun term_opt (SOME t) = "(SOME " ^ term t ^ ")"
64 | term_opt NONE = "NONE";
66 fun type_to_string'' (thyID : ThyC.id) t =
68 val ctxt' = Config.put show_markup false (Proof_Context.init_global
69 (ThyC.get_theory thyID))
71 Print_Mode.setmp [] (Syntax.string_of_typ ctxt') t
73 fun typ typ = type_to_string'' "Isac_Knowledge" typ; (*TODO legacy*)
74 fun typ_by_thyID thy typ = type_to_string'' thy typ; (*legacy*)
76 val typ_empty = Type ("empty", []);
77 val term_empty = Const ("empty", Type("'a", []));