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
17 fold String_Code.add_literal_char ["SML", "OCaml", "Haskell"]
18 #> String_Code.add_literal_list_string "Haskell"
21 code_instance char :: eq
30 code_const "eq_class.eq \<Colon> char \<Rightarrow> char \<Rightarrow> bool"
31 (SML "!((_ : char) = _)")
32 (OCaml "!((_ : char) = _)")
33 (Haskell infixl 4 "==")
35 code_const "Code_Evaluation.term_of \<Colon> char \<Rightarrow> term"
36 (Eval "HOLogic.mk'_char/ (IntInf.fromInt/ (Char.ord/ _))")
39 definition implode :: "string \<Rightarrow> String.literal" where
42 primrec explode :: "String.literal \<Rightarrow> string" where
46 "literal_case f s = f (explode s)"
47 "literal_rec f s = f (explode s)"
50 code_reserved SML String
53 (SML "String.implode")
54 (OCaml "failwith/ \"implode\"")
58 (SML "String.explode")
59 (OCaml "failwith/ \"explode\"")