{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs, DataKinds #-}
{-# LANGUAGE Safe #-}
module Control.Eff.Trace( Trace (..)
, trace
, runTrace
) where
import Control.Eff
data Trace v where
Trace :: String -> Trace ()
trace :: Member Trace r => String -> Eff r ()
trace = send . Trace
runTrace :: Eff '[Trace] w -> IO w
runTrace (Val x) = return x
runTrace (E u q) = case decomp u of
Right (Trace s) -> putStrLn s >> runTrace (q ^$ ())
Left _ -> error "runTrace: the impossible happened!: Union []"