thys/Data_slot.thy
author wuc
Tue, 20 May 2014 20:21:29 +0800
changeset 21 57d89c29c812
parent 0 1378b654acde
permissions -rw-r--r--
test if can write

theory Data_slot
imports Main
begin

ML {*
  fun ML_exec prog = ML_Compiler.eval true Position.none
                        (ML_Lex.tokenize prog)

  fun prog_data_slot name tp empty  = 
  "structure " ^ name ^ " = Theory_Data ( " ^
  "type T = "^ tp ^" " ^
  "val empty = " ^ empty ^ " ; "^
  "val extend = I; "^
  "fun merge (x, y) = x) "^
  "fun "^ name ^ "_store v =  Context.>>(Context.map_theory (" ^ name ^".map (fn x => v))) "^
  "fun "^ name ^ "_get () = Context.>>>(Context.map_theory_result (fn th => "^
  "                                     ("^ name ^".get th, th))) "

  fun data_slot name tp empty  = ML_exec (prog_data_slot name tp empty)
  val empty_term = @{term "x"}
  val empty_cterm = @{cterm "x"}
  val empty_thm = @{thm ext}
*}

end