@@ -146,7 +146,7 @@ instance FromFormKey a => FromFormKey (Product a) where parseFormKey = fmap Prod
146-- | The contents of a form, not yet URL-encoded.
146-- | The contents of a form, not yet URL-encoded.
148-- 'Form' can be URL-encoded with 'encodeForm' and URL-decoded with 'decodeForm'.
148-- 'Form' can be URL-encoded with 'encodeForm' and URL-decoded with 'decodeForm'.
149−newtype Form = Form { unForm :: Map Text [Text] }
149+newtype Form = Form { unForm :: HashMap Text [Text] }
150 deriving (Eq, Read, Generic, Monoid)
150 deriving (Eq, Read, Generic, Monoid)
152instance Show Form where
152instance Show Form where
@@ -155,8 +155,8 @@ instance Show Form where
156instance IsList Form where
156instance IsList Form where
157 type Item Form = (Text, Text)
157 type Item Form = (Text, Text)
158− fromList = Form . Map.fromListWith (flip (<>)) . fmap (\(k, v) -> (k, [v]))
158+ fromList = Form . HashMap.fromListWith (flip (<>)) . fmap (\(k, v) -> (k, [v]))
159− toList = concatMap (\(k, vs) -> map ((,) k) vs) . Map.toList . unForm
159+ toList = concatMap (\(k, vs) -> map ((,) k) vs) . HashMap.toList . unForm
161-- | Convert a value into 'Form'.
161-- | Convert a value into 'Form'.
@@ -216,7 +216,7 @@ instance ToHttpApiData v => ToForm (IntMap [v]) where
217-- | Convert a list of entries groupped by key into a 'Form'.
217-- | Convert a list of entries groupped by key into a 'Form'.
218fromEntriesByKey :: (ToFormKey k, ToHttpApiData v) => [(k, [v])] -> Form
218fromEntriesByKey :: (ToFormKey k, ToHttpApiData v) => [(k, [v])] -> Form
219−fromEntriesByKey = Form . Map.fromListWith (<>) . map (toFormKey *** map toQueryParam)
219+fromEntriesByKey = Form . HashMap.fromListWith (<>) . map (toFormKey *** map toQueryParam)
221-- | A 'Generic'-based implementation of 'toForm'.
221-- | A 'Generic'-based implementation of 'toForm'.
222-- This is used as a default implementation in 'ToForm'.
222-- This is used as a default implementation in 'ToForm'.
@@ -301,7 +301,7 @@ instance FromHttpApiData v => FromForm (IntMap [v]) where
302-- | Parse a 'Form' into a list of entries groupped by key.
302-- | Parse a 'Form' into a list of entries groupped by key.
303toEntriesByKey :: (FromFormKey k, FromHttpApiData v) => Form -> Either Text [(k, [v])]
303toEntriesByKey :: (FromFormKey k, FromHttpApiData v) => Form -> Either Text [(k, [v])]
304−toEntriesByKey = traverse parseGroup . Map.toList . unForm
304+toEntriesByKey = traverse parseGroup . HashMap.toList . unForm
306 parseGroup (k, vs) = (,) <$> parseFormKey k <*> traverse parseQueryParam vs
306 parseGroup (k, vs) = (,) <$> parseFormKey k <*> traverse parseQueryParam vs
@@ -450,7 +450,7 @@ encodeAsForm = encodeForm . toForm
450-- >>> lookupKey "name" [("name", "Oleg"), ("name", "David")]
450-- >>> lookupKey "name" [("name", "Oleg"), ("name", "David")]
451-- ["Oleg","David"]
451-- ["Oleg","David"]
452lookupKey :: Text -> Form -> [Text]
452lookupKey :: Text -> Form -> [Text]
453−lookupKey key = concat . Map.lookup key . unForm
453+lookupKey key = concat . HashMap.lookup key . unForm
455-- | Lookup a unique value for a key.
455-- | Lookup a unique value for a key.
456-- Fail if there is zero or more than one value.
456-- Fail if there is zero or more than one value.