@@ -93,16 +93,16 @@ Recall that to run an effectful program in ``Eff``, we use one of the
93``run`` family of functions to run the program in a particular
93``run`` family of functions to run the program in a particular
94computation context ``m``. For each effect, therefore, we must explain
94computation context ``m``. For each effect, therefore, we must explain
95how it is executed in a particular computation context for ``run`` to
95how it is executed in a particular computation context for ``run`` to
96−work in that context. This is achieved with the following type class:
96+work in that context. This is achieved with the following interface:
98.. code-block:: idris
98.. code-block:: idris
100− class Handler (e : Effect) (m : Type -> Type) where
100+ interface Handler (e : Effect) (m : Type -> Type) where
101 handle : resource -> (eff : e t resource resource') ->
101 handle : resource -> (eff : e t resource resource') ->
102 ((x : t) -> resource' x -> m a) -> m a
102 ((x : t) -> resource' x -> m a) -> m a
104−We have already seen some instance declarations in the effect
104+We have already seen some implementation declarations in the effect
105−summaries in Section :ref:`sect-simpleff`. An instance of ``Handler e
105+summaries in Section :ref:`sect-simpleff`. An implementation of ``Handler e
106m`` means that the effect declared with signature ``e`` can be run in
106m`` means that the effect declared with signature ``e`` can be run in
107computation context ``m``. The ``handle`` function takes:
107computation context ``m``. The ``handle`` function takes:
@@ -123,7 +123,7 @@ in the case of ``Get``, or passes on a new state, in the case of
124.. code-block:: idris
124.. code-block:: idris
126− instance Handler State m where
126+ Handler State m where
127 handle st Get k = k st st
127 handle st Get k = k st st
128 handle st (Put n) k = k () n
128 handle st (Put n) k = k () n
@@ -176,7 +176,7 @@ The following listing summarises what is required to define the
176 STATE : Type -> EFFECT
176 STATE : Type -> EFFECT
177 STATE t = MkEff t State
177 STATE t = MkEff t State
179− instance Handler State m where
179+ Handler State m where
180 handle st Get k = k st st
180 handle st Get k = k st st
181 handle st (Put n) k = k () n
181 handle st (Put n) k = k () n
@@ -211,13 +211,13 @@ directly.
211 PutCh : Char -> sig StdIO ()
211 PutCh : Char -> sig StdIO ()
212 GetCh : sig StdIO Char
212 GetCh : sig StdIO Char
214− instance Handler StdIO IO where
214+ Handler StdIO IO where
215 handle () (PutStr s) k = do putStr s; k () ()
215 handle () (PutStr s) k = do putStr s; k () ()
216 handle () GetStr k = do x <- getLine; k x ()
216 handle () GetStr k = do x <- getLine; k x ()
217 handle () (PutCh c) k = do putChar c; k () ()
217 handle () (PutCh c) k = do putChar c; k () ()
218 handle () GetCh k = do x <- getChar; k x ()
218 handle () GetCh k = do x <- getChar; k x ()
220− instance Handler StdIO (IOExcept a) where
220+ Handler StdIO (IOExcept a) where
221 handle () (PutStr s) k = do ioe_lift $ putStr s; k () ()
221 handle () (PutStr s) k = do ioe_lift $ putStr s; k () ()
222 handle () GetStr k = do x <- ioe_lift $ getLine; k x ()
222 handle () GetStr k = do x <- ioe_lift $ getLine; k x ()
223 handle () (PutCh c) k = do ioe_lift $ putChar c; k () ()
223 handle () (PutCh c) k = do ioe_lift $ putChar c; k () ()
@@ -241,10 +241,10 @@ error.
241 data Exception : Type -> Effect where
241 data Exception : Type -> Effect where
242 Raise : a -> sig (Exception a) b
242 Raise : a -> sig (Exception a) b
244− instance Handler (Exception a) Maybe where
244+ Handler (Exception a) Maybe where
245 handle _ (Raise e) k = Nothing
245 handle _ (Raise e) k = Nothing
247− instance Handler (Exception a) List where
247+ Handler (Exception a) List where
248 handle _ (Raise e) k = []
248 handle _ (Raise e) k = []
250 EXCEPTION : Type -> EFFECT
250 EXCEPTION : Type -> EFFECT
@@ -265,14 +265,14 @@ value.
265 data Selection : Effect where
265 data Selection : Effect where
266 Select : List a -> sig Selection a
266 Select : List a -> sig Selection a
268− instance Handler Selection Maybe where
268+ Handler Selection Maybe where
269 handle _ (Select xs) k = tryAll xs where
269 handle _ (Select xs) k = tryAll xs where
270 tryAll [] = Nothing
270 tryAll [] = Nothing
271 tryAll (x :: xs) = case k x () of
271 tryAll (x :: xs) = case k x () of
272 Nothing => tryAll xs
272 Nothing => tryAll xs
273 Just v => Just v
273 Just v => Just v
275− instance Handler Selection List where
275+ Handler Selection List where
276 handle r (Select xs) k = concatMap (\x => k x r) xs
276 handle r (Select xs) k = concatMap (\x => k x r) xs
278 SELECT : EFFECT
278 SELECT : EFFECT
@@ -308,7 +308,7 @@ the equivalent ``Eff`` programs.
308 WriteLine : String -> sig FileIO () (OpenFile Write)
308 WriteLine : String -> sig FileIO () (OpenFile Write)
309 EOF : sig FileIO Bool (OpenFile Read)
309 EOF : sig FileIO Bool (OpenFile Read)
311− instance Handler FileIO IO where
311+ Handler FileIO IO where
312 handle () (Open fname m) k = do h <- openFile fname m
312 handle () (Open fname m) k = do h <- openFile fname m
313 if !(validFile h)
313 if !(validFile h)
314 then k True (FH h)
314 then k True (FH h)