New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First-order effects admit an automatic definition of handle #54
Comments
This is possible to derive with newtype FirstOrderEffect
(sig :: (Type -> Type) -> Type -> Type)
(m :: Type -> Type)
(k :: Type)
= FirstOrderEffect (sig m k)
deriving stock Functor
instance
( forall m. Functor (sig m)
, forall m n a. Coercible (sig m a) (sig n a)
)
=> HFunctor (FirstOrderEffect sig) where
hmap _ =
coerce
instance
( forall m n a. Coercible (sig m a) (sig n a)
, forall m. Functor (sig m)
)
=> Effect (FirstOrderEffect sig) where
handle state handler =
coerce . fmap (handler . (<$ state)) |
data MyEffect a b c m k = ...
deriving (HFunctor, Effect) via (FirstOrderEffect (MyEffect a b c)) |
|
Nice one! Unfortunately, the dependency on Seems like we could also do this with |
To wit,
handle state handler = coerce . fmap (handler . (<$ state))
.We should use this in the README for
Teletype
.The text was updated successfully, but these errors were encountered: