28019
|
1 |
(* Title: Pure/General/properties.ML
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Property lists.
|
|
5 |
*)
|
|
6 |
|
|
7 |
signature PROPERTIES =
|
|
8 |
sig
|
50842
|
9 |
type entry = string * string
|
|
10 |
type T = entry list
|
28019
|
11 |
val defined: T -> string -> bool
|
|
12 |
val get: T -> string -> string option
|
50842
|
13 |
val put: entry -> T -> T
|
28019
|
14 |
val remove: string -> T -> T
|
51665
|
15 |
val seconds: T -> string -> Time.time
|
28019
|
16 |
end;
|
|
17 |
|
|
18 |
structure Properties: PROPERTIES =
|
|
19 |
struct
|
|
20 |
|
50842
|
21 |
type entry = string * string;
|
|
22 |
type T = entry list;
|
28019
|
23 |
|
|
24 |
fun defined (props: T) name = AList.defined (op =) props name;
|
|
25 |
fun get (props: T) name = AList.lookup (op =) props name;
|
43780
|
26 |
fun put entry (props: T) = AList.update (op =) entry props;
|
28019
|
27 |
fun remove name (props: T) = AList.delete (op =) name props;
|
|
28 |
|
51665
|
29 |
fun seconds props name =
|
|
30 |
(case AList.lookup (op =) props name of
|
|
31 |
NONE => Time.zeroTime
|
|
32 |
| SOME s => Time.fromReal (the_default 0.0 (Real.fromString s)));
|
|
33 |
|
28019
|
34 |
end;
|