@@ -90,25 +90,21 @@ import Foreign.Storable
90
90
91
91
-- | A concrete implementation of a readable and writable state variable,
92
92
-- carrying one IO action to read the value and another IO action to write the
93
- -- new value.
93
+ -- new value. This data type represents a piece of mutable, imperative state
94
+ -- with possible side-effects. These tend to encapsulate all sorts tricky
95
+ -- behavior in external libraries, and may well throw exceptions. Inhabitants
96
+ -- __should__ satsify the following properties:
94
97
--
95
- -- This data type represents a piece of mutable, imperative state
96
- -- with possible side-effects. These tend to encapsulate all sorts
97
- -- tricky behavior in external libraries, and may well throw
98
- -- exceptions.
99
- --
100
- -- Inhabitants __should__ satsify the following properties.
101
- --
102
- -- In the absence of concurrent mutation from other threads or a
103
- -- thrown exception:
98
+ -- * In the absence of concurrent mutation from other threads or a thrown
99
+ -- exception:
104
100
--
105
101
-- @
106
102
-- do x <- 'get' v; v '$=' y; v '$=' x
107
103
-- @
108
104
--
109
105
-- should restore the previous state.
110
106
--
111
- -- Ideally, in the absence of thrown exceptions:
107
+ -- * Ideally, in the absence of thrown exceptions:
112
108
--
113
109
-- @
114
110
-- v '$=' a >> 'get' v
@@ -196,6 +192,7 @@ instance HasSetter (TVar a) a where
196
192
197
193
infixr 2 $~ , $~!
198
194
195
+ -- | This is the class of all updatable state variables.
199
196
class HasSetter t a => HasUpdate t a b | t -> a b where
200
197
-- | Transform the contents of a state variable with a given funtion.
201
198
($~) :: MonadIO m => t -> (a -> b ) -> m ()
@@ -250,6 +247,7 @@ instance HasUpdate (TVar a) a a where
250
247
-- * HasGetter
251
248
--------------------------------------------------------------------
252
249
250
+ -- | This is the class of all readable state variables.
253
251
class HasGetter t a | t -> a where
254
252
get :: MonadIO m => t -> m a
255
253
0 commit comments