src/HOL/Library/Code_Char.thy
author haftmann
Tue Sep 16 16:13:09 2008 +0200 (2008-09-16)
changeset 28244 f433e544a855
parent 28228 7ebe8dc06cbb
child 28346 b8390cd56b8f
permissions -rw-r--r--
a sophisticated char/nibble conversion combinator
haftmann@24999
     1
(*  Title:      HOL/Library/Code_Char.thy
haftmann@24999
     2
    ID:         $Id$
haftmann@24999
     3
    Author:     Florian Haftmann
haftmann@24999
     4
*)
haftmann@24999
     5
haftmann@24999
     6
header {* Code generation of pretty characters (and strings) *}
haftmann@24999
     7
haftmann@24999
     8
theory Code_Char
haftmann@28228
     9
imports Plain "~~/src/HOL/List" "~~/src/HOL/Code_Eval"
haftmann@24999
    10
begin
haftmann@24999
    11
haftmann@24999
    12
code_type char
haftmann@24999
    13
  (SML "char")
haftmann@24999
    14
  (OCaml "char")
haftmann@24999
    15
  (Haskell "Char")
haftmann@24999
    16
haftmann@24999
    17
setup {*
haftmann@28090
    18
  fold (fn target => add_literal_char target) ["SML", "OCaml", "Haskell"] 
haftmann@28090
    19
  #> add_literal_list_string "Haskell"
haftmann@24999
    20
*}
haftmann@24999
    21
haftmann@24999
    22
code_instance char :: eq
haftmann@24999
    23
  (Haskell -)
haftmann@24999
    24
haftmann@24999
    25
code_reserved SML
haftmann@24999
    26
  char
haftmann@24999
    27
haftmann@24999
    28
code_reserved OCaml
haftmann@24999
    29
  char
haftmann@24999
    30
haftmann@24999
    31
code_const "op = \<Colon> char \<Rightarrow> char \<Rightarrow> bool"
haftmann@24999
    32
  (SML "!((_ : char) = _)")
haftmann@24999
    33
  (OCaml "!((_ : char) = _)")
haftmann@24999
    34
  (Haskell infixl 4 "==")
haftmann@24999
    35
haftmann@28228
    36
code_const "Code_Eval.term_of \<Colon> char \<Rightarrow> term"
haftmann@28228
    37
  (SML "HOLogic.mk'_char/ (IntInf.fromInt/ (Char.ord/ _))")
haftmann@28228
    38
haftmann@24999
    39
end