File tree Expand file tree Collapse file tree 3 files changed +12
-14
lines changed Expand file tree Collapse file tree 3 files changed +12
-14
lines changed Original file line number Diff line number Diff line change 1
1
# Deprecation Notice
2
2
3
3
Please note that this library has been merged into [ purescript-transformers] ( https://github.com/purescript-contrib/purescript-transformers ) .
4
-
5
- Development will be continued there.
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import Data.Either
6
6
7
7
data Free f a = Pure a
8
8
| Free (f (Free f a ))
9
- | Gosub (forall s . (forall r . ({ } -> Free f r ) -> (r -> Free f a ) -> s ) -> s )
9
+ | Gosub (forall s . (forall r . (Unit -> Free f r ) -> (r -> Free f a ) -> s ) -> s )
10
10
11
11
class MonadFree f m where
12
12
wrap :: forall a . f (m a ) -> m a
@@ -45,20 +45,20 @@ pureF a = Free (pure (Pure a))
45
45
iterM :: forall f m a . (Functor f , Monad m ) => (forall a . f (m a ) -> m a ) -> Free f a -> m a
46
46
iterM _ (Pure a) = return a
47
47
iterM k (Free f) = k $ iterM k <$> f
48
- iterM k (Gosub f) = f (\req recv -> iterM k (req {} ) >>= (iterM k <<< recv))
48
+ iterM k (Gosub f) = f (\req recv -> iterM k (req unit ) >>= (iterM k <<< recv))
49
49
50
50
-- Note: can blow the stack!
51
51
goM :: forall f m a . (Functor f , Monad m ) => (f (Free f a ) -> m (Free f a )) -> Free f a -> m a
52
52
goM k f = case resume f of
53
53
Left s -> k s >>= goM k
54
54
Right a -> return a
55
55
56
- resumeGosub :: forall f a . (Functor f ) => (forall s . (forall r . ({ } -> Free f r ) -> (r -> Free f a ) -> s ) -> s ) -> Either (f (Free f a )) (Free f a )
56
+ resumeGosub :: forall f a . (Functor f ) => (forall s . (forall r . (Unit -> Free f r ) -> (r -> Free f a ) -> s ) -> s ) -> Either (f (Free f a )) (Free f a )
57
57
resumeGosub f = f (\a g ->
58
- case a {} of
58
+ case a unit of
59
59
Pure a -> Right (g a)
60
60
Free t -> Left ((\h -> h >>= g) <$> t)
61
- Gosub h -> Right (h (\b i -> b {} >>= (\x -> i x >>= g)))
61
+ Gosub h -> Right (h (\b i -> b unit >>= (\x -> i x >>= g)))
62
62
)
63
63
64
64
foreign import resume
Original file line number Diff line number Diff line change @@ -2,27 +2,27 @@ module Control.Monad.Trampoline where
2
2
3
3
import Control.Monad.Free
4
4
5
- data Delay a = Delay ({ } -> a )
5
+ data Delay a = Delay (Unit -> a )
6
6
7
7
instance delayFunctor :: Functor Delay where
8
- (<$>) f (Delay g) = Delay (const (f (g {} )))
8
+ (<$>) f (Delay g) = Delay (const (f (g unit )))
9
9
10
10
instance delayApply :: Apply Delay where
11
- (<*>) (Delay f) (Delay a) = Delay (\{} -> (f {} ) (a {} ))
11
+ (<*>) (Delay f) (Delay a) = Delay (\_ -> (f unit ) (a unit ))
12
12
13
13
instance delayApplicative :: Applicative Delay where
14
- pure a = Delay (\{} -> a)
14
+ pure a = Delay (const a)
15
15
16
16
type Trampoline a = Free Delay a
17
17
18
18
done :: forall a . a -> Trampoline a
19
19
done = Pure
20
20
21
21
suspend :: forall a . Trampoline a -> Trampoline a
22
- suspend a = Free (Delay (\{} -> a))
22
+ suspend a = Free (Delay (const a))
23
23
24
- delay :: forall a . ({ } -> a ) -> Trampoline a
24
+ delay :: forall a . (Unit -> a ) -> Trampoline a
25
25
delay a = Free (done <$> Delay a)
26
26
27
27
runTrampoline :: forall a . Trampoline a -> a
28
- runTrampoline = go (\(Delay f) -> f {} )
28
+ runTrampoline = go (\(Delay f) -> f unit )
You can’t perform that action at this time.
0 commit comments