src/Pure/General/properties.ML
author wenzelm
Sat, 10 Jan 2009 13:10:07 +0100
changeset 29427 7ba952481e29
parent 28032 cb0021c989cd
child 29606 fedb8be05f24
permissions -rw-r--r--
excursion: commit_exit internally -- checkpoints are fully persistent now; excursion: do not force intermediate result states yet -- great performance improvement;

(*  Title:      Pure/General/properties.ML
    ID:         $Id$
    Author:     Makarius

Property lists.
*)

signature PROPERTIES =
sig
  type property = string * string
  type T = property list
  val defined: T -> string -> bool
  val get: T -> string -> string option
  val get_int: T -> string -> int option
  val put: string * string -> T -> T
  val remove: string -> T -> T
end;

structure Properties: PROPERTIES =
struct

type property = string * string;
type T = property list;

fun defined (props: T) name = AList.defined (op =) props name;

fun get (props: T) name = AList.lookup (op =) props name;
fun get_int props name = (case get props name of NONE => NONE | SOME s => Int.fromString s);

fun put prop (props: T) = AList.update (op =) prop props;
fun remove name (props: T) = AList.delete (op =) name props;

end;