Created
June 30, 2016 14:33
-
-
Save hasufell/ee6d2d2c241f68295799f84307bbb35e to your computer and use it in GitHub Desktop.
freer tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE DataKinds #-} | |
module Main where | |
import Control.Monad.Freer | |
import Control.Monad.Freer.Reader | |
import Control.Monad.Freer.State | |
main :: IO () | |
main = do | |
print $ run $ flip runReader "go" $ runState (foo "blah") 4 | |
foo :: String -> Eff '[State Int, Reader String] Bool | |
foo str = do | |
v <- get | |
s <- ask | |
if s == "go" | |
then put (2 :: Int) | |
else return () | |
if v > (3 :: Int) | |
then return True | |
else return False | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment