src/HOL/Library/Code_Char.thy
author haftmann
Tue Sep 16 09:21:24 2008 +0200 (2008-09-16)
changeset 28228 7ebe8dc06cbb
parent 28090 29af3c712d2b
child 28244 f433e544a855
permissions -rw-r--r--
evaluation using code generator
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@25965
    12
declare char.recs [code func del] char.cases [code func del]
haftmann@25965
    13
haftmann@24999
    14
code_type char
haftmann@24999
    15
  (SML "char")
haftmann@24999
    16
  (OCaml "char")
haftmann@24999
    17
  (Haskell "Char")
haftmann@24999
    18
haftmann@24999
    19
setup {*
haftmann@28090
    20
  fold (fn target => add_literal_char target) ["SML", "OCaml", "Haskell"] 
haftmann@28090
    21
  #> add_literal_list_string "Haskell"
haftmann@24999
    22
*}
haftmann@24999
    23
haftmann@24999
    24
code_instance char :: eq
haftmann@24999
    25
  (Haskell -)
haftmann@24999
    26
haftmann@24999
    27
code_reserved SML
haftmann@24999
    28
  char
haftmann@24999
    29
haftmann@24999
    30
code_reserved OCaml
haftmann@24999
    31
  char
haftmann@24999
    32
haftmann@24999
    33
code_const "op = \<Colon> char \<Rightarrow> char \<Rightarrow> bool"
haftmann@24999
    34
  (SML "!((_ : char) = _)")
haftmann@24999
    35
  (OCaml "!((_ : char) = _)")
haftmann@24999
    36
  (Haskell infixl 4 "==")
haftmann@24999
    37
haftmann@28228
    38
lemma [code func, code func del]:
haftmann@28228
    39
  "(Code_Eval.term_of :: char \<Rightarrow> term) = Code_Eval.term_of" ..
haftmann@28228
    40
haftmann@28228
    41
code_const "Code_Eval.term_of \<Colon> char \<Rightarrow> term"
haftmann@28228
    42
  (SML "HOLogic.mk'_char/ (IntInf.fromInt/ (Char.ord/ _))")
haftmann@28228
    43
haftmann@24999
    44
end