CookBook/Recipes/StoringData.thy
changeset 69 19106a9975c1
parent 68 e7519207c2b7
child 72 7b8c4fe235aa
equal deleted inserted replaced
68:e7519207c2b7 69:19106a9975c1
    14   Every generic data slot may keep data of any kind which is stored in the
    14   Every generic data slot may keep data of any kind which is stored in the
    15   context.
    15   context.
    16 
    16 
    17   *}
    17   *}
    18 
    18 
    19 ML {* 
    19 ML{*local
    20 local
       
    21 
    20 
    22 structure Data = GenericDataFun
    21 structure Data = GenericDataFun
    23  ( type T = int Symtab.table
    22  ( type T = int Symtab.table
    24    val empty = Symtab.empty
    23    val empty = Symtab.empty
    25    val extend = I
    24    val extend = I
    26    fun merge _ = Symtab.merge (K true)
    25    fun merge _ = Symtab.merge (K true)
    27  )
    26  )
    28 
    27 
    29 in
    28 in
    30 
    29  val lookup = Symtab.lookup o Data.get
    31 val lookup = Symtab.lookup o Data.get
    30  fun update k v = Data.map (Symtab.update (k, v))
    32 
       
    33 fun update k v = Data.map (Symtab.update (k, v))
       
    34 
       
    35 end *}
    31 end *}
    36 
    32 
    37 setup {* Context.theory_map (update "foo" 1) *}
    33 setup {* Context.theory_map (update "foo" 1) *}
    38 
    34 
    39 text {*
    35 text {*