module Effectful.Output.Dynamic
(
Output(..)
, runOutputAction
, runOutputLocalArray
, runOutputLocalList
, runOutputSharedArray
, runOutputSharedList
, output
) where
import Data.Primitive.Array
import Effectful
import Effectful.Dispatch.Dynamic
import Effectful.Output.Static.Local.Array qualified as LA
import Effectful.Output.Static.Local.List qualified as LL
import Effectful.Output.Static.Shared.Array qualified as SA
import Effectful.Output.Static.Shared.List qualified as SL
data Output o :: Effect where
Output :: o -> Output o m ()
type instance DispatchOf (Output o) = Dynamic
runOutputAction
:: forall o es a
. HasCallStack
=> (HasCallStack => o -> Eff es ())
-> Eff (Output o : es) a
-> Eff es a
runOutputAction :: forall o (es :: [Effect]) a.
HasCallStack =>
(HasCallStack => o -> Eff es ())
-> Eff (Output o : es) a -> Eff es a
runOutputAction HasCallStack => o -> Eff es ()
outputAction = EffectHandler_ (Output o) es -> Eff (Output o : es) a -> Eff es a
forall (e :: Effect) (es :: [Effect]) a.
(HasCallStack, DispatchOf e ~ 'Dynamic) =>
EffectHandler_ e es -> Eff (e : es) a -> Eff es a
interpret_ (EffectHandler_ (Output o) es -> Eff (Output o : es) a -> Eff es a)
-> EffectHandler_ (Output o) es
-> Eff (Output o : es) a
-> Eff es a
forall a b. (a -> b) -> a -> b
$ \case
Output o
o -> o -> Eff es a
o -> Eff es ()
HasCallStack => o -> Eff es ()
outputAction (o -> Eff es a) -> o -> Eff es a
forall a b. (a -> b) -> a -> b
$! o
o
runOutputLocalArray :: HasCallStack => Eff (Output o : es) a -> Eff es (a, Array o)
runOutputLocalArray :: forall o (es :: [Effect]) a.
HasCallStack =>
Eff (Output o : es) a -> Eff es (a, Array o)
runOutputLocalArray = (Eff (Output o : es) a -> Eff es (a, Array o))
-> (forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a
-> Eff es (a, Array o)
forall (e :: Effect) (handlerEs :: [Effect]) a (es :: [Effect]) b.
(HasCallStack, DispatchOf e ~ 'Dynamic) =>
(Eff handlerEs a -> Eff es b)
-> EffectHandler_ e handlerEs -> Eff (e : es) a -> Eff es b
reinterpret_ Eff (Output o : es) a -> Eff es (a, Array o)
forall o (es :: [Effect]) a.
HasCallStack =>
Eff (Output o : es) a -> Eff es (a, Array o)
LA.runOutput ((forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a -> Eff es (a, Array o))
-> (forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a
-> Eff es (a, Array o)
forall a b. (a -> b) -> a -> b
$ \case
Output o
o -> o -> Eff (Output o : es) ()
forall o (es :: [Effect]).
(HasCallStack, Output o :> es) =>
o -> Eff es ()
LA.output o
o
runOutputLocalList :: HasCallStack => Eff (Output o : es) a -> Eff es (a, [o])
runOutputLocalList :: forall o (es :: [Effect]) a.
HasCallStack =>
Eff (Output o : es) a -> Eff es (a, [o])
runOutputLocalList = (Eff (Output o : es) a -> Eff es (a, [o]))
-> (forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a
-> Eff es (a, [o])
forall (e :: Effect) (handlerEs :: [Effect]) a (es :: [Effect]) b.
(HasCallStack, DispatchOf e ~ 'Dynamic) =>
(Eff handlerEs a -> Eff es b)
-> EffectHandler_ e handlerEs -> Eff (e : es) a -> Eff es b
reinterpret_ Eff (Output o : es) a -> Eff es (a, [o])
forall o (es :: [Effect]) a.
HasCallStack =>
Eff (Output o : es) a -> Eff es (a, [o])
LL.runOutput ((forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a -> Eff es (a, [o]))
-> (forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a
-> Eff es (a, [o])
forall a b. (a -> b) -> a -> b
$ \case
Output o
o -> o -> Eff (Output o : es) ()
forall o (es :: [Effect]).
(HasCallStack, Output o :> es) =>
o -> Eff es ()
LL.output o
o
runOutputSharedArray :: HasCallStack => Eff (Output o : es) a -> Eff es (a, Array o)
runOutputSharedArray :: forall o (es :: [Effect]) a.
HasCallStack =>
Eff (Output o : es) a -> Eff es (a, Array o)
runOutputSharedArray = (Eff (Output o : es) a -> Eff es (a, Array o))
-> (forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a
-> Eff es (a, Array o)
forall (e :: Effect) (handlerEs :: [Effect]) a (es :: [Effect]) b.
(HasCallStack, DispatchOf e ~ 'Dynamic) =>
(Eff handlerEs a -> Eff es b)
-> EffectHandler_ e handlerEs -> Eff (e : es) a -> Eff es b
reinterpret_ Eff (Output o : es) a -> Eff es (a, Array o)
forall o (es :: [Effect]) a.
HasCallStack =>
Eff (Output o : es) a -> Eff es (a, Array o)
SA.runOutput ((forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a -> Eff es (a, Array o))
-> (forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a
-> Eff es (a, Array o)
forall a b. (a -> b) -> a -> b
$ \case
Output o
o -> o -> Eff (Output o : es) ()
forall o (es :: [Effect]).
(HasCallStack, Output o :> es) =>
o -> Eff es ()
SA.output o
o
runOutputSharedList :: HasCallStack => Eff (Output o : es) a -> Eff es (a, [o])
runOutputSharedList :: forall o (es :: [Effect]) a.
HasCallStack =>
Eff (Output o : es) a -> Eff es (a, [o])
runOutputSharedList = (Eff (Output o : es) a -> Eff es (a, [o]))
-> (forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a
-> Eff es (a, [o])
forall (e :: Effect) (handlerEs :: [Effect]) a (es :: [Effect]) b.
(HasCallStack, DispatchOf e ~ 'Dynamic) =>
(Eff handlerEs a -> Eff es b)
-> EffectHandler_ e handlerEs -> Eff (e : es) a -> Eff es b
reinterpret_ Eff (Output o : es) a -> Eff es (a, [o])
forall o (es :: [Effect]) a.
HasCallStack =>
Eff (Output o : es) a -> Eff es (a, [o])
SL.runOutput ((forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a -> Eff es (a, [o]))
-> (forall {a} {localEs :: [Effect]}.
HasCallStack =>
Output o (Eff localEs) a -> Eff (Output o : es) a)
-> Eff (Output o : es) a
-> Eff es (a, [o])
forall a b. (a -> b) -> a -> b
$ \case
Output o
o -> o -> Eff (Output o : es) ()
forall o (es :: [Effect]).
(HasCallStack, Output o :> es) =>
o -> Eff es ()
SL.output o
o
output
:: (HasCallStack, Output o :> es)
=> o
-> Eff es ()
output :: forall o (es :: [Effect]).
(HasCallStack, Output o :> es) =>
o -> Eff es ()
output = Output o (Eff es) () -> Eff es ()
forall (e :: Effect) (es :: [Effect]) a.
(HasCallStack, DispatchOf e ~ 'Dynamic, e :> es) =>
e (Eff es) a -> Eff es a
send (Output o (Eff es) () -> Eff es ())
-> (o -> Output o (Eff es) ()) -> o -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. o -> Output o (Eff es) ()
forall o (m :: Type -> Type). o -> Output o m ()
Output