From 4fe7828e2364c5daeb70765ecfb1513b01bfb14e Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 21 May 2024 20:24:36 +0200 Subject: Config: fix OsPath values my annoyance with conferer increases. It should really, /really/ be a compile error if a thing used in the config does not have a FromConfig instance. Or at least the documentation should mention that in such cases it will simply always take the default value without telling anyone, instead of just saying "the generic instance has reasonable defaults" (well, /which/ defaults?) --- lib/Config.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Config.hs b/lib/Config.hs index ef90fc1..4c8e3fd 100644 --- a/lib/Config.hs +++ b/lib/Config.hs @@ -2,15 +2,17 @@ {-# LANGUAGE RecordWildCards #-} module Config (UffdConfig(..), ServerConfig(..), LoggingConfig(..)) where -import Conferer (DefaultConfig (configDef)) +import Conferer (DefaultConfig (configDef), fetch, + unsafeFetchKey) import Conferer.FromConfig import Conferer.FromConfig.Warp () import Data.ByteString (ByteString) import Data.Functor ((<&>)) import Data.Text (Text) +import qualified Data.Text as T import GHC.Generics (Generic) import Network.Wai.Handler.Warp (Settings) -import System.OsPath (OsPath, osp) +import System.OsPath (OsPath, encodeUtf, osp) import URI.ByteString data UffdConfig = UffdConfig @@ -39,6 +41,9 @@ data LoggingConfig = LoggingConfig instance FromConfig ServerConfig +instance FromConfig OsPath where + fromConfig = fetchFromConfigWith (encodeUtf . T.unpack) + instance DefaultConfig ServerConfig where configDef = ServerConfig { serverConfigWarp = configDef -- cgit v1.2.3