src/HOL/Library/Code_Char.thy
author haftmann
Fri Oct 12 10:26:18 2007 +0200 (2007-10-12)
changeset 24999 1dbe785ed529
child 25965 05df64f786a4
permissions -rw-r--r--
added
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@24999
     9
imports List
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@24999
    18
let
haftmann@24999
    19
  val charr = @{const_name Char}
haftmann@24999
    20
  val nibbles = [@{const_name Nibble0}, @{const_name Nibble1},
haftmann@24999
    21
    @{const_name Nibble2}, @{const_name Nibble3},
haftmann@24999
    22
    @{const_name Nibble4}, @{const_name Nibble5},
haftmann@24999
    23
    @{const_name Nibble6}, @{const_name Nibble7},
haftmann@24999
    24
    @{const_name Nibble8}, @{const_name Nibble9},
haftmann@24999
    25
    @{const_name NibbleA}, @{const_name NibbleB},
haftmann@24999
    26
    @{const_name NibbleC}, @{const_name NibbleD},
haftmann@24999
    27
    @{const_name NibbleE}, @{const_name NibbleF}];
haftmann@24999
    28
in
haftmann@24999
    29
  fold (fn target => CodeTarget.add_pretty_char target charr nibbles)
haftmann@24999
    30
    ["SML", "OCaml", "Haskell"]
haftmann@24999
    31
  #> CodeTarget.add_pretty_list_string "Haskell"
haftmann@24999
    32
    @{const_name Nil} @{const_name Cons} charr nibbles
haftmann@24999
    33
end
haftmann@24999
    34
*}
haftmann@24999
    35
haftmann@24999
    36
code_instance char :: eq
haftmann@24999
    37
  (Haskell -)
haftmann@24999
    38
haftmann@24999
    39
code_reserved SML
haftmann@24999
    40
  char
haftmann@24999
    41
haftmann@24999
    42
code_reserved OCaml
haftmann@24999
    43
  char
haftmann@24999
    44
haftmann@24999
    45
code_const "op = \<Colon> char \<Rightarrow> char \<Rightarrow> bool"
haftmann@24999
    46
  (SML "!((_ : char) = _)")
haftmann@24999
    47
  (OCaml "!((_ : char) = _)")
haftmann@24999
    48
  (Haskell infixl 4 "==")
haftmann@24999
    49
haftmann@24999
    50
end