dep-t 0.4.0.1 → 0.4.0.2
raw patch · 3 files changed
+15/−9 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +6/−6
- dep-t.cabal +1/−1
- lib/Control/Monad/Dep/Class.hs +8/−2
README.md view
@@ -73,15 +73,13 @@ were treated uniformly; if all of them had access to (some view of) the environment record. -To tackle these issues, we begin by writing the controller in a more generic -way: +To tackle these issues, we begin by giving the controller a more general signature: mkControllerIO :: (HasLogger IO e, HasRepository IO e, MonadIO m, MonadReader e m) => Int -> m String -So far only the signature has changed, but now the function can work in other -reader-like monads besides `ReaderT`. +Now the function can work in other reader-like monads besides `ReaderT`. -Let's go one step further, and abstract away the `IO`, so that function in the +Let's go one step further, and abstract away the `IO`, so that functions in the record can have effects in other monads: mkController :: (HasLogger d e, HasRepository d e, LiftDep d m, MonadReader e m) => Int -> m String @@ -91,14 +89,16 @@ liftD $ repository e x return "view" -Now both the implementation and the signature have changed: +Now both the signature and the implementation have changed: - There's a new type variable `d`, the monad in which functions taken from the environment `e` have their effects. + - `MonadIO` has been replaced by `LiftDep` from `Control.Monad.Dep.Class`, a constraint that says we can lift `d` effects into `m` (though it could still make sense to require `MonadIO m` for effects not originating in the environment). + - Uses of `liftIO` have been replaced by `liftD`. If all those constraints prove annoying to write, there's a convenient shorthand using the `MonadDep` type family:
dep-t.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0 name: dep-t -version: 0.4.0.1 +version: 0.4.0.2 synopsis: Reader-like monad transformer for dependency injection. description: Put all your functions in the environment record! Let all your functions read from the environment record! No favorites!
lib/Control/Monad/Dep/Class.hs view
@@ -49,8 +49,14 @@ -- mkController' = mkController -- :} -- --- The new code can be used as a drop-in replacement of the old one. Notice --- that in the new code effects taken from the environment record are +-- The new code can be used as a drop-in replacement of the old one: +-- +-- >>> :{ +-- mkControllerIO' :: (HasLogger IO e, HasRepository IO e) => Int -> ReaderT e IO String +-- mkControllerIO' = mkController' +-- :} +-- +-- Notice that in the new code effects taken from the environment record are -- lifted using 'liftD' instead of 'lift' or 'liftIO'. -- module Control.Monad.Dep.Class