rio 0.1.13.0 → 0.1.14.0
raw patch · 4 files changed
+34/−12 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ RIO.Prelude.Simple: mkSimpleApp :: MonadIO m => LogFunc -> Maybe ProcessContext -> m SimpleApp
+ RIO.Process: lookupEnvFromContext :: (MonadReader env m, HasProcessContext env) => Text -> m (Maybe Text)
Files
- ChangeLog.md +5/−0
- rio.cabal +3/−3
- src/RIO/Prelude/Simple.hs +16/−8
- src/RIO/Process.hs +10/−1
ChangeLog.md view
@@ -1,5 +1,10 @@ # Changelog for rio +## 0.1.14.0++* Addition of `mkSimpleApp`+* Addition of `lookupEnvFromContext`+ ## 0.1.13.0 * Add `withLazyFileUtf8`
rio.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.2.+-- This file has been generated from package.yaml by hpack version 0.32.0. -- -- see: https://github.com/sol/hpack ----- hash: 8e4af889359b601656dfdc5de6e99c1ae5312558aa4768684771e5a0fb8e6a8e+-- hash: 3304dcc13a958b77f994720f0df6f7b7714d1ed441b38b6ab56b91b30164bcd2 name: rio-version: 0.1.13.0+version: 0.1.14.0 synopsis: A standard library for Haskell description: See README and Haddocks at <https://www.stackage.org/package/rio> category: Control
src/RIO/Prelude/Simple.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}--- | Provide a @SimpleApp@ datatype, for providing a basic @App@-like+-- | Provide a @`SimpleApp`@ datatype, for providing a basic @App@-like -- environment with common functionality built in. This is intended to -- make it easier to, e.g., use rio's logging and process code from -- within short scripts.@@ -7,6 +7,7 @@ -- @since 0.1.3.0 module RIO.Prelude.Simple ( SimpleApp+ , mkSimpleApp , runSimpleApp ) where @@ -31,6 +32,17 @@ instance HasProcessContext SimpleApp where processContextL = lens saProcessContext (\x y -> x { saProcessContext = y }) ++-- | Constructor for `SimpleApp`. In case when `ProcessContext` is not supplied+-- `mkDefaultProcessContext` will be used to create it.+--+-- @since 0.1.14.0+mkSimpleApp :: MonadIO m => LogFunc -> Maybe ProcessContext -> m SimpleApp+mkSimpleApp logFunc mProcessContext = do+ processContext <- maybe mkDefaultProcessContext pure mProcessContext+ pure $ SimpleApp {saLogFunc = logFunc, saProcessContext = processContext}++ -- | Run with a default configured @SimpleApp@, consisting of: -- -- * Logging to stderr@@ -45,10 +57,6 @@ runSimpleApp m = liftIO $ do verbose <- isJust <$> lookupEnv "RIO_VERBOSE" lo <- logOptionsHandle stderr verbose- pc <- mkDefaultProcessContext- withLogFunc lo $ \lf ->- let simpleApp = SimpleApp- { saLogFunc = lf- , saProcessContext = pc- }- in runRIO simpleApp m+ withLogFunc lo $ \lf -> do+ simpleApp <- mkSimpleApp lf Nothing+ runRIO simpleApp m
src/RIO/Process.hs view
@@ -44,6 +44,7 @@ , mkDefaultProcessContext , modifyEnvVars , withModifyEnvVars+ , lookupEnvFromContext , withWorkingDir -- ** Lenses , workingDirL@@ -296,6 +297,7 @@ -- is incomplete.) defaultPATHEXT = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC" + -- | Reset the executable cache. -- -- @since 0.0.3.0@@ -331,7 +333,7 @@ pc' <- mkProcessContext (f $ pcTextMap pc) return pc' { pcWorkingDir = pcWorkingDir pc } --- | Use 'modifyEnvVarMap' to create a new 'ProcessContext', and then+-- | Use 'modifyEnvVars' to create a new 'ProcessContext', and then -- use it in the provided action. -- -- @since 0.0.3.0@@ -344,6 +346,13 @@ pc <- view processContextL pc' <- modifyEnvVars pc f local (set processContextL pc') inner++-- | Look into the `ProcessContext` and return the specified environmet variable if one is+-- available.+--+-- @since 0.1.14.0+lookupEnvFromContext :: (MonadReader env m, HasProcessContext env) => Text -> m (Maybe Text)+lookupEnvFromContext envName = Map.lookup envName <$> view envVarsL -- | Set the working directory to be used by child processes. --