src/HOL/Library/Code_Char.thy
author bulwahn
Fri Apr 08 16:31:14 2011 +0200 (2011-04-08)
changeset 42316 12635bb655fd
parent 42231 bc1891226d00
child 42598 85ca44488a29
permissions -rw-r--r--
deactivating other compilations in quickcheck_exhaustive momentarily that only interesting for my benchmarks and experiments
haftmann@24999
     1
(*  Title:      HOL/Library/Code_Char.thy
haftmann@24999
     2
    Author:     Florian Haftmann
haftmann@24999
     3
*)
haftmann@24999
     4
haftmann@24999
     5
header {* Code generation of pretty characters (and strings) *}
haftmann@24999
     6
haftmann@24999
     7
theory Code_Char
haftmann@32657
     8
imports List Code_Evaluation Main
haftmann@24999
     9
begin
haftmann@24999
    10
haftmann@24999
    11
code_type char
haftmann@24999
    12
  (SML "char")
haftmann@24999
    13
  (OCaml "char")
haftmann@24999
    14
  (Haskell "Char")
haftmann@37222
    15
  (Scala "Char")
haftmann@24999
    16
haftmann@24999
    17
setup {*
haftmann@37222
    18
  fold String_Code.add_literal_char ["SML", "OCaml", "Haskell", "Scala"] 
haftmann@31053
    19
  #> String_Code.add_literal_list_string "Haskell"
haftmann@24999
    20
*}
haftmann@24999
    21
haftmann@38857
    22
code_instance char :: equal
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@37222
    31
code_reserved Scala
haftmann@37222
    32
  char
haftmann@37222
    33
haftmann@38857
    34
code_const "HOL.equal \<Colon> char \<Rightarrow> char \<Rightarrow> bool"
haftmann@24999
    35
  (SML "!((_ : char) = _)")
haftmann@24999
    36
  (OCaml "!((_ : char) = _)")
haftmann@39272
    37
  (Haskell infix 4 "==")
haftmann@37222
    38
  (Scala infixl 5 "==")
haftmann@24999
    39
haftmann@32657
    40
code_const "Code_Evaluation.term_of \<Colon> char \<Rightarrow> term"
haftmann@31046
    41
  (Eval "HOLogic.mk'_char/ (IntInf.fromInt/ (Char.ord/ _))")
haftmann@28228
    42
haftmann@33234
    43
haftmann@33234
    44
definition implode :: "string \<Rightarrow> String.literal" where
haftmann@33234
    45
  "implode = STR"
haftmann@33234
    46
haftmann@33234
    47
code_reserved SML String
haftmann@33234
    48
haftmann@33234
    49
code_const implode
haftmann@33234
    50
  (SML "String.implode")
haftmann@33234
    51
  (OCaml "failwith/ \"implode\"")
haftmann@33234
    52
  (Haskell "_")
haftmann@37459
    53
  (Scala "!(\"\" ++/ _)")
haftmann@33234
    54
haftmann@33234
    55
code_const explode
haftmann@33234
    56
  (SML "String.explode")
haftmann@33234
    57
  (OCaml "failwith/ \"explode\"")
haftmann@33234
    58
  (Haskell "_")
haftmann@37459
    59
  (Scala "!(_.toList)")
haftmann@33234
    60
bulwahn@42231
    61
bulwahn@42316
    62
(*declare Quickcheck_Exhaustive.char.bounded_forall_char.simps [code del]*)
bulwahn@42231
    63
haftmann@24999
    64
end