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