File tree Expand file tree Collapse file tree 3 files changed +10
-31
lines changed Expand file tree Collapse file tree 3 files changed +10
-31
lines changed Original file line number Diff line number Diff line change 143
143
144
144
### Types
145
145
146
- newtype Delay a where
147
- Delay :: Unit -> a -> Delay a
148
-
149
- type Trampoline a = Free Delay a
150
-
151
-
152
- ### Type Class Instances
153
-
154
- instance delayApplicative :: Applicative Delay
155
-
156
- instance delayApply :: Apply Delay
157
-
158
- instance delayFunctor :: Functor Delay
146
+ type Trampoline a = Free Lazy a
159
147
160
148
161
149
### Values
Original file line number Diff line number Diff line change 12
12
" dist"
13
13
],
14
14
"dependencies" : {
15
- "purescript-control" : " 0.2.1 " ,
16
- "purescript-either" : " 0.1.3 " ,
15
+ "purescript-control" : " * " ,
16
+ "purescript-either" : " * " ,
17
17
"purescript-exists" : " *" ,
18
- "purescript-transformers" : " 0.2.0"
18
+ "purescript-transformers" : " *" ,
19
+ "purescript-lazy" : " *"
19
20
}
20
21
}
Original file line number Diff line number Diff line change 1
1
module Control.Monad.Trampoline where
2
2
3
3
import Control.Monad.Free
4
+ import Data.Lazy
4
5
5
- newtype Delay a = Delay (Unit -> a )
6
-
7
- instance delayFunctor :: Functor Delay where
8
- (<$>) f (Delay g) = Delay (const (f (g unit)))
9
-
10
- instance delayApply :: Apply Delay where
11
- (<*>) (Delay f) (Delay a) = Delay (\_ -> (f unit) (a unit))
12
-
13
- instance delayApplicative :: Applicative Delay where
14
- pure a = Delay (const a)
15
-
16
- type Trampoline a = Free Delay a
6
+ type Trampoline a = Free Lazy a
17
7
18
8
done :: forall a . a -> Trampoline a
19
9
done = Pure
20
10
21
11
suspend :: forall a . Trampoline a -> Trampoline a
22
- suspend a = Free (Delay (const a))
12
+ suspend a = Free (defer (const a))
23
13
24
14
delay :: forall a . (Unit -> a ) -> Trampoline a
25
- delay a = Free (done <$> Delay a)
15
+ delay a = Free (done <$> defer a)
26
16
27
17
runTrampoline :: forall a . Trampoline a -> a
28
- runTrampoline = go (\( Delay f) -> f unit)
18
+ runTrampoline = go force
You can’t perform that action at this time.
0 commit comments