src/Pure/Isar/proof_data.ML
author aspinall
Fri, 07 May 2004 13:34:13 +0200
changeset 14712 81362115cedd
parent 13379 a21e132c3304
child 14981 e73f8140af78
permissions -rw-r--r--
Add -X option to trigger PGIP interaction mode.
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
8807
wenzelm
parents: 8143
diff changeset
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
5821
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     5
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     6
Type-safe interface for proof context data.
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
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
     9
signature PROOF_DATA_ARGS =
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    10
sig
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    11
  val name: string
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    12
  type T
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    13
  val init: theory -> T
13379
a21e132c3304 rearranged to work without proof contexts;
wenzelm
parents: 8807
diff changeset
    14
  val print: ProofContext.context -> T -> unit
5821
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    15
end;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    16
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    17
signature PROOF_DATA =
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    18
sig
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    19
  type T
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    20
  val init: theory -> theory
13379
a21e132c3304 rearranged to work without proof contexts;
wenzelm
parents: 8807
diff changeset
    21
  val print: ProofContext.context -> unit
a21e132c3304 rearranged to work without proof contexts;
wenzelm
parents: 8807
diff changeset
    22
  val get: ProofContext.context -> T
a21e132c3304 rearranged to work without proof contexts;
wenzelm
parents: 8807
diff changeset
    23
  val put: T -> ProofContext.context -> ProofContext.context
a21e132c3304 rearranged to work without proof contexts;
wenzelm
parents: 8807
diff changeset
    24
  val map: (T -> T) -> ProofContext.context -> ProofContext.context
5821
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    25
end;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    26
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    27
functor ProofDataFun(Args: PROOF_DATA_ARGS): PROOF_DATA =
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    28
struct
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    29
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    30
(*object kind kept private!*)
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    31
val kind = Object.kind Args.name;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    32
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    33
type T = Args.T;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    34
exception Data of T;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    35
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    36
val init =
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    37
  ProofContext.init_data kind
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    38
    (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
    39
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    40
val print = ProofContext.print_data kind;
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    41
val get = ProofContext.get_data kind (fn Data x => x);
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    42
val put = ProofContext.put_data kind Data;
8143
b0e44ab73631 added map, map_st;
wenzelm
parents: 6788
diff changeset
    43
fun map f ctxt = put (f (get ctxt)) ctxt;
b0e44ab73631 added map, map_st;
wenzelm
parents: 6788
diff changeset
    44
5821
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    45
end;
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
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    48
(*hide private data access functions*)
262ce90e4736 Type-safe interface for proof context data.
wenzelm
parents:
diff changeset
    49
structure ProofContext: PROOF_CONTEXT = ProofContext;