Skip to content

Commit 56c4f64

Browse files
Update tests
1 parent 1a2fe6a commit 56c4f64

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

test/Test/Control/Monad/Free/Coproduct.purs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Test.Control.Monad.Free.Coproduct where
22

33
import Prelude
44

5-
import Control.Monad.Free (Free, liftF, hoistFree, foldFree)
5+
import Control.Monad.Free (Free, hoist, interpret, lift)
66
import Data.Functor.Coproduct (Coproduct, coproduct, left, right)
77
import Effect (Effect)
88
import Effect.Console (log)
@@ -12,34 +12,34 @@ data Teletype1F a = Print1 String a
1212
type Teletype1 a = Free Teletype1F a
1313

1414
print1 :: String -> Teletype1 Unit
15-
print1 a = liftF (Print1 a unit)
15+
print1 a = lift (Print1 a unit)
1616

1717
data Teletype2F a = Print2 String a
1818

1919
type Teletype2 a = Free Teletype2F a
2020

2121
print2 :: String -> Teletype2 Unit
22-
print2 a = liftF (Print2 a unit)
22+
print2 a = lift (Print2 a unit)
2323

2424
data Teletype3F a = Print3 String a
2525

2626
type Teletype3 a = Free Teletype3F a
2727

2828
print3 :: String -> Teletype3 Unit
29-
print3 a = liftF (Print3 a unit)
29+
print3 a = lift (Print3 a unit)
3030

3131
type TF = Coproduct Teletype1F (Coproduct Teletype2F Teletype3F)
3232

3333
type T a = Free TF a
3434

3535
r :: T Unit
36-
r = hoistFree left (print1 "1")
36+
r = hoist left (print1 "1")
3737

3838
s :: T Unit
39-
s = hoistFree (right <<< left) (print2 "2")
39+
s = hoist (right <<< left) (print2 "2")
4040

4141
t :: T Unit
42-
t = hoistFree (right <<< right) (print3 "3")
42+
t = hoist (right <<< right) (print3 "3")
4343

4444
u :: T Unit
4545
u = r *> s *> t
@@ -57,7 +57,7 @@ tN :: TF ~> Effect
5757
tN = coproduct teletype1N $ coproduct teletype2N teletype3N
5858

5959
run :: T ~> Effect
60-
run = foldFree tN
60+
run = interpret tN
6161

6262
main :: Effect Unit
6363
main = run u

test/Test/Control/Monad/Free/Stratified.purs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Test.Control.Monad.Free.Stratified where
22

33
import Prelude
44

5-
import Control.Monad.Free (Free, foldFree, liftF)
5+
import Control.Monad.Free (Free, interpret, lift)
66
import Effect (Effect)
77
import Effect.Console (log)
88

@@ -14,14 +14,14 @@ data TeletypeF a
1414
type Teletype = Free TeletypeF
1515

1616
putStrLn :: String -> Teletype Unit
17-
putStrLn s = liftF $ PutStrLn s unit
17+
putStrLn s = lift $ PutStrLn s unit
1818

1919
getLine :: Teletype String
20-
getLine = liftF $ GetLine identity
20+
getLine = lift $ GetLine identity
2121

2222
-- | Interpreter for `Teletype`, producing an effectful output
2323
runTeletype :: Teletype ~> Effect
24-
runTeletype = foldFree go
24+
runTeletype = interpret go
2525
where
2626
go :: TeletypeF ~> Effect
2727
go (PutStrLn s next) = log s $> next
@@ -35,17 +35,17 @@ data InitialF a
3535
type Initial = Free InitialF
3636

3737
greet :: Initial String
38-
greet = liftF $ Greet identity
38+
greet = lift $ Greet identity
3939

4040
farewell :: Initial Unit
41-
farewell = liftF $ Farewell unit
41+
farewell = lift $ Farewell unit
4242

4343
-- | Interpreter for `Initial`, producing a `Teletype` output. `foldFree` allows
4444
-- | us to map one action in `InitialF` to multiple actions in `TeletypeF` (see
4545
-- | the `Greet` case - we're expanding one `InitialF` action into 3 `TeletypeF`
4646
-- | actions).
4747
runInitial :: Initial ~> Teletype
48-
runInitial initial = foldFree go initial
48+
runInitial initial = interpret go initial
4949
where
5050
go :: InitialF ~> Teletype
5151
go (Greet k) = do

test/Test/Control/Monad/Free/Teletype.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ module Test.Control.Monad.Free.Teletype where
22

33
import Prelude
44

5+
import Control.Monad.Free (Free, interpret, lift)
56
import Effect (Effect)
67
import Effect.Console (log)
7-
import Control.Monad.Free (Free, foldFree, liftF)
88

99
data TeletypeF a = PutStrLn String a | GetLine (String -> a)
1010

1111
type Teletype a = Free TeletypeF a
1212

1313
putStrLn :: String -> Teletype Unit
14-
putStrLn s = liftF (PutStrLn s unit)
14+
putStrLn s = lift (PutStrLn s unit)
1515

1616
getLine :: Teletype String
17-
getLine = liftF (GetLine identity)
17+
getLine = lift (GetLine identity)
1818

1919
teletypeN :: TeletypeF ~> Effect
2020
teletypeN (PutStrLn s a) = const a <$> log s
2121
teletypeN (GetLine k) = pure (k "fake input")
2222

2323
run :: Teletype ~> Effect
24-
run = foldFree teletypeN
24+
run = interpret teletypeN
2525

2626
echo :: Teletype String
2727
echo = do

0 commit comments

Comments
 (0)