src/HOL/Tools/datatype_hooks.ML
author wenzelm
Wed, 01 Aug 2007 16:55:40 +0200
changeset 24112 6c4e7d17f9b0
parent 22846 fb79144af9a3
child 24305 b1df9e31cda1
permissions -rw-r--r--
simplified internal Config interface;

(*  Title:      HOL/Tools/datatype_hooks.ML
    ID:         $Id$
    Author:     Florian Haftmann, TU Muenchen

Hooks for datatype introduction.
*)

signature DATATYPE_HOOKS =
sig
  type hook = string list -> theory -> theory
  val add: hook -> theory -> theory
  val all: hook
end;

structure DatatypeHooks : DATATYPE_HOOKS =
struct

type hook = string list -> theory -> theory;

structure DatatypeHooksData = TheoryDataFun
(
  type T = (serial * hook) list;
  val empty = [];
  val copy = I;
  val extend = I;
  fun merge _ hooks : T = AList.merge (op =) (K true) hooks;
);

fun add hook =
  DatatypeHooksData.map (cons (serial (), hook));

fun all dtcos thy =
  fold (fn (_, f) => f dtcos) (DatatypeHooksData.get thy) thy;

end;