src/Pure/General/properties.ML
author wenzelm
Wed, 31 Dec 2008 18:53:16 +0100
changeset 29270 0eade173f77e
parent 28032 cb0021c989cd
child 29606 fedb8be05f24
permissions -rw-r--r--
moved old add_type_XXX, add_term_XXX etc. to structure OldTerm;

(*  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;