src/Pure/General/properties.ML
author wenzelm
Sat, 14 Jan 2012 12:36:43 +0100
changeset 46204 df1369a42393
parent 43780 2cb2310d68b6
child 46829 9770573e2172
permissions -rw-r--r--
tuned signature;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28019
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/General/properties.ML
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
     3
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
     4
Property lists.
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
     5
*)
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
     6
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
     7
signature PROPERTIES =
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
     8
sig
43780
2cb2310d68b6 more uniform Properties in ML and Scala;
wenzelm
parents: 29606
diff changeset
     9
  type entry = string * string
2cb2310d68b6 more uniform Properties in ML and Scala;
wenzelm
parents: 29606
diff changeset
    10
  type T = entry list
28019
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    11
  val defined: T -> string -> bool
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    12
  val get: T -> string -> string option
28032
cb0021c989cd added get_int;
wenzelm
parents: 28019
diff changeset
    13
  val get_int: T -> string -> int option
43780
2cb2310d68b6 more uniform Properties in ML and Scala;
wenzelm
parents: 29606
diff changeset
    14
  val put: entry -> T -> T
2cb2310d68b6 more uniform Properties in ML and Scala;
wenzelm
parents: 29606
diff changeset
    15
  val put_int: string * int -> T -> T
28019
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    16
  val remove: string -> T -> T
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    17
end;
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    18
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    19
structure Properties: PROPERTIES =
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    20
struct
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    21
43780
2cb2310d68b6 more uniform Properties in ML and Scala;
wenzelm
parents: 29606
diff changeset
    22
type entry = string * string;
2cb2310d68b6 more uniform Properties in ML and Scala;
wenzelm
parents: 29606
diff changeset
    23
type T = entry list;
28019
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    24
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    25
fun defined (props: T) name = AList.defined (op =) props name;
28032
cb0021c989cd added get_int;
wenzelm
parents: 28019
diff changeset
    26
28019
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    27
fun get (props: T) name = AList.lookup (op =) props name;
28032
cb0021c989cd added get_int;
wenzelm
parents: 28019
diff changeset
    28
fun get_int props name = (case get props name of NONE => NONE | SOME s => Int.fromString s);
cb0021c989cd added get_int;
wenzelm
parents: 28019
diff changeset
    29
43780
2cb2310d68b6 more uniform Properties in ML and Scala;
wenzelm
parents: 29606
diff changeset
    30
fun put entry (props: T) = AList.update (op =) entry props;
2cb2310d68b6 more uniform Properties in ML and Scala;
wenzelm
parents: 29606
diff changeset
    31
fun put_int (name, i) = put (name, signed_string_of_int i);
2cb2310d68b6 more uniform Properties in ML and Scala;
wenzelm
parents: 29606
diff changeset
    32
28019
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    33
fun remove name (props: T) = AList.delete (op =) name props;
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    34
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    35
end;