{-# LANGUAGE DeriveFunctor, DeriveGeneric #-}
module Control.Effect.Trace
(
Trace(..)
, trace
, Algebra
, Effect
, Has
, run
) where
import Control.Algebra
import GHC.Generics (Generic1)
data Trace m k = Trace
{ Trace m k -> String
traceMessage :: String
, Trace m k -> m k
traceCont :: m k
}
deriving (a -> Trace m b -> Trace m a
(a -> b) -> Trace m a -> Trace m b
(forall a b. (a -> b) -> Trace m a -> Trace m b)
-> (forall a b. a -> Trace m b -> Trace m a) -> Functor (Trace m)
forall a b. a -> Trace m b -> Trace m a
forall a b. (a -> b) -> Trace m a -> Trace m b
forall (m :: * -> *) a b. Functor m => a -> Trace m b -> Trace m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> Trace m a -> Trace m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Trace m b -> Trace m a
$c<$ :: forall (m :: * -> *) a b. Functor m => a -> Trace m b -> Trace m a
fmap :: (a -> b) -> Trace m a -> Trace m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> Trace m a -> Trace m b
Functor, (forall a. Trace m a -> Rep1 (Trace m) a)
-> (forall a. Rep1 (Trace m) a -> Trace m a) -> Generic1 (Trace m)
forall a. Rep1 (Trace m) a -> Trace m a
forall a. Trace m a -> Rep1 (Trace m) a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
forall (m :: * -> *) a. Rep1 (Trace m) a -> Trace m a
forall (m :: * -> *) a. Trace m a -> Rep1 (Trace m) a
$cto1 :: forall (m :: * -> *) a. Rep1 (Trace m) a -> Trace m a
$cfrom1 :: forall (m :: * -> *) a. Trace m a -> Rep1 (Trace m) a
Generic1)
instance HFunctor Trace
instance Effect Trace
trace :: Has Trace sig m => String -> m ()
trace :: String -> m ()
trace message :: String
message = Trace m () -> m ()
forall (eff :: (* -> *) -> * -> *) (sig :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Member eff sig, Algebra sig m) =>
eff m a -> m a
send (String -> m () -> Trace m ()
forall (m :: * -> *) k. String -> m k -> Trace m k
Trace String
message (() -> m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()))