{-# LANGUAGE AllowAmbiguousTypes #-}
module Effectful.Labeled.Input
(
Input
, runInput
, runInputAction
, input
, inputs
, Labeled(..)
) where
import Effectful
import Effectful.Dispatch.Dynamic
import Effectful.Labeled
import Effectful.Input.Dynamic (Input(..))
import Effectful.Input.Dynamic qualified as I
runInput
:: forall label i es a
. HasCallStack
=> i
-> Eff (Labeled label (Input i) : es) a
-> Eff es a
runInput :: forall {k} (label :: k) i (es :: [(Type -> Type) -> Type -> Type])
a.
HasCallStack =>
i -> Eff (Labeled label (Input i) : es) a -> Eff es a
runInput = forall (label :: k) (e :: (Type -> Type) -> Type -> Type)
(es :: [(Type -> Type) -> Type -> Type]) a b.
HasCallStack =>
(Eff (e : es) a -> Eff es b)
-> Eff (Labeled label e : es) a -> Eff es b
forall {k} (label :: k) (e :: (Type -> Type) -> Type -> Type)
(es :: [(Type -> Type) -> Type -> Type]) a b.
HasCallStack =>
(Eff (e : es) a -> Eff es b)
-> Eff (Labeled label e : es) a -> Eff es b
runLabeled @label ((Eff (Input i : es) a -> Eff es a)
-> Eff (Labeled label (Input i) : es) a -> Eff es a)
-> (i -> Eff (Input i : es) a -> Eff es a)
-> i
-> Eff (Labeled label (Input i) : es) a
-> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> Eff (Input i : es) a -> Eff es a
forall i (es :: [(Type -> Type) -> Type -> Type]) a.
HasCallStack =>
i -> Eff (Input i : es) a -> Eff es a
I.runInput
runInputAction
:: forall label i es a
. HasCallStack
=> (HasCallStack => Eff es i)
-> Eff (Labeled label (Input i) : es) a
-> Eff es a
runInputAction :: forall {k} (label :: k) i (es :: [(Type -> Type) -> Type -> Type])
a.
HasCallStack =>
(HasCallStack => Eff es i)
-> Eff (Labeled label (Input i) : es) a -> Eff es a
runInputAction = forall (label :: k) (e :: (Type -> Type) -> Type -> Type)
(es :: [(Type -> Type) -> Type -> Type]) a b.
HasCallStack =>
(Eff (e : es) a -> Eff es b)
-> Eff (Labeled label e : es) a -> Eff es b
forall {k} (label :: k) (e :: (Type -> Type) -> Type -> Type)
(es :: [(Type -> Type) -> Type -> Type]) a b.
HasCallStack =>
(Eff (e : es) a -> Eff es b)
-> Eff (Labeled label e : es) a -> Eff es b
runLabeled @label ((Eff (Input i : es) a -> Eff es a)
-> Eff (Labeled label (Input i) : es) a -> Eff es a)
-> (Eff es i -> Eff (Input i : es) a -> Eff es a)
-> Eff es i
-> Eff (Labeled label (Input i) : es) a
-> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Eff es i -> Eff (Input i : es) a -> Eff es a
(HasCallStack => Eff es i) -> Eff (Input i : es) a -> Eff es a
forall i (es :: [(Type -> Type) -> Type -> Type]) a.
HasCallStack =>
(HasCallStack => Eff es i) -> Eff (Input i : es) a -> Eff es a
I.runInputAction
input
:: forall label i es
. (HasCallStack, Labeled label (Input i) :> es)
=> Eff es i
input :: forall {k} (label :: k) i (es :: [(Type -> Type) -> Type -> Type]).
(HasCallStack, Labeled label (Input i) :> es) =>
Eff es i
input = Labeled label (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 (Labeled label (Input i) (Eff es) i -> Eff es i)
-> Labeled label (Input i) (Eff es) i -> Eff es i
forall a b. (a -> b) -> a -> b
$ forall (label :: k) (e :: (Type -> Type) -> Type -> Type)
(a :: Type -> Type) b.
e a b -> Labeled label e a b
forall {k} (label :: k) (e :: (Type -> Type) -> Type -> Type)
(a :: Type -> Type) b.
e a b -> Labeled label e a b
Labeled @label Input i (Eff es) i
forall i (a :: Type -> Type). Input i a i
Input
inputs
:: forall label i es a
. (HasCallStack, Labeled label (Input i) :> es)
=> (i -> a)
-> Eff es a
inputs :: forall {k} (label :: k) i (es :: [(Type -> Type) -> Type -> Type])
a.
(HasCallStack, Labeled label (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
<$> forall (label :: k) i (es :: [(Type -> Type) -> Type -> Type]).
(HasCallStack, Labeled label (Input i) :> es) =>
Eff es i
forall {k} (label :: k) i (es :: [(Type -> Type) -> Type -> Type]).
(HasCallStack, Labeled label (Input i) :> es) =>
Eff es i
input @label