@@ -49,7 +49,11 @@ import Web.HttpApiData.Internal.HttpApiData
50-- 'Form' can be URL-encoded with 'encodeForm' and URL-decoded with 'decodeForm'.
50-- 'Form' can be URL-encoded with 'encodeForm' and URL-decoded with 'decodeForm'.
51newtype Form = Form { unForm :: M.Map T.Text T.Text }
51newtype Form = Form { unForm :: M.Map T.Text T.Text }
52− deriving (Eq, Show, Read, Generic, Monoid)
52+ deriving (Eq, Read, Generic, Monoid)
54+instance Show Form where
55+ showsPrec d form = showParen (d > 10) $
56+ showString "fromList " . shows (toList form)
54instance IsList Form where
58instance IsList Form where
55 type Item Form = (T.Text, T.Text)
59 type Item Form = (T.Text, T.Text)
@@ -264,28 +268,28 @@ encodeForm xs =
265-- Key-value pairs get decoded normally:
269-- Key-value pairs get decoded normally:
267−-- >>> toList <$> decodeForm "name=Greg&lastname=Weber"
271+-- >>> decodeForm "name=Greg&lastname=Weber"
268−-- Right [("lastname","Weber"),("name","Greg")]
272+-- Right (fromList [("lastname","Weber"),("name","Greg")])
270-- Keys with no values get decoded to pairs with empty values.
274-- Keys with no values get decoded to pairs with empty values.
272−-- >>> toList <$> decodeForm "is_test"
276+-- >>> decodeForm "is_test"
273−-- Right [("is_test","")]
277+-- Right (fromList [("is_test","")])
275-- Empty keys are allowed:
279-- Empty keys are allowed:
277−-- >>> toList <$> decodeForm "=foobar"
281+-- >>> decodeForm "=foobar"
278−-- Right [("","foobar")]
282+-- Right (fromList [("","foobar")])
280-- The empty string gets decoded into an empty 'Form':
284-- The empty string gets decoded into an empty 'Form':
282−-- >>> toList <$> decodeForm ""
286+-- >>> decodeForm ""
283−-- Right []
287+-- Right (fromList [])
285-- Everything is un-escaped with 'unEscapeString':
289-- Everything is un-escaped with 'unEscapeString':
287−-- >>> toList <$> decodeForm "fullname=Andres%20L%C3%B6h"
291+-- >>> decodeForm "fullname=Andres%20L%C3%B6h"
288−-- Right [("fullname","Andres L\246h")]
292+-- Right (fromList [("fullname","Andres L\246h")])
290-- Improperly formed strings result in an error:
294-- Improperly formed strings result in an error: