simple-effects 0.1.0.2 → 0.2.0.0
raw patch · 2 files changed
+6/−5 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Control.Effects1: EffHandling1 :: (forall a. EffectMsg1 eff a -> m (EffectRes1 eff a)) -> EffHandling1 eff m
+ Control.Effects1: EffHandling1 :: (forall a. EffectCon1 eff a => EffectMsg1 eff a -> m (EffectRes1 eff a)) -> EffHandling1 eff m
- Control.Effects1: [getHandling1] :: EffHandling1 eff m -> forall a. EffectMsg1 eff a -> m (EffectRes1 eff a)
+ Control.Effects1: [getHandling1] :: EffHandling1 eff m -> forall a. EffectCon1 eff a => EffectMsg1 eff a -> m (EffectRes1 eff a)
- Control.Effects1: effect1 :: MonadEffect1 eff m => proxy eff -> EffectMsg1 eff a -> m (EffectRes1 eff a)
+ Control.Effects1: effect1 :: (MonadEffect1 eff m, EffectCon1 eff a) => proxy eff -> EffectMsg1 eff a -> m (EffectRes1 eff a)
- Control.Effects1: handleEffect1 :: Monad m => (forall a. EffectMsg1 eff a -> m (EffectRes1 eff a)) -> EffectHandler1 eff m a -> m a
+ Control.Effects1: handleEffect1 :: Monad m => (forall a. EffectCon1 eff a => EffectMsg1 eff a -> m (EffectRes1 eff a)) -> EffectHandler1 eff m a -> m a
Files
- simple-effects.cabal +1/−1
- src/Control/Effects1.hs +5/−4
simple-effects.cabal view
@@ -1,5 +1,5 @@ name: simple-effects-version: 0.1.0.2+version: 0.2.0.0 synopsis: A simple effect system that integrates with MTL description: Please see README.md homepage: https://gitlab.com/LukaHorvat/simple-effects
src/Control/Effects1.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE TypeFamilies, MultiParamTypeClasses, FlexibleInstances, DeriveFunctor , GeneralizedNewtypeDeriving, UndecidableInstances, StandaloneDeriving - , IncoherentInstances, RankNTypes #-} + , IncoherentInstances, RankNTypes, ConstraintKinds #-} module Control.Effects1 where import Interlude @@ -11,13 +11,14 @@ type family EffectMsg1 eff :: * -> * type family EffectRes1 eff :: * -> * +type family EffectCon1 eff :: * -> Constraint class Monad m => MonadEffect1 eff m where -- | Use the effect described by 'eff'. - effect1 :: proxy eff -> EffectMsg1 eff a -> m (EffectRes1 eff a) + effect1 :: EffectCon1 eff a => proxy eff -> EffectMsg1 eff a -> m (EffectRes1 eff a) newtype EffHandling1 eff m = EffHandling1 { - getHandling1 :: forall a. EffectMsg1 eff a -> m (EffectRes1 eff a) } + getHandling1 :: forall a. EffectCon1 eff a => EffectMsg1 eff a -> m (EffectRes1 eff a) } -- | The 'EffectHandler1' is rally just a 'ReaderT' carrying around the function that knows how to -- handle the effect. @@ -47,6 +48,6 @@ effect1 _ msg = EffectHandler1 (ReaderT (($ msg) . getHandling1)) -- | Handle the effect described by 'eff'. -handleEffect1 :: Monad m => (forall a. EffectMsg1 eff a -> m (EffectRes1 eff a)) +handleEffect1 :: Monad m => (forall a. EffectCon1 eff a => EffectMsg1 eff a -> m (EffectRes1 eff a)) -> EffectHandler1 eff m a -> m a handleEffect1 f eh = runReaderT (unpackEffectHandler1 eh) (EffHandling1 f)