http-api-data-0.6.1: Converting to/from HTTP API data like URL pieces, headers and query parameters.
Safe HaskellNone
LanguageHaskell2010

Web.Internal.HttpApiData

Description

Convert Haskell values to and from HTTP API data such as URL pieces, headers and query parameters.

Synopsis

Documentation

>>> :set -XOverloadedStrings
>>> import Data.Text (Text)
>>> import Data.Word (Word8)
>>> import Data.Text.Read (decimal)
>>> import Data.Time.Compat
>>> import Data.Time.Calendar.Month.Compat
>>> import Data.Time.Calendar.Quarter.Compat
>>> import Data.Version
>>> import Web.Cookie (SetCookie)
>>> data BasicAuthToken = BasicAuthToken Text deriving (Show)
>>> instance FromHttpApiData BasicAuthToken where parseHeader h = BasicAuthToken <$> parseHeaderWithPrefix "Basic " h; parseQueryParam p = BasicAuthToken <$> parseQueryParam p

class ToHttpApiData a where Source #

Convert value to HTTP API data.

WARNING: Do not derive this using DeriveAnyClass as the generated instance will loop indefinitely.

Minimal complete definition

toUrlPiece | toQueryParam

Methods

toUrlPiece :: a -> Text Source #

Convert to URL path piece.

toEncodedUrlPiece :: a -> Builder Source #

Convert to a URL path piece, making sure to encode any special chars. The default definition uses urlEncodeBuilder False but this may be overriden with a more efficient version.

toHeader :: a -> ByteString Source #

Convert to HTTP header value.

toQueryParam :: a -> Text Source #

Convert to query param value.

toEncodedQueryParam :: a -> Builder Source #

Convert to URL query param, The default definition uses urlEncodeBuilder True but this may be overriden with a more efficient version.

Since: 0.5.1

Instances

Instances details
ToHttpApiData SetCookie Source #

Note: this instance works correctly for alphanumeric name and value

>>> let Right c = parseUrlPiece "SESSID=r2t5uvjq435r4q7ib3vtdjq120" :: Either Text SetCookie
>>> toUrlPiece c
"SESSID=r2t5uvjq435r4q7ib3vtdjq120"
>>> toHeader c
"SESSID=r2t5uvjq435r4q7ib3vtdjq120"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: SetCookie -> Text Source #

toEncodedUrlPiece :: SetCookie -> Builder Source #

toHeader :: SetCookie -> ByteString Source #

toQueryParam :: SetCookie -> Text Source #

toEncodedQueryParam :: SetCookie -> Builder Source #

ToHttpApiData Void Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Void -> Text Source #

toEncodedUrlPiece :: Void -> Builder Source #

toHeader :: Void -> ByteString Source #

toQueryParam :: Void -> Text Source #

toEncodedQueryParam :: Void -> Builder Source #

ToHttpApiData All Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: All -> Text Source #

toEncodedUrlPiece :: All -> Builder Source #

toHeader :: All -> ByteString Source #

toQueryParam :: All -> Text Source #

toEncodedQueryParam :: All -> Builder Source #

ToHttpApiData Any Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Any -> Text Source #

toEncodedUrlPiece :: Any -> Builder Source #

toHeader :: Any -> ByteString Source #

toQueryParam :: Any -> Text Source #

toEncodedQueryParam :: Any -> Builder Source #

ToHttpApiData Version Source #
>>> toUrlPiece (Version [1, 2, 3] [])
"1.2.3"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Version -> Text Source #

toEncodedUrlPiece :: Version -> Builder Source #

toHeader :: Version -> ByteString Source #

toQueryParam :: Version -> Text Source #

toEncodedQueryParam :: Version -> Builder Source #

ToHttpApiData Int16 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Int16 -> Text Source #

toEncodedUrlPiece :: Int16 -> Builder Source #

toHeader :: Int16 -> ByteString Source #

toQueryParam :: Int16 -> Text Source #

toEncodedQueryParam :: Int16 -> Builder Source #

ToHttpApiData Int32 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Int32 -> Text Source #

toEncodedUrlPiece :: Int32 -> Builder Source #

toHeader :: Int32 -> ByteString Source #

toQueryParam :: Int32 -> Text Source #

toEncodedQueryParam :: Int32 -> Builder Source #

ToHttpApiData Int64 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Int64 -> Text Source #

toEncodedUrlPiece :: Int64 -> Builder Source #

toHeader :: Int64 -> ByteString Source #

toQueryParam :: Int64 -> Text Source #

toEncodedQueryParam :: Int64 -> Builder Source #

ToHttpApiData Int8 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Int8 -> Text Source #

toEncodedUrlPiece :: Int8 -> Builder Source #

toHeader :: Int8 -> ByteString Source #

toQueryParam :: Int8 -> Text Source #

toEncodedQueryParam :: Int8 -> Builder Source #

ToHttpApiData Word16 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Word16 -> Text Source #

toEncodedUrlPiece :: Word16 -> Builder Source #

toHeader :: Word16 -> ByteString Source #

toQueryParam :: Word16 -> Text Source #

toEncodedQueryParam :: Word16 -> Builder Source #

ToHttpApiData Word32 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Word32 -> Text Source #

toEncodedUrlPiece :: Word32 -> Builder Source #

toHeader :: Word32 -> ByteString Source #

toQueryParam :: Word32 -> Text Source #

toEncodedQueryParam :: Word32 -> Builder Source #

ToHttpApiData Word64 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Word64 -> Text Source #

toEncodedUrlPiece :: Word64 -> Builder Source #

toHeader :: Word64 -> ByteString Source #

toQueryParam :: Word64 -> Text Source #

toEncodedQueryParam :: Word64 -> Builder Source #

ToHttpApiData Word8 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Word8 -> Text Source #

toEncodedUrlPiece :: Word8 -> Builder Source #

toHeader :: Word8 -> ByteString Source #

toQueryParam :: Word8 -> Text Source #

toEncodedQueryParam :: Word8 -> Builder Source #

ToHttpApiData Ordering Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Ordering -> Text Source #

toEncodedUrlPiece :: Ordering -> Builder Source #

toHeader :: Ordering -> ByteString Source #

toQueryParam :: Ordering -> Text Source #

toEncodedQueryParam :: Ordering -> Builder Source #

ToHttpApiData Text Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Text -> Text Source #

toEncodedUrlPiece :: Text -> Builder Source #

toHeader :: Text -> ByteString Source #

toQueryParam :: Text -> Text Source #

toEncodedQueryParam :: Text -> Builder Source #

ToHttpApiData Text Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Text -> Text Source #

toEncodedUrlPiece :: Text -> Builder Source #

toHeader :: Text -> ByteString Source #

toQueryParam :: Text -> Text Source #

toEncodedQueryParam :: Text -> Builder Source #

ToHttpApiData Day Source #
>>> toUrlPiece (fromGregorian 2015 10 03)
"2015-10-03"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Day -> Text Source #

toEncodedUrlPiece :: Day -> Builder Source #

toHeader :: Day -> ByteString Source #

toQueryParam :: Day -> Text Source #

toEncodedQueryParam :: Day -> Builder Source #

ToHttpApiData Month Source #
>>> import Data.Time.Calendar.Month.Compat (Month (..))
>>> MkMonth 24482
2040-03
>>> toUrlPiece $ MkMonth 24482
"2040-03"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Month -> Text Source #

toEncodedUrlPiece :: Month -> Builder Source #

toHeader :: Month -> ByteString Source #

toQueryParam :: Month -> Text Source #

toEncodedQueryParam :: Month -> Builder Source #

ToHttpApiData Quarter Source #
>>> import Data.Time.Calendar.Quarter.Compat (Quarter (..))
>>> MkQuarter 8040
2010-Q1
>>> toUrlPiece $ MkQuarter 8040
"2010-q1"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Quarter -> Text Source #

toEncodedUrlPiece :: Quarter -> Builder Source #

toHeader :: Quarter -> ByteString Source #

toQueryParam :: Quarter -> Text Source #

toEncodedQueryParam :: Quarter -> Builder Source #

ToHttpApiData QuarterOfYear Source #
>>> toUrlPiece Q4
"q4"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: QuarterOfYear -> Text Source #

toEncodedUrlPiece :: QuarterOfYear -> Builder Source #

toHeader :: QuarterOfYear -> ByteString Source #

toQueryParam :: QuarterOfYear -> Text Source #

toEncodedQueryParam :: QuarterOfYear -> Builder Source #

ToHttpApiData DayOfWeek Source #
>>> toUrlPiece Monday
"monday"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: DayOfWeek -> Text Source #

toEncodedUrlPiece :: DayOfWeek -> Builder Source #

toHeader :: DayOfWeek -> ByteString Source #

toQueryParam :: DayOfWeek -> Text Source #

toEncodedQueryParam :: DayOfWeek -> Builder Source #

ToHttpApiData NominalDiffTime Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: NominalDiffTime -> Text Source #

toEncodedUrlPiece :: NominalDiffTime -> Builder Source #

toHeader :: NominalDiffTime -> ByteString Source #

toQueryParam :: NominalDiffTime -> Text Source #

toEncodedQueryParam :: NominalDiffTime -> Builder Source #

ToHttpApiData UTCTime Source #
>>> toUrlPiece $ UTCTime (fromGregorian 2015 10 03) 864.5
"2015-10-03T00:14:24.500Z"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: UTCTime -> Text Source #

toEncodedUrlPiece :: UTCTime -> Builder Source #

toHeader :: UTCTime -> ByteString Source #

toQueryParam :: UTCTime -> Text Source #

toEncodedQueryParam :: UTCTime -> Builder Source #

ToHttpApiData LocalTime Source #
>>> toUrlPiece $ LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 21.687)
"2015-10-03T14:55:21.687"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: LocalTime -> Text Source #

toEncodedUrlPiece :: LocalTime -> Builder Source #

toHeader :: LocalTime -> ByteString Source #

toQueryParam :: LocalTime -> Text Source #

toEncodedQueryParam :: LocalTime -> Builder Source #

ToHttpApiData TimeOfDay Source #
>>> toUrlPiece $ TimeOfDay 14 55 23.1
"14:55:23.100"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: TimeOfDay -> Text Source #

toEncodedUrlPiece :: TimeOfDay -> Builder Source #

toHeader :: TimeOfDay -> ByteString Source #

toQueryParam :: TimeOfDay -> Text Source #

toEncodedQueryParam :: TimeOfDay -> Builder Source #

ToHttpApiData ZonedTime Source #
>>> toUrlPiece $ ZonedTime (LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 51.001)) utc
"2015-10-03T14:55:51.001Z"
>>> toUrlPiece $ ZonedTime (LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 51.001)) (TimeZone 120 True "EET")
"2015-10-03T14:55:51.001+02:00"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: ZonedTime -> Text Source #

toEncodedUrlPiece :: ZonedTime -> Builder Source #

toHeader :: ZonedTime -> ByteString Source #

toQueryParam :: ZonedTime -> Text Source #

toEncodedQueryParam :: ZonedTime -> Builder Source #

ToHttpApiData UUID Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: UUID -> Text Source #

toEncodedUrlPiece :: UUID -> Builder Source #

toHeader :: UUID -> ByteString Source #

toQueryParam :: UUID -> Text Source #

toEncodedQueryParam :: UUID -> Builder Source #

ToHttpApiData Integer Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Integer -> Text Source #

toEncodedUrlPiece :: Integer -> Builder Source #

toHeader :: Integer -> ByteString Source #

toQueryParam :: Integer -> Text Source #

toEncodedQueryParam :: Integer -> Builder Source #

ToHttpApiData Natural Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Natural -> Text Source #

toEncodedUrlPiece :: Natural -> Builder Source #

toHeader :: Natural -> ByteString Source #

toQueryParam :: Natural -> Text Source #

toEncodedQueryParam :: Natural -> Builder Source #

ToHttpApiData String Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: String -> Text Source #

toEncodedUrlPiece :: String -> Builder Source #

toHeader :: String -> ByteString Source #

toQueryParam :: String -> Text Source #

toEncodedQueryParam :: String -> Builder Source #

ToHttpApiData () Source #
>>> toUrlPiece ()
"_"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: () -> Text Source #

toEncodedUrlPiece :: () -> Builder Source #

toHeader :: () -> ByteString Source #

toQueryParam :: () -> Text Source #

toEncodedQueryParam :: () -> Builder Source #

ToHttpApiData Bool Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Bool -> Text Source #

toEncodedUrlPiece :: Bool -> Builder Source #

toHeader :: Bool -> ByteString Source #

toQueryParam :: Bool -> Text Source #

toEncodedQueryParam :: Bool -> Builder Source #

ToHttpApiData Char Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Char -> Text Source #

toEncodedUrlPiece :: Char -> Builder Source #

toHeader :: Char -> ByteString Source #

toQueryParam :: Char -> Text Source #

toEncodedQueryParam :: Char -> Builder Source #

ToHttpApiData Double Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Double -> Text Source #

toEncodedUrlPiece :: Double -> Builder Source #

toHeader :: Double -> ByteString Source #

toQueryParam :: Double -> Text Source #

toEncodedQueryParam :: Double -> Builder Source #

ToHttpApiData Float Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Float -> Text Source #

toEncodedUrlPiece :: Float -> Builder Source #

toHeader :: Float -> ByteString Source #

toQueryParam :: Float -> Text Source #

toEncodedQueryParam :: Float -> Builder Source #

ToHttpApiData Int Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Int -> Text Source #

toEncodedUrlPiece :: Int -> Builder Source #

toHeader :: Int -> ByteString Source #

toQueryParam :: Int -> Text Source #

toEncodedQueryParam :: Int -> Builder Source #

ToHttpApiData Word Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Word -> Text Source #

toEncodedUrlPiece :: Word -> Builder Source #

toHeader :: Word -> ByteString Source #

toQueryParam :: Word -> Text Source #

toEncodedQueryParam :: Word -> Builder Source #

ToHttpApiData a => ToHttpApiData (First a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: First a -> Text Source #

toEncodedUrlPiece :: First a -> Builder Source #

toHeader :: First a -> ByteString Source #

toQueryParam :: First a -> Text Source #

toEncodedQueryParam :: First a -> Builder Source #

ToHttpApiData a => ToHttpApiData (Last a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Last a -> Text Source #

toEncodedUrlPiece :: Last a -> Builder Source #

toHeader :: Last a -> ByteString Source #

toQueryParam :: Last a -> Text Source #

toEncodedQueryParam :: Last a -> Builder Source #

ToHttpApiData a => ToHttpApiData (Max a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Max a -> Text Source #

toEncodedUrlPiece :: Max a -> Builder Source #

toHeader :: Max a -> ByteString Source #

toQueryParam :: Max a -> Text Source #

toEncodedQueryParam :: Max a -> Builder Source #

ToHttpApiData a => ToHttpApiData (Min a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Min a -> Text Source #

toEncodedUrlPiece :: Min a -> Builder Source #

toHeader :: Min a -> ByteString Source #

toQueryParam :: Min a -> Text Source #

toEncodedQueryParam :: Min a -> Builder Source #

ToHttpApiData a => ToHttpApiData (Identity a) Source #

Since: 0.4.2

Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Identity a -> Text Source #

toEncodedUrlPiece :: Identity a -> Builder Source #

toHeader :: Identity a -> ByteString Source #

toQueryParam :: Identity a -> Text Source #

toEncodedQueryParam :: Identity a -> Builder Source #

ToHttpApiData a => ToHttpApiData (First a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: First a -> Text Source #

toEncodedUrlPiece :: First a -> Builder Source #

toHeader :: First a -> ByteString Source #

toQueryParam :: First a -> Text Source #

toEncodedQueryParam :: First a -> Builder Source #

ToHttpApiData a => ToHttpApiData (Last a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Last a -> Text Source #

toEncodedUrlPiece :: Last a -> Builder Source #

toHeader :: Last a -> ByteString Source #

toQueryParam :: Last a -> Text Source #

toEncodedQueryParam :: Last a -> Builder Source #

ToHttpApiData a => ToHttpApiData (Dual a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Dual a -> Text Source #

toEncodedUrlPiece :: Dual a -> Builder Source #

toHeader :: Dual a -> ByteString Source #

toQueryParam :: Dual a -> Text Source #

toEncodedQueryParam :: Dual a -> Builder Source #

ToHttpApiData a => ToHttpApiData (Product a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Product a -> Text Source #

toEncodedUrlPiece :: Product a -> Builder Source #

toHeader :: Product a -> ByteString Source #

toQueryParam :: Product a -> Text Source #

toEncodedQueryParam :: Product a -> Builder Source #

ToHttpApiData a => ToHttpApiData (Sum a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Sum a -> Text Source #

toEncodedUrlPiece :: Sum a -> Builder Source #

toHeader :: Sum a -> ByteString Source #

toQueryParam :: Sum a -> Text Source #

toEncodedQueryParam :: Sum a -> Builder Source #

ToHttpApiData a => ToHttpApiData (Maybe a) Source #
>>> toUrlPiece (Just "Hello")
"just Hello"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Maybe a -> Text Source #

toEncodedUrlPiece :: Maybe a -> Builder Source #

toHeader :: Maybe a -> ByteString Source #

toQueryParam :: Maybe a -> Text Source #

toEncodedQueryParam :: Maybe a -> Builder Source #

HasResolution a => ToHttpApiData (Fixed a) Source #

Note: this instance is not polykinded

Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Fixed a -> Text Source #

toEncodedUrlPiece :: Fixed a -> Builder Source #

toHeader :: Fixed a -> ByteString Source #

toQueryParam :: Fixed a -> Text Source #

toEncodedQueryParam :: Fixed a -> Builder Source #

(ToHttpApiData a, ToHttpApiData b) => ToHttpApiData (Either a b) Source #
>>> toUrlPiece (Left "err" :: Either String Int)
"left err"
>>> toUrlPiece (Right 3 :: Either String Int)
"right 3"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Either a b -> Text Source #

toEncodedUrlPiece :: Either a b -> Builder Source #

toHeader :: Either a b -> ByteString Source #

toQueryParam :: Either a b -> Text Source #

toEncodedQueryParam :: Either a b -> Builder Source #

ToHttpApiData a => ToHttpApiData (Const a b) Source #

Since: 0.4.2

Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Const a b -> Text Source #

toEncodedUrlPiece :: Const a b -> Builder Source #

toHeader :: Const a b -> ByteString Source #

toQueryParam :: Const a b -> Text Source #

toEncodedQueryParam :: Const a b -> Builder Source #

ToHttpApiData a => ToHttpApiData (Tagged b a) Source #

Note: this instance is not polykinded

Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: Tagged b a -> Text Source #

toEncodedUrlPiece :: Tagged b a -> Builder Source #

toHeader :: Tagged b a -> ByteString Source #

toQueryParam :: Tagged b a -> Text Source #

toEncodedQueryParam :: Tagged b a -> Builder Source #

class FromHttpApiData a where Source #

Parse value from HTTP API data.

WARNING: Do not derive this using DeriveAnyClass as the generated instance will loop indefinitely.

Minimal complete definition

parseUrlPiece | parseQueryParam

Methods

parseUrlPiece :: Text -> Either Text a Source #

Parse URL path piece.

parseHeader :: ByteString -> Either Text a Source #

Parse HTTP header value.

parseQueryParam :: Text -> Either Text a Source #

Parse query param value.

Instances

Instances details
FromHttpApiData SetCookie Source #

Note: this instance works correctly for alphanumeric name and value

>>> parseUrlPiece "SESSID=r2t5uvjq435r4q7ib3vtdjq120" :: Either Text SetCookie
Right (SetCookie {setCookieName = "SESSID", setCookieValue = "r2t5uvjq435r4q7ib3vtdjq120", setCookiePath = Nothing, setCookieExpires = Nothing, setCookieMaxAge = Nothing, setCookieDomain = Nothing, setCookieHttpOnly = False, setCookieSecure = False, setCookieSameSite = Nothing})
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text SetCookie Source #

parseHeader :: ByteString -> Either Text SetCookie Source #

parseQueryParam :: Text -> Either Text SetCookie Source #

FromHttpApiData Void Source #

Parsing a Void value is always an error, considering Void as a data type with no constructors.

Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Void Source #

parseHeader :: ByteString -> Either Text Void Source #

parseQueryParam :: Text -> Either Text Void Source #

FromHttpApiData All Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text All Source #

parseHeader :: ByteString -> Either Text All Source #

parseQueryParam :: Text -> Either Text All Source #

FromHttpApiData Any Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Any Source #

parseHeader :: ByteString -> Either Text Any Source #

parseQueryParam :: Text -> Either Text Any Source #

FromHttpApiData Version Source #
>>> showVersion <$> parseUrlPiece "1.2.3"
Right "1.2.3"
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Version Source #

parseHeader :: ByteString -> Either Text Version Source #

parseQueryParam :: Text -> Either Text Version Source #

FromHttpApiData Int16 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Int16 Source #

parseHeader :: ByteString -> Either Text Int16 Source #

parseQueryParam :: Text -> Either Text Int16 Source #

FromHttpApiData Int32 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Int32 Source #

parseHeader :: ByteString -> Either Text Int32 Source #

parseQueryParam :: Text -> Either Text Int32 Source #

FromHttpApiData Int64 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Int64 Source #

parseHeader :: ByteString -> Either Text Int64 Source #

parseQueryParam :: Text -> Either Text Int64 Source #

FromHttpApiData Int8 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Int8 Source #

parseHeader :: ByteString -> Either Text Int8 Source #

parseQueryParam :: Text -> Either Text Int8 Source #

FromHttpApiData Word16 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Word16 Source #

parseHeader :: ByteString -> Either Text Word16 Source #

parseQueryParam :: Text -> Either Text Word16 Source #

FromHttpApiData Word32 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Word32 Source #

parseHeader :: ByteString -> Either Text Word32 Source #

parseQueryParam :: Text -> Either Text Word32 Source #

FromHttpApiData Word64 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Word64 Source #

parseHeader :: ByteString -> Either Text Word64 Source #

parseQueryParam :: Text -> Either Text Word64 Source #

FromHttpApiData Word8 Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Word8 Source #

parseHeader :: ByteString -> Either Text Word8 Source #

parseQueryParam :: Text -> Either Text Word8 Source #

FromHttpApiData Ordering Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Ordering Source #

parseHeader :: ByteString -> Either Text Ordering Source #

parseQueryParam :: Text -> Either Text Ordering Source #

FromHttpApiData Text Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Text Source #

parseHeader :: ByteString -> Either Text Text Source #

parseQueryParam :: Text -> Either Text Text Source #

FromHttpApiData Text Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Text Source #

parseHeader :: ByteString -> Either Text Text Source #

parseQueryParam :: Text -> Either Text Text Source #

FromHttpApiData Day Source #
>>> toGregorian <$> parseUrlPiece "2016-12-01"
Right (2016,12,1)
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Day Source #

parseHeader :: ByteString -> Either Text Day Source #

parseQueryParam :: Text -> Either Text Day Source #

FromHttpApiData Month Source #
>>> parseUrlPiece "2021-01" :: Either Text Month
Right 2021-01
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Month Source #

parseHeader :: ByteString -> Either Text Month Source #

parseQueryParam :: Text -> Either Text Month Source #

FromHttpApiData Quarter Source #
>>> parseUrlPiece "2021-q1" :: Either Text Quarter
Right 2021-Q1
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Quarter Source #

parseHeader :: ByteString -> Either Text Quarter Source #

parseQueryParam :: Text -> Either Text Quarter Source #

FromHttpApiData QuarterOfYear Source #
>>> parseUrlPiece "q2" :: Either Text QuarterOfYear
Right Q2
>>> parseUrlPiece "Q3" :: Either Text QuarterOfYear
Right Q3
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text QuarterOfYear Source #

parseHeader :: ByteString -> Either Text QuarterOfYear Source #

parseQueryParam :: Text -> Either Text QuarterOfYear Source #

FromHttpApiData DayOfWeek Source #
>>> parseUrlPiece "Monday" :: Either Text DayOfWeek
Right Monday
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text DayOfWeek Source #

parseHeader :: ByteString -> Either Text DayOfWeek Source #

parseQueryParam :: Text -> Either Text DayOfWeek Source #

FromHttpApiData NominalDiffTime Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text NominalDiffTime Source #

parseHeader :: ByteString -> Either Text NominalDiffTime Source #

parseQueryParam :: Text -> Either Text NominalDiffTime Source #

FromHttpApiData UTCTime Source #
>>> parseUrlPiece "2015-10-03T00:14:24Z" :: Either Text UTCTime
Right 2015-10-03 00:14:24 UTC
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text UTCTime Source #

parseHeader :: ByteString -> Either Text UTCTime Source #

parseQueryParam :: Text -> Either Text UTCTime Source #

FromHttpApiData LocalTime Source #
>>> parseUrlPiece "2015-10-03T14:55:01" :: Either Text LocalTime
Right 2015-10-03 14:55:01
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text LocalTime Source #

parseHeader :: ByteString -> Either Text LocalTime Source #

parseQueryParam :: Text -> Either Text LocalTime Source #

FromHttpApiData TimeOfDay Source #
>>> parseUrlPiece "14:55:01.333" :: Either Text TimeOfDay
Right 14:55:01.333
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text TimeOfDay Source #

parseHeader :: ByteString -> Either Text TimeOfDay Source #

parseQueryParam :: Text -> Either Text TimeOfDay Source #

FromHttpApiData ZonedTime Source #
>>> parseUrlPiece "2015-10-03T14:55:01+0000" :: Either Text ZonedTime
Right 2015-10-03 14:55:01 +0000
>>> parseQueryParam "2016-12-31T01:00:00Z" :: Either Text ZonedTime
Right 2016-12-31 01:00:00 +0000
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text ZonedTime Source #

parseHeader :: ByteString -> Either Text ZonedTime Source #

parseQueryParam :: Text -> Either Text ZonedTime Source #

FromHttpApiData UUID Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text UUID Source #

parseHeader :: ByteString -> Either Text UUID Source #

parseQueryParam :: Text -> Either Text UUID Source #

FromHttpApiData Integer Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Integer Source #

parseHeader :: ByteString -> Either Text Integer Source #

parseQueryParam :: Text -> Either Text Integer Source #

FromHttpApiData Natural Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Natural Source #

parseHeader :: ByteString -> Either Text Natural Source #

parseQueryParam :: Text -> Either Text Natural Source #

FromHttpApiData String Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text String Source #

parseHeader :: ByteString -> Either Text String Source #

parseQueryParam :: Text -> Either Text String Source #

FromHttpApiData () Source #
>>> parseUrlPiece "_" :: Either Text ()
Right ()
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text () Source #

parseHeader :: ByteString -> Either Text () Source #

parseQueryParam :: Text -> Either Text () Source #

FromHttpApiData Bool Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Bool Source #

parseHeader :: ByteString -> Either Text Bool Source #

parseQueryParam :: Text -> Either Text Bool Source #

FromHttpApiData Char Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Char Source #

parseHeader :: ByteString -> Either Text Char Source #

parseQueryParam :: Text -> Either Text Char Source #

FromHttpApiData Double Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Double Source #

parseHeader :: ByteString -> Either Text Double Source #

parseQueryParam :: Text -> Either Text Double Source #

FromHttpApiData Float Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Float Source #

parseHeader :: ByteString -> Either Text Float Source #

parseQueryParam :: Text -> Either Text Float Source #

FromHttpApiData Int Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Int Source #

parseHeader :: ByteString -> Either Text Int Source #

parseQueryParam :: Text -> Either Text Int Source #

FromHttpApiData Word Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text Word Source #

parseHeader :: ByteString -> Either Text Word Source #

parseQueryParam :: Text -> Either Text Word Source #

FromHttpApiData a => FromHttpApiData (First a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (First a) Source #

parseHeader :: ByteString -> Either Text (First a) Source #

parseQueryParam :: Text -> Either Text (First a) Source #

FromHttpApiData a => FromHttpApiData (Last a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Last a) Source #

parseHeader :: ByteString -> Either Text (Last a) Source #

parseQueryParam :: Text -> Either Text (Last a) Source #

FromHttpApiData a => FromHttpApiData (Max a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Max a) Source #

parseHeader :: ByteString -> Either Text (Max a) Source #

parseQueryParam :: Text -> Either Text (Max a) Source #

FromHttpApiData a => FromHttpApiData (Min a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Min a) Source #

parseHeader :: ByteString -> Either Text (Min a) Source #

parseQueryParam :: Text -> Either Text (Min a) Source #

FromHttpApiData a => FromHttpApiData (Identity a) Source #

Since: 0.4.2

Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Identity a) Source #

parseHeader :: ByteString -> Either Text (Identity a) Source #

parseQueryParam :: Text -> Either Text (Identity a) Source #

FromHttpApiData a => FromHttpApiData (First a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (First a) Source #

parseHeader :: ByteString -> Either Text (First a) Source #

parseQueryParam :: Text -> Either Text (First a) Source #

FromHttpApiData a => FromHttpApiData (Last a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Last a) Source #

parseHeader :: ByteString -> Either Text (Last a) Source #

parseQueryParam :: Text -> Either Text (Last a) Source #

FromHttpApiData a => FromHttpApiData (Dual a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Dual a) Source #

parseHeader :: ByteString -> Either Text (Dual a) Source #

parseQueryParam :: Text -> Either Text (Dual a) Source #

FromHttpApiData a => FromHttpApiData (Product a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Product a) Source #

parseHeader :: ByteString -> Either Text (Product a) Source #

parseQueryParam :: Text -> Either Text (Product a) Source #

FromHttpApiData a => FromHttpApiData (Sum a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Sum a) Source #

parseHeader :: ByteString -> Either Text (Sum a) Source #

parseQueryParam :: Text -> Either Text (Sum a) Source #

FromHttpApiData a => FromHttpApiData (LenientData a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (LenientData a) Source #

parseHeader :: ByteString -> Either Text (LenientData a) Source #

parseQueryParam :: Text -> Either Text (LenientData a) Source #

FromHttpApiData a => FromHttpApiData (Maybe a) Source #
>>> parseUrlPiece "Just 123" :: Either Text (Maybe Int)
Right (Just 123)
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Maybe a) Source #

parseHeader :: ByteString -> Either Text (Maybe a) Source #

parseQueryParam :: Text -> Either Text (Maybe a) Source #

HasResolution a => FromHttpApiData (Fixed a) Source #

Note: this instance is not polykinded

Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Fixed a) Source #

parseHeader :: ByteString -> Either Text (Fixed a) Source #

parseQueryParam :: Text -> Either Text (Fixed a) Source #

(FromHttpApiData a, FromHttpApiData b) => FromHttpApiData (Either a b) Source #
>>> parseUrlPiece "Right 123" :: Either Text (Either String Int)
Right (Right 123)
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Either a b) Source #

parseHeader :: ByteString -> Either Text (Either a b) Source #

parseQueryParam :: Text -> Either Text (Either a b) Source #

FromHttpApiData a => FromHttpApiData (Const a b) Source #

Since: 0.4.2

Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Const a b) Source #

parseHeader :: ByteString -> Either Text (Const a b) Source #

parseQueryParam :: Text -> Either Text (Const a b) Source #

FromHttpApiData a => FromHttpApiData (Tagged b a) Source #

Note: this instance is not polykinded

Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (Tagged b a) Source #

parseHeader :: ByteString -> Either Text (Tagged b a) Source #

parseQueryParam :: Text -> Either Text (Tagged b a) Source #

toUrlPieces :: (Functor t, ToHttpApiData a) => t a -> t Text Source #

Convert multiple values to a list of URL pieces.

>>> toUrlPieces [1, 2, 3] :: [Text]
["1","2","3"]

parseUrlPieces :: (Traversable t, FromHttpApiData a) => t Text -> Either Text (t a) Source #

Parse multiple URL pieces.

>>> parseUrlPieces ["true", "false"] :: Either Text [Bool]
Right [True,False]
>>> parseUrlPieces ["123", "hello", "world"] :: Either Text [Int]
Left "could not parse: `hello' (input does not start with a digit)"

toQueryParams :: (Functor t, ToHttpApiData a) => t a -> t Text Source #

Convert multiple values to a list of query parameter values.

>>> toQueryParams [fromGregorian 2015 10 03, fromGregorian 2015 12 01] :: [Text]
["2015-10-03","2015-12-01"]

parseQueryParams :: (Traversable t, FromHttpApiData a) => t Text -> Either Text (t a) Source #

Parse multiple query parameters.

>>> parseQueryParams ["1", "2", "3"] :: Either Text [Int]
Right [1,2,3]
>>> parseQueryParams ["64", "128", "256"] :: Either Text [Word8]
Left "out of bounds: `256' (should be between 0 and 255)"

parseUrlPieceMaybe :: FromHttpApiData a => Text -> Maybe a Source #

Parse URL path piece in a Maybe.

>>> parseUrlPieceMaybe "12" :: Maybe Int
Just 12

parseHeaderMaybe :: FromHttpApiData a => ByteString -> Maybe a Source #

Parse HTTP header value in a Maybe.

>>> parseHeaderMaybe "hello" :: Maybe Text
Just "hello"

parseQueryParamMaybe :: FromHttpApiData a => Text -> Maybe a Source #

Parse query param value in a Maybe.

>>> parseQueryParamMaybe "true" :: Maybe Bool
Just True

defaultParseError :: Text -> Either Text a Source #

Default parsing error.

parseMaybeTextData :: (Text -> Maybe a) -> Text -> Either Text a Source #

Convert Maybe parser into Either Text parser with default error message.

showTextData :: Show a => a -> Text Source #

Lower case.

Convert to URL piece using Show instance. The result is always lower cased.

>>> showTextData True
"true"

This can be used as a default implementation for enumeration types:

>>> data MyData = Foo | Bar | Baz deriving (Show)
>>> instance ToHttpApiData MyData where toUrlPiece = showTextData
>>> toUrlPiece Foo
"foo"

showt :: Show a => a -> Text Source #

Like show, but returns Text.

parseUrlPieceWithPrefix :: FromHttpApiData a => Text -> Text -> Either Text a Source #

Case insensitive.

Parse given text case insensitive and then parse the rest of the input using parseUrlPiece.

>>> parseUrlPieceWithPrefix "Just " "just 10" :: Either Text Int
Right 10
>>> parseUrlPieceWithPrefix "Left " "left" :: Either Text Bool
Left "could not parse: `left'"

This can be used to implement FromHttpApiData for single field constructors:

>>> data Foo = Foo Int deriving (Show)
>>> instance FromHttpApiData Foo where parseUrlPiece s = Foo <$> parseUrlPieceWithPrefix "Foo " s
>>> parseUrlPiece "foo 1" :: Either Text Foo
Right (Foo 1)

parseHeaderWithPrefix :: FromHttpApiData a => ByteString -> ByteString -> Either Text a Source #

Parse given bytestring then parse the rest of the input using parseHeader.

data BasicAuthToken = BasicAuthToken Text deriving (Show)

instance FromHttpApiData BasicAuthToken where
  parseHeader h     = BasicAuthToken <$> parseHeaderWithPrefix "Basic " h
  parseQueryParam p = BasicAuthToken <$> parseQueryParam p
>>> parseHeader "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" :: Either Text BasicAuthToken
Right (BasicAuthToken "QWxhZGRpbjpvcGVuIHNlc2FtZQ==")

parseQueryParamWithPrefix :: FromHttpApiData a => Text -> Text -> Either Text a Source #

Case insensitive.

Parse given text case insensitive and then parse the rest of the input using parseQueryParam.

>>> parseQueryParamWithPrefix "z" "z10" :: Either Text Int
Right 10

parseBoundedTextData :: (Show a, Bounded a, Enum a) => Text -> Either Text a Source #

Case insensitive.

Parse values case insensitively based on Show instance.

>>> parseBoundedTextData "true" :: Either Text Bool
Right True
>>> parseBoundedTextData "FALSE" :: Either Text Bool
Right False

This can be used as a default implementation for enumeration types:

>>> data MyData = Foo | Bar | Baz deriving (Show, Bounded, Enum)
>>> instance FromHttpApiData MyData where parseUrlPiece = parseBoundedTextData
>>> parseUrlPiece "foo" :: Either Text MyData
Right Foo

lookupBoundedEnumOf :: (Bounded a, Enum a, Eq b) => (a -> b) -> b -> Maybe a Source #

Lookup values based on a precalculated mapping of their representations.

parseBoundedEnumOf :: (Bounded a, Enum a) => (a -> Text) -> Text -> Either Text a Source #

Parse values based on a precalculated mapping of their Text representation.

>>> parseBoundedEnumOf toUrlPiece "true" :: Either Text Bool
Right True

For case insensitive parser see parseBoundedEnumOfI.

parseBoundedEnumOfI :: (Bounded a, Enum a) => (a -> Text) -> Text -> Either Text a Source #

Case insensitive.

Parse values case insensitively based on a precalculated mapping of their Text representations.

>>> parseBoundedEnumOfI toUrlPiece "FALSE" :: Either Text Bool
Right False

For case sensitive parser see parseBoundedEnumOf.

parseBoundedUrlPiece :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a Source #

Case insensitive.

Parse values case insensitively based on ToHttpApiData instance. Uses toUrlPiece to get possible values.

parseBoundedQueryParam :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a Source #

Case insensitive.

Parse values case insensitively based on ToHttpApiData instance. Uses toQueryParam to get possible values.

parseBoundedHeader :: (ToHttpApiData a, Bounded a, Enum a) => ByteString -> Either Text a Source #

Parse values based on ToHttpApiData instance. Uses toHeader to get possible values.

readTextData :: Read a => Text -> Either Text a Source #

Parse URL piece using Read instance.

Use for types which do not involve letters:

>>> readTextData "1991-06-02" :: Either Text Day
Right 1991-06-02

This parser is case sensitive and will not match showTextData in presence of letters:

>>> readTextData (showTextData True) :: Either Text Bool
Left "could not parse: `true'"

See parseBoundedTextData.

runReader :: Reader a -> Text -> Either Text a Source #

Run Reader as HTTP API data parser.

parseBounded :: (Bounded a, Integral a) => Reader Integer -> Text -> Either Text a Source #

Run Reader to parse bounded integral value with bounds checking.

>>> parseBounded decimal "256" :: Either Text Word8
Left "out of bounds: `256' (should be between 0 and 255)"

unsafeToEncodedUrlPiece :: ToHttpApiData a => a -> Builder Source #

Convert to a URL-encoded path piece using toUrlPiece. Note: this function does not check if the result contains unescaped characters! This function can be used to override toEncodedUrlPiece as a more efficient implementation when the resulting URL piece never has to be escaped.

unsafeToEncodedQueryParam :: ToHttpApiData a => a -> Builder Source #

Convert to a URL-encoded query param using toQueryParam. Note: this function does not check if the result contains unescaped characters!

Since: 0.5.1

newtype LenientData a Source #

Lenient parameters. FromHttpApiData combinators always return Right.

Since: 0.3.5

Constructors

LenientData 

Fields

Instances

Instances details
Functor LenientData Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

fmap :: (a -> b) -> LenientData a -> LenientData b

(<$) :: a -> LenientData b -> LenientData a

Foldable LenientData Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

fold :: Monoid m => LenientData m -> m

foldMap :: Monoid m => (a -> m) -> LenientData a -> m

foldMap' :: Monoid m => (a -> m) -> LenientData a -> m

foldr :: (a -> b -> b) -> b -> LenientData a -> b

foldr' :: (a -> b -> b) -> b -> LenientData a -> b

foldl :: (b -> a -> b) -> b -> LenientData a -> b

foldl' :: (b -> a -> b) -> b -> LenientData a -> b

foldr1 :: (a -> a -> a) -> LenientData a -> a

foldl1 :: (a -> a -> a) -> LenientData a -> a

toList :: LenientData a -> [a]

null :: LenientData a -> Bool

length :: LenientData a -> Int

elem :: Eq a => a -> LenientData a -> Bool

maximum :: Ord a => LenientData a -> a

minimum :: Ord a => LenientData a -> a

sum :: Num a => LenientData a -> a

product :: Num a => LenientData a -> a

Traversable LenientData Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

traverse :: Applicative f => (a -> f b) -> LenientData a -> f (LenientData b)

sequenceA :: Applicative f => LenientData (f a) -> f (LenientData a)

mapM :: Monad m => (a -> m b) -> LenientData a -> m (LenientData b)

sequence :: Monad m => LenientData (m a) -> m (LenientData a)

Data a => Data (LenientData a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LenientData a -> c (LenientData a)

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LenientData a)

toConstr :: LenientData a -> Constr

dataTypeOf :: LenientData a -> DataType

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LenientData a))

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LenientData a))

gmapT :: (forall b. Data b => b -> b) -> LenientData a -> LenientData a

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LenientData a -> r

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LenientData a -> r

gmapQ :: (forall d. Data d => d -> u) -> LenientData a -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> LenientData a -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> LenientData a -> m (LenientData a)

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LenientData a -> m (LenientData a)

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LenientData a -> m (LenientData a)

Read a => Read (LenientData a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

readsPrec :: Int -> ReadS (LenientData a)

readList :: ReadS [LenientData a]

readPrec :: ReadPrec (LenientData a)

readListPrec :: ReadPrec [LenientData a]

Show a => Show (LenientData a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

showsPrec :: Int -> LenientData a -> ShowS

show :: LenientData a -> String

showList :: [LenientData a] -> ShowS

Eq a => Eq (LenientData a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

(==) :: LenientData a -> LenientData a -> Bool

(/=) :: LenientData a -> LenientData a -> Bool

Ord a => Ord (LenientData a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

compare :: LenientData a -> LenientData a -> Ordering

(<) :: LenientData a -> LenientData a -> Bool

(<=) :: LenientData a -> LenientData a -> Bool

(>) :: LenientData a -> LenientData a -> Bool

(>=) :: LenientData a -> LenientData a -> Bool

max :: LenientData a -> LenientData a -> LenientData a

min :: LenientData a -> LenientData a -> LenientData a

FromHttpApiData a => FromHttpApiData (LenientData a) Source # 
Instance details

Defined in Web.Internal.HttpApiData

Methods

parseUrlPiece :: Text -> Either Text (LenientData a) Source #

parseHeader :: ByteString -> Either Text (LenientData a) Source #

parseQueryParam :: Text -> Either Text (LenientData a) Source #

runTT :: (a -> Builder) -> a -> Text Source #

runFT :: (Text -> Either String a) -> Text -> Either Text a Source #