module Effectful.Input.Dynamic
(
Input(..)
, runInput
, runInputAction
, input
, inputs
) where
import Effectful
import Effectful.Dispatch.Dynamic
data Input i :: Effect where
Input :: Input i m i
type instance DispatchOf (Input i) = Dynamic
runInput
:: HasCallStack
=> i
-> Eff (Input i : es) a
-> Eff es a
runInput :: forall i (es :: [(Type -> Type) -> Type -> Type]) a.
HasCallStack =>
i -> Eff (Input i : es) a -> Eff es a
runInput i
inputValue = EffectHandler_ (Input i) es -> Eff (Input i : es) a -> Eff es a
forall (e :: (Type -> Type) -> Type -> Type)
(es :: [(Type -> Type) -> Type -> Type]) a.
(HasCallStack, DispatchOf e ~ 'Dynamic) =>
EffectHandler_ e es -> Eff (e : es) a -> Eff es a
interpret_ (EffectHandler_ (Input i) es -> Eff (Input i : es) a -> Eff es a)
-> EffectHandler_ (Input i) es -> Eff (Input i : es) a -> Eff es a
forall a b. (a -> b) -> a -> b
$ \case
Input i (Eff localEs) a
Input -> a -> Eff es a
forall a. a -> Eff es a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure i
a
inputValue
runInputAction
:: forall i es a
. HasCallStack
=> (HasCallStack => Eff es i)
-> Eff (Input i : es) a
-> Eff es a
runInputAction :: forall i (es :: [(Type -> Type) -> Type -> Type]) a.
HasCallStack =>
(HasCallStack => Eff es i) -> Eff (Input i : es) a -> Eff es a
runInputAction HasCallStack => Eff es i
inputAction = EffectHandler_ (Input i) es -> Eff (Input i : es) a -> Eff es a
forall (e :: (Type -> Type) -> Type -> Type)
(es :: [(Type -> Type) -> Type -> Type]) a.
(HasCallStack, DispatchOf e ~ 'Dynamic) =>
EffectHandler_ e es -> Eff (e : es) a -> Eff es a
interpret_ (EffectHandler_ (Input i) es -> Eff (Input i : es) a -> Eff es a)
-> EffectHandler_ (Input i) es -> Eff (Input i : es) a -> Eff es a
forall a b. (a -> b) -> a -> b
$ \case
Input i (Eff localEs) a
Input -> Eff es i
Eff es a
HasCallStack => Eff es i
inputAction
input :: (HasCallStack, Input i :> es) => Eff es i
input :: forall i (es :: [(Type -> Type) -> Type -> Type]).
(HasCallStack, Input i :> es) =>
Eff es i
input = Input i (Eff es) i -> Eff es i
forall (e :: (Type -> Type) -> Type -> Type)
(es :: [(Type -> Type) -> Type -> Type]) a.
(HasCallStack, DispatchOf e ~ 'Dynamic, e :> es) =>
e (Eff es) a -> Eff es a
send Input i (Eff es) i
forall i (m :: Type -> Type). Input i m i
Input
inputs
:: (HasCallStack, Input i :> es)
=> (i -> a)
-> Eff es a
inputs :: forall i (es :: [(Type -> Type) -> Type -> Type]) a.
(HasCallStack, Input i :> es) =>
(i -> a) -> Eff es a
inputs i -> a
f = i -> a
f (i -> a) -> Eff es i -> Eff es a
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Eff es i
forall i (es :: [(Type -> Type) -> Type -> Type]).
(HasCallStack, Input i :> es) =>
Eff es i
input