File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ module Control.Monad.Free
8
8
, runFree
9
9
, runFreeM
10
10
, resume
11
+ , resume'
11
12
) where
12
13
13
14
import Prelude
@@ -188,9 +189,18 @@ resume
188
189
. Functor f
189
190
=> Free f a
190
191
-> Either (f (Free f a )) a
191
- resume f = case toView f of
192
- Return a -> Right a
193
- Bind g i -> Left (i <$> g)
192
+ resume = resume' (\g i -> Left (i <$> g)) Right
193
+
194
+ -- | Unwraps a single layer of `f`, providing the continuation.
195
+ resume'
196
+ :: forall f a r
197
+ . (forall b . f b -> (b -> Free f a ) -> r )
198
+ -> (a -> r )
199
+ -> Free f a
200
+ -> r
201
+ resume' k j f = case toView f of
202
+ Return a -> j a
203
+ Bind g i -> k g i
194
204
195
205
fromView :: forall f a . FreeView f a Val -> Free f a
196
206
fromView f = Free (unsafeCoerceFreeView f) empty
You can’t perform that action at this time.
0 commit comments