mirror of
https://github.com/lexi-lambda/freer-simple.git
synced 2024-12-29 17:22:05 +03:00
27 lines
619 B
Haskell
27 lines
619 B
Haskell
{-# LANGUAGE FlexibleContexts #-}
|
|
module Tests.State (
|
|
testPutGet,
|
|
testPutGetPutGetPlus,
|
|
testGetStart
|
|
) where
|
|
|
|
import Control.Monad.Freer
|
|
import Control.Monad.Freer.State
|
|
|
|
testPutGet :: Int -> Int -> (Int,Int)
|
|
testPutGet n start = run (runState go start)
|
|
where go = put n >> get >>= return
|
|
|
|
testPutGetPutGetPlus :: Int -> Int -> Int -> (Int,Int)
|
|
testPutGetPutGetPlus p1 p2 start = run (runState go start)
|
|
where go = do
|
|
put p1
|
|
x <- get
|
|
put p2
|
|
y <- get
|
|
return (x+y)
|
|
|
|
testGetStart :: Int -> (Int,Int)
|
|
testGetStart = run . runState go
|
|
where go = get >>= return
|