From 196bbc9cb713cefc77e97dcbad028967fa68ddee Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Fri, 8 Apr 2022 14:16:26 +0200 Subject: update stack snapshot This gives us the fixes versions of cgi and multipart, as well as aeson 2 (which required some code adjustments). --- src/ImageHoster/Data.hs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/ImageHoster') diff --git a/src/ImageHoster/Data.hs b/src/ImageHoster/Data.hs index 39f14e0..1d67c35 100644 --- a/src/ImageHoster/Data.hs +++ b/src/ImageHoster/Data.hs @@ -11,15 +11,14 @@ module ImageHoster.Data , defaultSettings ) where +import Control.Arrow ((***)) import Data.Aeson import Data.Aeson.Types +import Data.Aeson.KeyMap (toList, fromList) +import Data.Aeson.Key (toString, fromString) import Data.Traversable import GHC.Generics -import qualified Data.HashMap.Strict as HM -import qualified Data.Text as T - - -- | We are dealing with seconds when talking about durations, hence the type -- alias. type Seconds = Integer @@ -65,9 +64,9 @@ instance FromJSON Settings where parseUserDict :: Value -> Parser [(String, String)] parseUserDict = withObject "users" $ \o -> - for (HM.toList o) $ \(user, pw) -> do + for (toList $ o) $ \(user, pw) -> do password <- parseJSON pw - return (T.unpack user, password) + return (toString user, password) instance ToJSON Settings where @@ -78,7 +77,7 @@ instance ToJSON Settings where ] where formatUsers :: [(String, String)] -> Object - formatUsers = HM.fromList . map (\(user, pw) -> (T.pack user, toJSON pw)) + formatUsers = fromList . map (fromString *** toJSON) -- | Return the default settings. -- cgit v1.2.3