@@ -49,7 +49,11 @@ import Web.HttpApiData.Internal.HttpApiData
4949--
5050-- 'Form' can be URL-encoded with 'encodeForm' and URL-decoded with 'decodeForm'.
5151newtype Form = Form { unForm :: M.Map T.Text T.Text }
52− deriving (Eq, Show, Read, Generic, Monoid)
52+ deriving (Eq, Read, Generic, Monoid)
53+
54+instance Show Form where
55+ showsPrec d form = showParen (d > 10) $
56+ showString "fromList " . shows (toList form)
5357
5458instance IsList Form where
5559 type Item Form = (T.Text, T.Text)
@@ -264,28 +268,28 @@ encodeForm xs =
264268--
265269-- Key-value pairs get decoded normally:
266270--
267−-- >>> toList <$> decodeForm "name=Greg&lastname=Weber"
268−-- Right [("lastname","Weber"),("name","Greg")]
271+-- >>> decodeForm "name=Greg&lastname=Weber"
272+-- Right (fromList [("lastname","Weber"),("name","Greg")])
269273--
270274-- Keys with no values get decoded to pairs with empty values.
271275--
272−-- >>> toList <$> decodeForm "is_test"
273−-- Right [("is_test","")]
276+-- >>> decodeForm "is_test"
277+-- Right (fromList [("is_test","")])
274278--
275279-- Empty keys are allowed:
276280--
277−-- >>> toList <$> decodeForm "=foobar"
278−-- Right [("","foobar")]
281+-- >>> decodeForm "=foobar"
282+-- Right (fromList [("","foobar")])
279283--
280284-- The empty string gets decoded into an empty 'Form':
281285--
282−-- >>> toList <$> decodeForm ""
283−-- Right []
286+-- >>> decodeForm ""
287+-- Right (fromList [])
284288--
285289-- Everything is un-escaped with 'unEscapeString':
286290--
287−-- >>> toList <$> decodeForm "fullname=Andres%20L%C3%B6h"
288−-- Right [("fullname","Andres L\246h")]
291+-- >>> decodeForm "fullname=Andres%20L%C3%B6h"
292+-- Right (fromList [("fullname","Andres L\246h")])
289293--
290294-- Improperly formed strings result in an error:
291295--