src/HOL/Library/Code_Char.thy
changeset 65884 d76937b773d9
parent 62597 b3f2b8c906a6
equal deleted inserted replaced
65883:750efd46bba9 65884:d76937b773d9
    14     and (OCaml) "char"
    14     and (OCaml) "char"
    15     and (Haskell) "Prelude.Char"
    15     and (Haskell) "Prelude.Char"
    16     and (Scala) "Char"
    16     and (Scala) "Char"
    17 
    17 
    18 setup \<open>
    18 setup \<open>
    19   fold String_Code.add_literal_char ["SML", "OCaml", "Haskell", "Scala"] 
    19   fold String_Code.add_literal_char ["SML", "OCaml", "Haskell", "Scala"]
    20   #> String_Code.add_literal_list_string "Haskell"
    20   #> String_Code.add_literal_list_string "Haskell"
    21 \<close>
    21 \<close>
    22 
    22 
    23 code_printing
    23 code_printing
    24   constant integer_of_char \<rightharpoonup>
    24   constant integer_of_char \<rightharpoonup>
    28     and (Scala) "BigInt(_.toInt)"
    28     and (Scala) "BigInt(_.toInt)"
    29 | constant char_of_integer \<rightharpoonup>
    29 | constant char_of_integer \<rightharpoonup>
    30     (SML) "!(Char.chr o IntInf.toInt)"
    30     (SML) "!(Char.chr o IntInf.toInt)"
    31     and (OCaml) "Char.chr (Big'_int.int'_of'_big'_int _)"
    31     and (OCaml) "Char.chr (Big'_int.int'_of'_big'_int _)"
    32     and (Haskell) "!(let chr k | (0 <= k && k < 256) = Prelude.toEnum k :: Prelude.Char in chr . Prelude.fromInteger)"
    32     and (Haskell) "!(let chr k | (0 <= k && k < 256) = Prelude.toEnum k :: Prelude.Char in chr . Prelude.fromInteger)"
    33     and (Scala) "!((k: BigInt) => if (BigInt(0) <= k && k < BigInt(256)) k.charValue else error(\"character value out of range\"))"
    33     and (Scala) "!((k: BigInt) => if (BigInt(0) <= k && k < BigInt(256)) k.charValue else sys.error(\"character value out of range\"))"
    34 | class_instance char :: equal \<rightharpoonup>
    34 | class_instance char :: equal \<rightharpoonup>
    35     (Haskell) -
    35     (Haskell) -
    36 | constant "HOL.equal :: char \<Rightarrow> char \<Rightarrow> bool" \<rightharpoonup>
    36 | constant "HOL.equal :: char \<Rightarrow> char \<Rightarrow> bool" \<rightharpoonup>
    37     (SML) "!((_ : char) = _)"
    37     (SML) "!((_ : char) = _)"
    38     and (OCaml) "!((_ : char) = _)"
    38     and (OCaml) "!((_ : char) = _)"
    78     and (Scala) infixl 4 "<"
    78     and (Scala) infixl 4 "<"
    79     and (Eval) infixl 6 "<"
    79     and (Eval) infixl 6 "<"
    80 |  constant "Orderings.less_eq :: String.literal \<Rightarrow> String.literal \<Rightarrow> bool" \<rightharpoonup>
    80 |  constant "Orderings.less_eq :: String.literal \<Rightarrow> String.literal \<Rightarrow> bool" \<rightharpoonup>
    81     (SML) "!((_ : string) <= _)"
    81     (SML) "!((_ : string) <= _)"
    82     and (OCaml) "!((_ : string) <= _)"
    82     and (OCaml) "!((_ : string) <= _)"
    83     \<comment> \<open>Order operations for @{typ String.literal} work in Haskell only 
    83     \<comment> \<open>Order operations for @{typ String.literal} work in Haskell only
    84           if no type class instance needs to be generated, because String = [Char] in Haskell
    84           if no type class instance needs to be generated, because String = [Char] in Haskell
    85           and @{typ "char list"} need not have the same order as @{typ String.literal}.\<close>
    85           and @{typ "char list"} need not have the same order as @{typ String.literal}.\<close>
    86     and (Haskell) infix 4 "<="
    86     and (Haskell) infix 4 "<="
    87     and (Scala) infixl 4 "<="
    87     and (Scala) infixl 4 "<="
    88     and (Eval) infixl 6 "<="
    88     and (Eval) infixl 6 "<="