module Effectful.Input.Static
(
Input
, runInput
, input
, inputs
) where
import Data.Kind
import Effectful
import Effectful.Dispatch.Static
data Input (i :: Type) :: Effect
type instance DispatchOf (Input i) = Static NoSideEffects
newtype instance StaticRep (Input i) = Input i
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 = StaticRep (Input i) -> Eff (Input i : es) a -> Eff es a
forall (e :: (Type -> Type) -> Type -> Type)
(sideEffects :: SideEffects)
(es :: [(Type -> Type) -> Type -> Type]) a.
(HasCallStack, DispatchOf e ~ 'Static sideEffects,
MaybeIOE sideEffects es) =>
StaticRep e -> Eff (e : es) a -> Eff es a
evalStaticRep (StaticRep (Input i) -> Eff (Input i : es) a -> Eff es a)
-> (i -> StaticRep (Input i))
-> i
-> Eff (Input i : es) a
-> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> StaticRep (Input i)
forall i. i -> StaticRep (Input i)
Input
input :: (HasCallStack, Input i :> es) => Eff es i
input :: forall i (es :: [(Type -> Type) -> Type -> Type]).
(HasCallStack, Input i :> es) =>
Eff es i
input = do
Input i
i <- Eff es (StaticRep (Input i))
forall (e :: (Type -> Type) -> Type -> Type)
(sideEffects :: SideEffects)
(es :: [(Type -> Type) -> Type -> Type]).
(HasCallStack, DispatchOf e ~ 'Static sideEffects, e :> es) =>
Eff es (StaticRep e)
getStaticRep
i -> Eff es i
forall a. a -> Eff es a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure i
i
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