packages feed

include-env 0.3.0.0 → 0.4.0.0

raw patch · 3 files changed

+21/−3 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ IncludeEnv.TH: includeEnvMaybe :: String -> Q Exp

Files

+ Changelog.md view
@@ -0,0 +1,3 @@+0.4.0.0++* add 'includeEnvMaybe'
include-env.cabal view
@@ -1,5 +1,5 @@ name:                include-env-version:             0.3.0.0+version:             0.4.0.0 synopsis:            Include the value of an environment variable at compile time description:         Embed secrets (e.g. API keys) inside production artifacts at compile time. homepage:            https://github.com/unfoldml/include-env@@ -11,6 +11,7 @@ category:            Development build-type:          Simple extra-source-files:  README.md+                     Changelog.md cabal-version:       >=1.10 tested-with:         GHC == 8.6.5, GHC == 8.10.4 
src/IncludeEnv/TH.hs view
@@ -19,7 +19,11 @@ @  -}-module IncludeEnv.TH (includeEnv, includeEnvLenient) where+module IncludeEnv.TH (+  includeEnv+  , includeEnvLenient+  , includeEnvMaybe+  ) where  import System.Environment (lookupEnv) @@ -51,7 +55,7 @@  -- | Like 'includeEnv' but only prints a warning if the environment variable cannot be found. ----- NB : If the lookup fails, the declared value will contain an empty string.+-- NB : If the lookup fails, the declared value will contain an _empty string_ . includeEnvLenient :: String -- ^ name of environment variable to be looked up                   -> String -- ^ name of new value                   -> Q [Dec]@@ -69,3 +73,13 @@         qpat = VarP (mkName n)         qbody = NormalB (LitE (StringL x)) +-- | Like 'includeEnv' but produces a 'Maybe String'+--+-- Use case : The program needs to be compiled against two different environments that may have different sets of environment variables. 'includeEnvMaybe' lets you account for the results of multiple such lookups at runtime.+--+-- @since 0.4.0.0+includeEnvMaybe :: String -- ^ name of environment variable to be looked up+                -> Q Exp+includeEnvMaybe e = do+  mstr <- runIO $ lookupEnv e+  [| mstr |]