1 (* Title: HOL/Library/Code_Char.thy
2 Author: Florian Haftmann
5 header {* Code generation of pretty characters (and strings) *}
8 imports List Code_Evaluation Main
18 fold String_Code.add_literal_char ["SML", "OCaml", "Haskell", "Scala"]
19 #> String_Code.add_literal_list_string "Haskell"
22 code_instance char :: eq
34 code_const "eq_class.eq \<Colon> char \<Rightarrow> char \<Rightarrow> bool"
35 (SML "!((_ : char) = _)")
36 (OCaml "!((_ : char) = _)")
37 (Haskell infixl 4 "==")
40 code_const "Code_Evaluation.term_of \<Colon> char \<Rightarrow> term"
41 (Eval "HOLogic.mk'_char/ (IntInf.fromInt/ (Char.ord/ _))")
44 definition implode :: "string \<Rightarrow> String.literal" where
47 primrec explode :: "String.literal \<Rightarrow> string" where
51 "literal_case f s = f (explode s)"
52 "literal_rec f s = f (explode s)"
55 code_reserved SML String
58 (SML "String.implode")
59 (OCaml "failwith/ \"implode\"")
61 (Scala "List.toString((_))")
64 (SML "String.explode")
65 (OCaml "failwith/ \"explode\"")
67 (Scala "List.fromString((_))")