mirror of
https://github.com/lexi-lambda/freer-simple.git
synced 2024-12-28 08:45:17 +03:00
27 lines
625 B
Haskell
27 lines
625 B
Haskell
{-# LANGUAGE FlexibleContexts #-}
|
|
module Tests.StateRW (
|
|
testPutGetRW,
|
|
testPutGetPutGetPlusRW,
|
|
testGetStartRW
|
|
) where
|
|
|
|
import Control.Monad.Freer
|
|
import Control.Monad.Freer.StateRW
|
|
|
|
testPutGetRW :: Int -> Int -> (Int,Int)
|
|
testPutGetRW n start = run (runStateR go start)
|
|
where go = tell n >> ask
|
|
|
|
testPutGetPutGetPlusRW :: Int -> Int -> Int -> (Int,Int)
|
|
testPutGetPutGetPlusRW p1 p2 start = run (runStateR go start)
|
|
where go = do
|
|
tell p1
|
|
x <- ask
|
|
tell p2
|
|
y <- ask
|
|
return (x+y)
|
|
|
|
testGetStartRW :: Int -> (Int,Int)
|
|
testGetStartRW = run . runStateR go
|
|
where go = ask
|