src/HOL/Tools/datatype_hooks.ML
author paulson
Wed, 08 Aug 2007 13:59:46 +0200
changeset 24182 a39c5e7de6a7
parent 22846 fb79144af9a3
child 24305 b1df9e31cda1
permissions -rw-r--r--
Fixing the code to undo the function ascii_of

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