src/HOL/Library/Code_Char.thy
author haftmann
Fri, 12 Oct 2007 10:26:18 +0200
changeset 24999 1dbe785ed529
child 25965 05df64f786a4
permissions -rw-r--r--
added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24999
haftmann
parents:
diff changeset
     1
(*  Title:      HOL/Library/Code_Char.thy
haftmann
parents:
diff changeset
     2
    ID:         $Id$
haftmann
parents:
diff changeset
     3
    Author:     Florian Haftmann
haftmann
parents:
diff changeset
     4
*)
haftmann
parents:
diff changeset
     5
haftmann
parents:
diff changeset
     6
header {* Code generation of pretty characters (and strings) *}
haftmann
parents:
diff changeset
     7
haftmann
parents:
diff changeset
     8
theory Code_Char
haftmann
parents:
diff changeset
     9
imports List
haftmann
parents:
diff changeset
    10
begin
haftmann
parents:
diff changeset
    11
haftmann
parents:
diff changeset
    12
code_type char
haftmann
parents:
diff changeset
    13
  (SML "char")
haftmann
parents:
diff changeset
    14
  (OCaml "char")
haftmann
parents:
diff changeset
    15
  (Haskell "Char")
haftmann
parents:
diff changeset
    16
haftmann
parents:
diff changeset
    17
setup {*
haftmann
parents:
diff changeset
    18
let
haftmann
parents:
diff changeset
    19
  val charr = @{const_name Char}
haftmann
parents:
diff changeset
    20
  val nibbles = [@{const_name Nibble0}, @{const_name Nibble1},
haftmann
parents:
diff changeset
    21
    @{const_name Nibble2}, @{const_name Nibble3},
haftmann
parents:
diff changeset
    22
    @{const_name Nibble4}, @{const_name Nibble5},
haftmann
parents:
diff changeset
    23
    @{const_name Nibble6}, @{const_name Nibble7},
haftmann
parents:
diff changeset
    24
    @{const_name Nibble8}, @{const_name Nibble9},
haftmann
parents:
diff changeset
    25
    @{const_name NibbleA}, @{const_name NibbleB},
haftmann
parents:
diff changeset
    26
    @{const_name NibbleC}, @{const_name NibbleD},
haftmann
parents:
diff changeset
    27
    @{const_name NibbleE}, @{const_name NibbleF}];
haftmann
parents:
diff changeset
    28
in
haftmann
parents:
diff changeset
    29
  fold (fn target => CodeTarget.add_pretty_char target charr nibbles)
haftmann
parents:
diff changeset
    30
    ["SML", "OCaml", "Haskell"]
haftmann
parents:
diff changeset
    31
  #> CodeTarget.add_pretty_list_string "Haskell"
haftmann
parents:
diff changeset
    32
    @{const_name Nil} @{const_name Cons} charr nibbles
haftmann
parents:
diff changeset
    33
end
haftmann
parents:
diff changeset
    34
*}
haftmann
parents:
diff changeset
    35
haftmann
parents:
diff changeset
    36
code_instance char :: eq
haftmann
parents:
diff changeset
    37
  (Haskell -)
haftmann
parents:
diff changeset
    38
haftmann
parents:
diff changeset
    39
code_reserved SML
haftmann
parents:
diff changeset
    40
  char
haftmann
parents:
diff changeset
    41
haftmann
parents:
diff changeset
    42
code_reserved OCaml
haftmann
parents:
diff changeset
    43
  char
haftmann
parents:
diff changeset
    44
haftmann
parents:
diff changeset
    45
code_const "op = \<Colon> char \<Rightarrow> char \<Rightarrow> bool"
haftmann
parents:
diff changeset
    46
  (SML "!((_ : char) = _)")
haftmann
parents:
diff changeset
    47
  (OCaml "!((_ : char) = _)")
haftmann
parents:
diff changeset
    48
  (Haskell infixl 4 "==")
haftmann
parents:
diff changeset
    49
haftmann
parents:
diff changeset
    50
end