From 89a1cbdbb440a339552e76a79d3a0acb000e5705 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 19 Mar 2016 17:22:12 +0100 Subject: Fix lookupDefault --- Data/ConfigManager.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Data') diff --git a/Data/ConfigManager.hs b/Data/ConfigManager.hs index edc2e93..038276e 100644 --- a/Data/ConfigManager.hs +++ b/Data/ConfigManager.hs @@ -35,6 +35,7 @@ import Control.Monad (join) import Data.Text (Text) import qualified Data.Text as T import qualified Data.HashMap.Strict as M +import Data.Maybe (fromMaybe) import qualified Data.ConfigManager.Reader as R import Data.ConfigManager.Types @@ -52,8 +53,8 @@ lookup name config = join . fmap (readMaybe . T.unpack) $ M.lookup name (hashMap -- | Lookup for the value associated to a name and return the default value if -- no binding exists with the given name. -lookupDefault :: Value -> Name -> Config -> Value -lookupDefault defaultValue name config = M.lookupDefault defaultValue name (hashMap config) +lookupDefault :: Read a => a -> Name -> Config -> a +lookupDefault defaultValue name config = fromMaybe defaultValue $ lookup name config -- $format -- -- cgit v1.2.3