Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix strictness semantics of State and Writer #194

Merged
merged 5 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Made tests more rigorous
  • Loading branch information
KingoftheHomeless committed Jul 28, 2019
commit 47a7518b02b92de0840b212e212060622031a5dc
6 changes: 2 additions & 4 deletions test/OutputSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import Polysemy.Output
import Data.Foldable
import Test.Hspec

import Control.Exception


spec :: Spec
spec = parallel $ do
Expand All @@ -32,10 +30,10 @@ spec = parallel $ do

describe "runOutputMonoid" $
it "should be strict in the output" $
let t = run . runOutputMonoid (id @String) $ do
let t = runM . runOutputMonoid (id @String) $ do
output @String (error "strict")
return ()
in evaluate t `shouldThrow` errorCall "strict"
in t `shouldThrow` errorCall "strict"

runOutput :: Int -> Sem '[Output Int, Output [Int]] a -> ([[Int]], a)
runOutput size = run . runOutputMonoid (:[]) . runOutputBatched size
Expand Down
14 changes: 6 additions & 8 deletions test/WriterSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module WriterSpec where

import Test.Hspec

import Control.Exception (evaluate)

import Polysemy
import Polysemy.Error
import Polysemy.Writer
Expand Down Expand Up @@ -62,15 +60,15 @@ spec = describe "writer" $ do

it "should be strict in the output" $
let
t1 = run . runWriter @String $ do
t1 = runM . runWriter @String $ do
tell @String (error "strict")

t2 = run . runWriter @String $ do
t2 = runM . runWriter @String $ do
listen @String (tell @String (error "strict"))

t3 = run . runWriter @String $
t3 = runM . runWriter @String $
pass @String $ pure (\_ -> error "strict", ())
in do
evaluate t1 `shouldThrow` errorCall "strict"
evaluate t2 `shouldThrow` errorCall "strict"
evaluate t3 `shouldThrow` errorCall "strict"
t1 `shouldThrow` errorCall "strict"
t2 `shouldThrow` errorCall "strict"
t3 `shouldThrow` errorCall "strict"