Difference between revisions of "DDC/PolymorphicUpdate"
< DDC
Jump to navigation
Jump to search
Line 10: | Line 10: | ||
(get, set) |
(get, set) |
||
</haskell> |
</haskell> |
||
+ | |||
+ | This function allocates a box which can store a value and returns a tuple of functions which can be used to get and set that value. |
Revision as of 06:17, 19 March 2008
Get/Set
Consider the following function:
makeGetSet :: a -> (() -> a, a -> ())
makeGetSet x
= do box = Just x
get () = case box of { Just z -> z; }
set z = box#x #= z
(get, set)
This function allocates a box which can store a value and returns a tuple of functions which can be used to get and set that value.