Skip to content

Commit

Permalink
Remove the StateRW module, since it wasn’t very useful
Browse files Browse the repository at this point in the history
  • Loading branch information
lexi-lambda committed Dec 7, 2017
1 parent 6cf9abc commit 47b5375
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 99 deletions.
30 changes: 0 additions & 30 deletions RELEASE.md

This file was deleted.

6 changes: 0 additions & 6 deletions bench/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Control.Monad.Freer (Member, Eff, run, send)
import Control.Monad.Freer.Internal (Eff(..), decomp, qApp, tsingleton)
import Control.Monad.Freer.Error (runError, throwError)
import Control.Monad.Freer.State (get, put, runState)
import Control.Monad.Freer.StateRW (ask, tell, runStateR)

import qualified Control.Eff as EE
import qualified Control.Eff.Exception as EE
Expand All @@ -36,10 +35,6 @@ countDown :: Int -> (Int, Int)
countDown start = run (runState start go)
where go = get >>= (\n -> if n <= 0 then pure n else put (n-1) >> go)

countDownRW :: Int -> (Int, Int)
countDownRW start = run (runStateR start go)
where go = ask >>= (\n -> if n <= 0 then pure n else tell (n-1) >> go)

countDownMTL :: Int -> (Int, Int)
countDownMTL = MTL.runState go
where go = MTL.get >>= (\n -> if n <= 0 then pure n else MTL.put (n-1) >> go)
Expand Down Expand Up @@ -149,7 +144,6 @@ main =
],
bgroup "Countdown Bench" [
bench "freer.State" $ whnf countDown 10000
, bench "freer.StateRW" $ whnf countDownRW 10000
, bench "mtl.State" $ whnf countDownMTL 10000
, bench "ee.State" $ whnf countDownEE 10000
],
Expand Down
36 changes: 0 additions & 36 deletions src/Control/Monad/Freer/StateRW.hs

This file was deleted.

27 changes: 0 additions & 27 deletions tests/Tests/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Test.Tasty.QuickCheck (testProperty)

import Control.Monad.Freer (run)
import Control.Monad.Freer.State (evalState, execState, get, put, runState)
import Control.Monad.Freer.StateRW (ask, runStateR, tell)

tests :: TestTree
tests = testGroup "State tests"
Expand All @@ -15,14 +14,6 @@ tests = testGroup "State tests"
$ \p1 p2 start -> testPutGetPutGetPlus p1 p2 start == (p1 + p2, p2)
, testProperty "If only getting, start state determines outcome"
$ \start -> testGetStart start == (start, start)
, testProperty "testPutGet: State == StateRW"
$ \n -> testPutGet n 0 == testPutGetRW n 0
, testProperty "testPutGetPutGetPlus: State == StateRW"
$ \p1 p2 start ->
testPutGetPutGetPlus p1 p2 start
== testPutGetPutGetPlusRW p1 p2 start
, testProperty "testGetStart: State == StateRW"
$ \n -> testGetStart n == testGetStartRW n
, testProperty "testEvalState: evalState discards final state"
$ \n -> testEvalState n == n
, testProperty "testExecState: execState returns final state"
Expand All @@ -34,11 +25,6 @@ testPutGet n start = run $ runState start go
where
go = put n >> get

testPutGetRW :: Int -> Int -> (Int, Int)
testPutGetRW n start = run $ runStateR start go
where
go = tell n >> ask

testPutGetPutGetPlus :: Int -> Int -> Int -> (Int, Int)
testPutGetPutGetPlus p1 p2 start = run $ runState start go
where
Expand All @@ -49,22 +35,9 @@ testPutGetPutGetPlus p1 p2 start = run $ runState start go
y <- get
pure (x + y)

testPutGetPutGetPlusRW :: Int -> Int -> Int -> (Int, Int)
testPutGetPutGetPlusRW p1 p2 start = run $ runStateR start go
where
go = do
tell p1
x <- ask
tell p2
y <- ask
pure (x+y)

testGetStart :: Int -> (Int, Int)
testGetStart = run . flip runState get

testGetStartRW :: Int -> (Int, Int)
testGetStartRW = run . flip runStateR ask

testEvalState :: Int -> Int
testEvalState = run . flip evalState go
where
Expand Down

0 comments on commit 47b5375

Please sign in to comment.