| 5821 |      1 | (*  Title:      Pure/Isar/proof_data.ML
 | 
|  |      2 |     ID:         $Id$
 | 
|  |      3 |     Author:     Markus Wenzel, TU Muenchen
 | 
| 8807 |      4 |     License:    GPL (GNU GENERAL PUBLIC LICENSE)
 | 
| 5821 |      5 | 
 | 
|  |      6 | Type-safe interface for proof context data.
 | 
|  |      7 | *)
 | 
|  |      8 | 
 | 
|  |      9 | signature PROOF_DATA_ARGS =
 | 
|  |     10 | sig
 | 
|  |     11 |   val name: string
 | 
|  |     12 |   type T
 | 
|  |     13 |   val init: theory -> T
 | 
| 13379 |     14 |   val print: ProofContext.context -> T -> unit
 | 
| 5821 |     15 | end;
 | 
|  |     16 | 
 | 
|  |     17 | signature PROOF_DATA =
 | 
|  |     18 | sig
 | 
|  |     19 |   type T
 | 
|  |     20 |   val init: theory -> theory
 | 
| 13379 |     21 |   val print: ProofContext.context -> unit
 | 
|  |     22 |   val get: ProofContext.context -> T
 | 
|  |     23 |   val put: T -> ProofContext.context -> ProofContext.context
 | 
|  |     24 |   val map: (T -> T) -> ProofContext.context -> ProofContext.context
 | 
| 5821 |     25 | end;
 | 
|  |     26 | 
 | 
|  |     27 | functor ProofDataFun(Args: PROOF_DATA_ARGS): PROOF_DATA =
 | 
|  |     28 | struct
 | 
|  |     29 | 
 | 
|  |     30 | (*object kind kept private!*)
 | 
|  |     31 | val kind = Object.kind Args.name;
 | 
|  |     32 | 
 | 
|  |     33 | type T = Args.T;
 | 
|  |     34 | exception Data of T;
 | 
|  |     35 | 
 | 
|  |     36 | val init =
 | 
|  |     37 |   ProofContext.init_data kind
 | 
|  |     38 |     (Data o Args.init, fn ctxt => fn (Data x) => Args.print ctxt x);
 | 
|  |     39 | 
 | 
|  |     40 | val print = ProofContext.print_data kind;
 | 
|  |     41 | val get = ProofContext.get_data kind (fn Data x => x);
 | 
|  |     42 | val put = ProofContext.put_data kind Data;
 | 
| 8143 |     43 | fun map f ctxt = put (f (get ctxt)) ctxt;
 | 
|  |     44 | 
 | 
| 5821 |     45 | end;
 | 
|  |     46 | 
 | 
|  |     47 | 
 | 
|  |     48 | (*hide private data access functions*)
 | 
|  |     49 | structure ProofContext: PROOF_CONTEXT = ProofContext;
 |