Skip to content

Instantly share code, notes, and snippets.

@hasufell
Created June 30, 2016 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasufell/ee6d2d2c241f68295799f84307bbb35e to your computer and use it in GitHub Desktop.
Save hasufell/ee6d2d2c241f68295799f84307bbb35e to your computer and use it in GitHub Desktop.
freer tests
{-# 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