danidiaz / dep-t

Dependency injection for records-of-functions.
http://hackage.haskell.org/package/dep-t
BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

Perhaps add "withEnv" function. #4

Closed danidiaz closed 3 years ago

danidiaz commented 3 years ago

Something like:

withEnv :: forall d e m r . (LiftDep d m, MonadReader e m)  => (e -> d r) -> m r      
withEnv f = do
    e <- ask
    liftD (f e)

It could avoid repeated uses of liftD, when all of a function's effects come from the environment.

danidiaz commented 3 years ago

Added in 5b6654fa47ec08e74503ffbb600cd438e83ef6a3 as useEnv.