src/Pure/General/properties.ML
author wenzelm
Sun, 01 Mar 2009 23:36:12 +0100
changeset 30190 479806475f3c
parent 29606 fedb8be05f24
child 43780 2cb2310d68b6
permissions -rw-r--r--
use long names for old-style fold combinators;
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
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
     9
  type property = string * string
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    10
  type T = property list
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
28019
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    14
  val put: string * string -> T -> T
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    15
  val remove: string -> T -> T
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    16
end;
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    17
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    18
structure Properties: PROPERTIES =
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    19
struct
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    20
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    21
type property = string * string;
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    22
type T = property list;
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    23
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    24
fun defined (props: T) name = AList.defined (op =) props name;
28032
cb0021c989cd added get_int;
wenzelm
parents: 28019
diff changeset
    25
28019
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    26
fun get (props: T) name = AList.lookup (op =) props name;
28032
cb0021c989cd added get_int;
wenzelm
parents: 28019
diff changeset
    27
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
    28
28019
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    29
fun put prop (props: T) = AList.update (op =) prop props;
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    30
fun remove name (props: T) = AList.delete (op =) name props;
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    31
359764333bf4 Property lists.
wenzelm
parents:
diff changeset
    32
end;