@@ -81,12 +81,6 @@ resumeGosub (Gosub f) = f (\a g ->
81
81
Gosub h -> Right (h (\b i -> b unit >>= (\x -> i x >>= g)))
82
82
)
83
83
84
- unsafeLeft :: forall a b . Either a b -> a
85
- unsafeLeft (Left x) = x
86
-
87
- unsafeRight :: forall a b . Either a b -> b
88
- unsafeRight (Right x) = x
89
-
90
84
resume :: forall f a . (Functor f ) => Free f a -> Either (f (Free f a )) a
91
85
resume f = case f of
92
86
Pure x -> Right x
@@ -100,26 +94,10 @@ go fn f = case resume f of
100
94
Left l -> go fn (fn l)
101
95
Right r -> r
102
96
103
- foreign import goEffImpl
104
- " function goEffImpl(resume, isRight, fromLeft, fromRight, fn, value) {\
105
- \ return function(){\
106
- \ while (true) {\
107
- \ var r = resume(value);\
108
- \ if (isRight(r)) return fromRight(r);\
109
- \ value = fn(fromLeft(r))();\
110
- \ }\
111
- \ };\
112
- \}" :: forall e f a . Fn6
113
- (Free f a -> Either (f (Free f a )) a )
114
- (Either (f (Free f a )) a -> Boolean )
115
- (Either (f (Free f a )) a -> (f (Free f a )))
116
- (Either (f (Free f a )) a -> a )
117
- (f (Free f a ) -> Eff e (Free f a ))
118
- (Free f a )
119
- (Eff e a )
120
-
121
97
goEff :: forall e f a . (Functor f ) => (f (Free f a ) -> Eff e (Free f a )) -> Free f a -> Eff e a
122
- goEff fn f = runFn6 goEffImpl resume isRight unsafeLeft unsafeRight fn f
98
+ goEff fn f = case resume f of
99
+ Left l -> fn l >>= goEff fn
100
+ Right r -> return r
123
101
124
102
-- Note: can blow the stack!
125
103
goMC :: forall f m a . (Monad m ) => Natural f m -> FreeC f a -> m a
0 commit comments