packages feed

conferer-snap 0.1.0.2 → 0.1.0.3

raw patch · 2 files changed

+7/−28 lines, 2 filesdep ~conferer

Dependency ranges changed: conferer

Files

conferer-snap.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 4e774641434d8bf9378dc67543351024816357bcdc3fe48cc17fb6abcc927345+-- hash: 142581a42462aa0dc39d95415374444454465da8b8868bfb174ff55a1d57c411  name:           conferer-snap-version:        0.1.0.2+version:        0.1.0.3 synopsis:       conferer's FromConfig instances for snap Config  description:    Library to abstract the parsing of many haskell config values from different config sources@@ -33,7 +33,7 @@   default-extensions: OverloadedStrings LambdaCase QuasiQuotes ScopedTypeVariables   build-depends:       base >=4.3 && <5-    , conferer >=0.1.0.1 && <0.2.0.0+    , conferer >=0.1.0.2 && <0.2.0.0     , snap-core >=1.0 && <2.0     , snap-server >=1.0 && <2.0     , text >=1.1 && <1.3@@ -49,7 +49,7 @@   default-extensions: OverloadedStrings LambdaCase QuasiQuotes ScopedTypeVariables   build-depends:       base >=4.3 && <5-    , conferer >=0.1.0.1 && <0.2.0.0+    , conferer >=0.1.0.2 && <0.2.0.0     , conferer-snap     , hspec     , snap-core >=1.0 && <2.0
src/Conferer/FetchFromConfig/Snap.hs view
@@ -5,22 +5,22 @@   --   -- @   -- import Conferer-  -- import Conferer.FetchFromConfig.Snap () -- from package conferer-snap+  -- import Conferer.FetchFromConfig.Snap ()   --   -- main = do   --   config <- 'defaultConfig' \"awesomeapp\"-  --   snapConfig <- 'getFromConfig' \"warp\" config+  --   snapConfig <- 'getFromConfig' \"snap\" config   -- @   --   -- * Internal utility functions   -- | These may be useful for someone but are subject to change at any point so   -- use with care-  findKeyAndApplyConfig   ) where  import Conferer.Core import Conferer.Types import Conferer.FetchFromConfig.Basics+ import Data.Either (rights) import Data.String (fromString) import Data.Text (Text, unpack)@@ -57,24 +57,3 @@       >>= findKeyAndApplyConfig config k "verbose" Snap.setVerbose       >>= findKeyAndApplyConfig config k "unix-socket" Snap.setUnixSocket       >>= findKeyAndApplyConfig config k "unix-socket-access-mode" Snap.setUnixSocketAccessMode---- | Concatenate many transformations to the config based on keys and functions------ TODO: This should probably be on @conferer@ and maybe should use a--- transformer stack to avoid so much repeated code-findKeyAndApplyConfig ::-  FetchFromConfig newvalue-  => Config -- ^ Complete config-  -> Key -- ^ Key that indicates the part of the config that we care about-  -> Key -- ^ Key that we use to find the config (usually concatenating with the-         -- other key)-  -> (newvalue -> config -> config) -- ^ Function that knows how to use the-                                    -- value to update the config-  -> Either Text config -- ^ Result of the last config updating-  -> IO (Either Text config) -- ^ Updated config-findKeyAndApplyConfig config k relativeKey f (Right customConfig) =-  fetch (k /. relativeKey) config-    >>= \case-      Left a -> return $ Right customConfig-      Right a -> return $ Right $ f a customConfig-findKeyAndApplyConfig config k relativeKey f (Left e) = return $ Left e