effectful-config-file 0.1.1.0 → 0.1.1.1
raw patch · 7 files changed
+72/−23 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +2/−0
- effectful-config-file.cabal +1/−1
- src/Data/Config.hs +11/−1
- src/Data/Error/Config.hs +3/−1
- src/Effectful/Config.hs +17/−5
- src/Effectful/Config/Log.hs +21/−9
- src/Effectful/Config/Secrets.hs +17/−6
CHANGELOG.md view
@@ -1,3 +1,5 @@+## [1.1.1](https://github.com/haskell-github-trust/effectful-config-file/compare/1.1.0...1.1.1) (2026-10-25)+ ## [1.1.0](https://github.com/haskell-github-trust/effectful-config-file/compare/1.0.2...1.1.0) (2026-10-25) ### Features
effectful-config-file.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: effectful-config-file-version: 0.1.1.0+version: 0.1.1.1 synopsis: Config-file effect for effectful description: Config-file parser and utilities to use in conjunction with effectful category: Configuration
src/Data/Config.hs view
@@ -58,7 +58,11 @@ ) import Toml.Semantics.Types (Value' (..)) +-- | Class to convert raw text fetched from a source into a value.+--+-- @since 0.1.0.0 class ConfigParse a where+ -- | Parse raw text into a value. parse :: Text -> a instance ConfigParse Int where@@ -74,7 +78,10 @@ parse = id -- | Class to fetch values from different sources.+--+-- @since 0.1.0.0 class ConfigFetch a where+ -- | Resolve a value from its source, returning it in resolved form. fetch :: IOE :> es => Log :> es@@ -177,7 +184,10 @@ Literal . parse <$> getSecret k fetch v@(Literal _) = pure v --- | @since 0.1.0.0+-- | Parse the TOML table under the top-level key with the given parser.+-- Fails if the key is missing or is not a table.+--+-- @since 0.1.0.0 withSection :: Text -> ParseTable l a
src/Data/Error/Config.hs view
@@ -5,7 +5,9 @@ import Data.List (intercalate) import Toml (DecodeError, prettyDecodeError) --- | @since 0.1.0.0+-- | Errors raised while decoding a TOML configuration.+--+-- @since 0.1.0.0 newtype ConfigError = ConfigError { _ce_errors :: [DecodeError] }
src/Effectful/Config.hs view
@@ -38,17 +38,24 @@ import Toml (Result (..), decode', prettyDecodeError) import Toml.Schema.FromValue (FromValue) --- | @since 0.1.0.0+-- | Effect giving access to a shared, mutable configuration of type @c@.+--+-- @since 0.1.0.0 type Config c = Reader (MVar c) --- | @since 0.1.0.0+-- | Get the current configuration.+--+-- @since 0.1.0.0 getConfig :: IOE :> es => Config c :> es => Eff es c getConfig = ask >>= liftIO . readMVar --- | @since 0.1.0.0+-- | Fetch the value at the given lens from its source, caching the result+-- as a 'Literal' in the configuration for subsequent calls.+--+-- @since 0.1.0.0 getConfigValue :: IOE :> es => Config c :> es@@ -72,7 +79,9 @@ , "this should be impossible and is most likely a bug in your ConfigFetch instance" ] --- | @since 0.1.0.0+-- | Decode a configuration from TOML text. Warnings are ignored.+--+-- @since 0.1.0.0 readConfig :: FromValue c => Text@@ -83,7 +92,10 @@ resultToEither (Failure es) = Left (ConfigError es) resultToEither (Success _ c) = Right c --- | @since 0.1.0.0+-- | Read and decode a TOML configuration file, logging decoding warnings+-- and throwing t'ConfigError' on failure.+--+-- @since 0.1.0.0 readConfig' :: forall c es . IOE :> es
src/Effectful/Config/Log.hs view
@@ -29,14 +29,18 @@ ) import GHC.Stack (CallStack, HasCallStack, SrcLoc (..), callStack, getCallStack) --- | @since 0.1.0.0+-- | Logging effect used by the library.+--+-- @since 0.1.0.0 data Log :: Effect type instance DispatchOf Log = Static WithSideEffects newtype instance StaticRep Log = Log (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) --- | @since 0.1.0.0+-- | Run the t'Log' effect with a @monad-logger@ style logging function.+--+-- @since 0.1.0.0 runLog :: IOE :> es => (Loc -> LogSource -> LogLevel -> LogStr -> IO ())@@ -54,16 +58,24 @@ Log cb <- getStaticRep unsafeEff_ $ cb (callSiteLoc callStack) "" lvl (toLogStr msg) --- | @since 0.1.0.0+-- | Log a message at debug level.+--+-- @since 0.1.0.0 logDebug- , logWarn- :: HasCallStack- => Log :> es- => Text- -> Eff es ()+ :: HasCallStack+ => Log :> es+ => Text+ -> Eff es () logDebug = logAt LevelDebug --- | @since 0.1.0.0+-- | Log a message at warning level.+--+-- @since 0.1.0.0+logWarn+ :: HasCallStack+ => Log :> es+ => Text+ -> Eff es () logWarn = logAt LevelWarn callSiteLoc :: CallStack -> Loc
src/Effectful/Config/Secrets.hs view
@@ -17,26 +17,37 @@ import Effectful.Error.Static (Error, throwError) import GHC.Stack (HasCallStack) --- | @since 0.1.0.0+-- | Effect to look up secrets by key.+--+-- @since 0.1.0.0 data Secrets :: Effect where+ -- | Look up the secret with the given key. GetSecret :: Text -> Secrets m Text type instance DispatchOf Secrets = Dynamic --- | @since 0.1.0.0+-- | Look up the secret with the given key.+--+-- @since 0.1.0.0 getSecret :: HasCallStack => Secrets :> es => Text -> Eff es Text getSecret = send . GetSecret --- | @since 0.1.0.0+-- | Errors raised when a secret cannot be resolved.+--+-- @since 0.1.0.0 data SecretsError- = NoSecretsBackend Text- | SecretNotFound Text+ = -- | No secrets backend is configured to resolve the key.+ NoSecretsBackend Text+ | -- | The backend has no secret with this key.+ SecretNotFound Text deriving (Eq, Show) --- | @since 0.1.0.0+-- | Run 'Secrets' without a backend: every lookup throws 'NoSecretsBackend'.+--+-- @since 0.1.0.0 runSecretsError :: Error SecretsError :> es => Eff (Secrets : es) a