equal
deleted
inserted
replaced
46 |
46 |
47 definition update :: "'a ref \<Rightarrow> 'a\<Colon>heap \<Rightarrow> unit Heap" ("_ := _" 62) where |
47 definition update :: "'a ref \<Rightarrow> 'a\<Colon>heap \<Rightarrow> unit Heap" ("_ := _" 62) where |
48 [code del]: "update r v = Heap_Monad.heap (\<lambda>h. ((), set r v h))" |
48 [code del]: "update r v = Heap_Monad.heap (\<lambda>h. ((), set r v h))" |
49 |
49 |
50 definition change :: "('a\<Colon>heap \<Rightarrow> 'a) \<Rightarrow> 'a ref \<Rightarrow> 'a Heap" where |
50 definition change :: "('a\<Colon>heap \<Rightarrow> 'a) \<Rightarrow> 'a ref \<Rightarrow> 'a Heap" where |
51 "change f r = (do |
51 "change f r = do { |
52 x \<leftarrow> ! r; |
52 x \<leftarrow> ! r; |
53 let y = f x; |
53 let y = f x; |
54 r := y; |
54 r := y; |
55 return y |
55 return y |
56 done)" |
56 }" |
57 |
57 |
58 |
58 |
59 subsection {* Properties *} |
59 subsection {* Properties *} |
60 |
60 |
61 text {* Primitives *} |
61 text {* Primitives *} |