28019
|
1 |
(* Title: Pure/General/properties.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Makarius
|
|
4 |
|
|
5 |
Property lists.
|
|
6 |
*)
|
|
7 |
|
|
8 |
signature PROPERTIES =
|
|
9 |
sig
|
|
10 |
type property = string * string
|
|
11 |
type T = property list
|
|
12 |
val defined: T -> string -> bool
|
|
13 |
val get: T -> string -> string option
|
28032
|
14 |
val get_int: T -> string -> int option
|
28019
|
15 |
val put: string * string -> T -> T
|
|
16 |
val remove: string -> T -> T
|
|
17 |
end;
|
|
18 |
|
|
19 |
structure Properties: PROPERTIES =
|
|
20 |
struct
|
|
21 |
|
|
22 |
type property = string * string;
|
|
23 |
type T = property list;
|
|
24 |
|
|
25 |
fun defined (props: T) name = AList.defined (op =) props name;
|
28032
|
26 |
|
28019
|
27 |
fun get (props: T) name = AList.lookup (op =) props name;
|
28032
|
28 |
fun get_int props name = (case get props name of NONE => NONE | SOME s => Int.fromString s);
|
|
29 |
|
28019
|
30 |
fun put prop (props: T) = AList.update (op =) prop props;
|
|
31 |
fun remove name (props: T) = AList.delete (op =) name props;
|
|
32 |
|
|
33 |
end;
|