{-# LANGUAGE AllowAmbiguousTypes #-}
module Effectful.Labeled
(
Labeled(..)
, runLabeled
, labeled
) where
import Unsafe.Coerce (unsafeCoerce)
import Effectful
import Effectful.Dispatch.Static
newtype Labeled (label :: k) (e :: Effect) :: Effect where
Labeled :: forall label e m a. e m a -> Labeled label e m a
type instance DispatchOf (Labeled label e) = DispatchOf e
data instance StaticRep (Labeled label e)
runLabeled
:: forall label e es a b
. HasCallStack
=> (Eff (e : es) a -> Eff es b)
-> Eff (Labeled label e : es) a
-> Eff es b
runLabeled :: forall {k} (label :: k) (e :: Effect) (es :: [Effect]) a b.
HasCallStack =>
(Eff (e : es) a -> Eff es b)
-> Eff (Labeled label e : es) a -> Eff es b
runLabeled Eff (e : es) a -> Eff es b
runE Eff (Labeled label e : es) a
m = Eff (e : es) a -> Eff es b
runE (Eff (Labeled label e : es) a -> Eff (e : es) a
forall {k} (label :: k) (e :: Effect) (es :: [Effect]) a.
Eff (Labeled label e : es) a -> Eff (e : es) a
fromLabeled Eff (Labeled label e : es) a
m)
labeled
:: forall label e es a
. (HasCallStack, Labeled label e :> es)
=> Eff (e : es) a
-> Eff es a
labeled :: forall {k} (label :: k) (e :: Effect) (es :: [Effect]) a.
(HasCallStack, Labeled label e :> es) =>
Eff (e : es) a -> Eff es a
labeled Eff (e : es) a
m = forall (e :: Effect) (es :: [Effect]) a.
(e :> es) =>
Eff (e : es) a -> Eff es a
subsume @(Labeled label e) (Eff (e : es) a -> Eff (Labeled label e : es) a
forall {k} (e :: Effect) (es :: [Effect]) a (label :: k).
Eff (e : es) a -> Eff (Labeled label e : es) a
toLabeled Eff (e : es) a
m)
fromLabeled :: Eff (Labeled label e : es) a -> Eff (e : es) a
fromLabeled :: forall {k} (label :: k) (e :: Effect) (es :: [Effect]) a.
Eff (Labeled label e : es) a -> Eff (e : es) a
fromLabeled = Eff (Labeled label e : es) a -> Eff (e : es) a
forall a b. a -> b
unsafeCoerce
toLabeled :: Eff (e : es) a -> Eff (Labeled label e : es) a
toLabeled :: forall {k} (e :: Effect) (es :: [Effect]) a (label :: k).
Eff (e : es) a -> Eff (Labeled label e : es) a
toLabeled = Eff (e : es) a -> Eff (Labeled label e : es) a
forall a b. a -> b
unsafeCoerce