simple-effects 0.11.0.0 → 0.11.0.1
raw patch · 3 files changed
+10/−20 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Control.Effects.Resource: instance Control.Effects.Resource.Unexceptional (Control.Effects.RuntimeImplemented e)
Files
simple-effects.cabal view
@@ -1,5 +1,5 @@ name: simple-effects -version: 0.11.0.0 +version: 0.11.0.1 synopsis: A simple effect system that integrates with MTL description: Please see the tutorial modules homepage: https://gitlab.com/LukaHorvat/simple-effects
src/Control/Effects/Resource.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE ScopedTypeVariables, RankNTypes, TypeFamilies, MultiParamTypeClasses, LambdaCase #-} {-# LANGUAGE FlexibleContexts, InstanceSigs, NoMonomorphismRestriction, FlexibleInstances #-} -{-# LANGUAGE DataKinds, UndecidableInstances, TypeOperators, StandaloneDeriving, DeriveAnyClass #-} +{-# LANGUAGE DataKinds, UndecidableInstances, TypeOperators #-} {-# LANGUAGE ConstraintKinds #-} -- | Provides the 'Bracket' effect for handing resource acquisition and safe cleanup. module Control.Effects.Resource where @@ -16,7 +16,6 @@ import qualified Control.Monad.Trans.Writer.Lazy as LW import qualified Control.Monad.Trans.RWS.Strict as SR import qualified Control.Monad.Trans.RWS.Lazy as LR -import ListT -- | Class of transformers that don't introduce additional exit points to a computation. -- @@ -135,9 +134,7 @@ instance Unexceptional IdentityT instance Unexceptional (ReaderT r) instance Unexceptional ListT - - - +instance Unexceptional (RuntimeImplemented e) -- | A simpler version of 'bracket' that doesn't use the results of the parameters. bracket_ :: MonadEffect Bracket m => m resource -> m cleanupRes -> m result -> m result @@ -156,8 +153,8 @@ ':$$: 'Text "If you need this instance, please let me know what you think should happen." ) UnexceptionalError t = TypeError ( 'Text "The Bracket effect doesn't know about the transformer " ':<>: 'ShowType t ':$$: - 'Text "While the effect can be used with any transformer that has a RunnableTrans instance, \ - \it's dangerous to do so implicitly because the transformer might introduce an additional \ - \exit point to the computation (like IO, MaybeT, ExceptT and friends do)" ':$$: - 'Text "If you're sure that it doesn't, give it an 'Unexceptional' instance:" ':$$: - 'Text "instance Unexceptional (" ':<>: 'ShowType t ':<>: 'Text ")" ) + 'Text "While the effect can be used with any transformer that has a RunnableTrans instance, \ + \it's dangerous to do so implicitly because the transformer might introduce an additional \ + \exit point to the computation (like IO, MaybeT, ExceptT and friends do)" ':$$: + 'Text "If you're sure that it doesn't, give it an 'Unexceptional' instance:" ':$$: + 'Text "instance Unexceptional (" ':<>: 'ShowType t ':<>: 'Text ")" )
src/Control/Monad/Runnable.hs view
@@ -45,14 +45,7 @@ -- | A class of transformers that can run their effects in the underlying monad. -- --- The following laws need to hold. --- --- @ --- \\t -> do st <- 'currentTransState' --- res <- 'lift' ('runTransformer' t st) --- 'restoreTransState' res --- == 'id' --- @ +-- The following law needs to hold. -- -- @ -- f :: (forall a. m a -> m a) @@ -65,7 +58,7 @@ type TransformerResult t a :: * -- | Get the current state value. currentTransState :: Monad m => t m (TransformerState t m) - -- | If given a result, reconstruct the computation. + -- | Given a result, interpret it as a computation. This restores the state of the transformer. restoreTransState :: Monad m => TransformerResult t a -> t m a -- | Given the required state value and a computation, run the effects of the transformer -- in the underlying monad.