src/Pure/Isar/proof_data.ML
author wenzelm
Tue, 17 May 2005 10:19:45 +0200
changeset 15974 cef3d89d49d4
parent 14981 e73f8140af78
permissions -rw-r--r--
moved credit to CONTRIBUTORS; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5821
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/proof_data.ML
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     4
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     5
Type-safe interface for proof context data.
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     6
*)
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     7
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     8
signature PROOF_DATA_ARGS =
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     9
sig
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    10
  val name: string
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    11
  type T
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    12
  val init: theory -> T
13379
a21e132c3304 rearranged to work without proof contexts;
wenzelm
parents: 8807
diff changeset
    13
  val print: ProofContext.context -> T -> unit
5821
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    14
end;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    15
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    16
signature PROOF_DATA =
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    17
sig
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    18
  type T
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    19
  val init: theory -> theory
13379
a21e132c3304 rearranged to work without proof contexts;
wenzelm
parents: 8807
diff changeset
    20
  val print: ProofContext.context -> unit
a21e132c3304 rearranged to work without proof contexts;
wenzelm
parents: 8807
diff changeset
    21
  val get: ProofContext.context -> T
a21e132c3304 rearranged to work without proof contexts;
wenzelm
parents: 8807
diff changeset
    22
  val put: T -> ProofContext.context -> ProofContext.context
a21e132c3304 rearranged to work without proof contexts;
wenzelm
parents: 8807
diff changeset
    23
  val map: (T -> T) -> ProofContext.context -> ProofContext.context
5821
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    24
end;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    25
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    26
functor ProofDataFun(Args: PROOF_DATA_ARGS): PROOF_DATA =
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    27
struct
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    28
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    29
(*object kind kept private!*)
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    30
val kind = Object.kind Args.name;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    31
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    32
type T = Args.T;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    33
exception Data of T;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    34
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    35
val init =
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    36
  ProofContext.init_data kind
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    37
    (Data o Args.init, fn ctxt => fn (Data x) => Args.print ctxt x);
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    38
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    39
val print = ProofContext.print_data kind;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    40
val get = ProofContext.get_data kind (fn Data x => x);
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    41
val put = ProofContext.put_data kind Data;
8143
b0e44ab73631 added map, map_st;
wenzelm
parents: 6788
diff changeset
    42
fun map f ctxt = put (f (get ctxt)) ctxt;
b0e44ab73631 added map, map_st;
wenzelm
parents: 6788
diff changeset
    43
5821
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    44
end;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    45
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    46
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    47
(*hide private data access functions*)
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    48
structure ProofContext: PROOF_CONTEXT = ProofContext;