Hoogle Search
Within LTS Haskell 24.39 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
toFormKey :: ToFormKey k => k -> Texthttp-api-data Web.FormUrlEncoded Render a key for a Form.
unForm :: Form -> HashMap Text [Text]http-api-data Web.FormUrlEncoded No documentation available.
urlDecodeAsForm :: FromForm a => ByteString -> Either Text ahttp-api-data Web.FormUrlEncoded This is a convenience function for decoding a application/x-www-form-urlencoded ByteString directly to a datatype that has an instance of FromForm. This is effectively fromForm <=< urlDecodeForm.
>>> urlDecodeAsForm "name=Dennis&age=22" :: Either Text Person Right (Person {name = "Dennis", age = 22})urlDecodeForm :: ByteString -> Either Text Formhttp-api-data Web.FormUrlEncoded Decode an application/x-www-form-urlencoded ByteString to a Form. Key-value pairs get decoded normally:
>>> urlDecodeForm "name=Greg&lastname=Weber" Right (fromList [("lastname","Weber"),("name","Greg")])Keys with no values get decoded to pairs with empty values.>>> urlDecodeForm "is_test" Right (fromList [("is_test","")])Empty keys are allowed:>>> urlDecodeForm "=foobar" Right (fromList [("","foobar")])The empty string gets decoded into an empty Form:>>> urlDecodeForm "" Right (fromList [])
Everything is un-escaped with unEscapeString:>>> urlDecodeForm "fullname=Andres%20L%C3%B6h" Right (fromList [("fullname","Andres L\246h")])Improperly formed strings result in an error:>>> urlDecodeForm "this=has=too=many=equals" Left "not a valid pair: this=has=too=many=equals"
urlEncodeAsForm :: ToForm a => a -> ByteStringhttp-api-data Web.FormUrlEncoded This is a convenience function for encoding a datatype that has instance of ToForm directly to a application/x-www-form-urlencoded ByteString. This is effectively urlEncodeForm . toForm. _NOTE:_ this encoding is unstable and may result in different key order (but not values). For a stable encoding see urlEncodeAsFormStable.
urlEncodeAsFormStable :: ToForm a => a -> ByteStringhttp-api-data Web.FormUrlEncoded This is a convenience function for encoding a datatype that has instance of ToForm directly to a application/x-www-form-urlencoded ByteString. This is effectively urlEncodeFormStable . toForm.
>>> urlEncodeAsFormStable Person {name = "Dennis", age = 22} "age=22&name=Dennis"urlEncodeForm :: Form -> ByteStringhttp-api-data Web.FormUrlEncoded Encode a Form to an application/x-www-form-urlencoded ByteString. _NOTE:_ this encoding is unstable and may result in different key order (but not values). For a stable encoding see urlEncodeFormStable.
urlEncodeFormStable :: Form -> ByteStringhttp-api-data Web.FormUrlEncoded Encode a Form to an application/x-www-form-urlencoded ByteString. For an unstable (but faster) encoding see urlEncodeForm. Key-value pairs get encoded to key=value and separated by &:
>>> urlEncodeFormStable [("name", "Julian"), ("lastname", "Arni")] "lastname=Arni&name=Julian"Keys with empty values get encoded to just key (without the = sign):>>> urlEncodeFormStable [("is_test", "")] "is_test"Empty keys are allowed too:>>> urlEncodeFormStable [("", "foobar")] "=foobar"However, if both key and value are empty, the key-value pair is ignored. (This prevents urlDecodeForm . urlEncodeFormStable from being a true isomorphism).>>> urlEncodeFormStable [("", "")] ""Everything is escaped with escapeURIString isUnreserved:>>> urlEncodeFormStable [("fullname", "Andres Löh")] "fullname=Andres%20L%C3%B6h"-
http-api-data Web.Internal.FormUrlEncoded Parse Form into a value. An example type and instance:
data Person = Person { name :: String , age :: Int } instance FromForm Person where fromForm f = Person <$> parseUnique "name" f <*> parseUnique "age" fInstead of manually writing FromForm instances you can use a default generic implementation of fromForm. To do that, simply add deriving Generic clause to your datatype and declare a FromForm instance for your datatype without giving definition for fromForm. For instance, the previous example can be simplified into this:data Person = Person { name :: String , age :: Int } deriving (Generic) instance FromForm PersonThe default implementation of fromForm is genericFromForm. It only works for records and it will use parseQueryParam for each field's value. -
http-api-data Web.Internal.FormUrlEncoded Typeclass for types that can be parsed from keys of a Form. This is the reverse of ToFormKey.