| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Web.Internal.HttpApiData
Description
Convert Haskell values to and from HTTP API data such as URL pieces, headers and query parameters.
Synopsis
- class ToHttpApiData a where
- toUrlPiece :: a -> Text
- toEncodedUrlPiece :: a -> Builder
- toHeader :: a -> ByteString
- toQueryParam :: a -> Text
- class FromHttpApiData a where
- parseUrlPiece :: Text -> Either Text a
- parseHeader :: ByteString -> Either Text a
- parseQueryParam :: Text -> Either Text a
- toUrlPieces :: (Functor t, ToHttpApiData a) => t a -> t Text
- parseUrlPieces :: (Traversable t, FromHttpApiData a) => t Text -> Either Text (t a)
- toQueryParams :: (Functor t, ToHttpApiData a) => t a -> t Text
- parseQueryParams :: (Traversable t, FromHttpApiData a) => t Text -> Either Text (t a)
- parseUrlPieceMaybe :: FromHttpApiData a => Text -> Maybe a
- parseHeaderMaybe :: FromHttpApiData a => ByteString -> Maybe a
- parseQueryParamMaybe :: FromHttpApiData a => Text -> Maybe a
- defaultParseError :: Text -> Either Text a
- parseMaybeTextData :: (Text -> Maybe a) -> Text -> Either Text a
- showTextData :: Show a => a -> Text
- showt :: Show a => a -> Text
- parseUrlPieceWithPrefix :: FromHttpApiData a => Text -> Text -> Either Text a
- parseHeaderWithPrefix :: FromHttpApiData a => ByteString -> ByteString -> Either Text a
- parseQueryParamWithPrefix :: FromHttpApiData a => Text -> Text -> Either Text a
- parseBoundedTextData :: (Show a, Bounded a, Enum a) => Text -> Either Text a
- lookupBoundedEnumOf :: (Bounded a, Enum a, Eq b) => (a -> b) -> b -> Maybe a
- parseBoundedEnumOf :: (Bounded a, Enum a) => (a -> Text) -> Text -> Either Text a
- parseBoundedEnumOfI :: (Bounded a, Enum a) => (a -> Text) -> Text -> Either Text a
- parseBoundedUrlPiece :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
- parseBoundedQueryParam :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a
- parseBoundedHeader :: (ToHttpApiData a, Bounded a, Enum a) => ByteString -> Either Text a
- readTextData :: Read a => Text -> Either Text a
- runReader :: Reader a -> Text -> Either Text a
- parseBounded :: forall a. (Bounded a, Integral a) => Reader Integer -> Text -> Either Text a
- unsafeToEncodedUrlPiece :: ToHttpApiData a => a -> Builder
- timeToUrlPiece :: FormatTime t => String -> t -> Text
- newtype LenientData a = LenientData {
- getLenientData :: Either Text a
- runAtto :: Parser a -> Text -> Either Text a
Documentation
>>>data BasicAuthToken = BasicAuthToken Text deriving (Show)>>>instance FromHttpApiData BasicAuthToken where parseHeader h = BasicAuthToken <$> parseHeaderWithPrefix "Basic " h; parseQueryParam p = BasicAuthToken <$> parseQueryParam p>>>import Data.Time.Compat>>>import Data.Version
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
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 encodePathSegmentsRelative,
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.
Instances
| ToHttpApiData Bool Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Bool -> Text Source # toEncodedUrlPiece :: Bool -> Builder Source # toHeader :: Bool -> ByteString Source # toQueryParam :: Bool -> Text Source # | |
| ToHttpApiData Char Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Char -> Text Source # toEncodedUrlPiece :: Char -> Builder Source # toHeader :: Char -> ByteString Source # toQueryParam :: Char -> Text Source # | |
| ToHttpApiData Double Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Double -> Text Source # toEncodedUrlPiece :: Double -> Builder Source # toHeader :: Double -> ByteString Source # toQueryParam :: Double -> Text Source # | |
| ToHttpApiData Float Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Float -> Text Source # toEncodedUrlPiece :: Float -> Builder Source # toHeader :: Float -> ByteString Source # toQueryParam :: Float -> Text Source # | |
| ToHttpApiData Int Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int -> Text Source # toEncodedUrlPiece :: Int -> Builder Source # toHeader :: Int -> ByteString Source # toQueryParam :: Int -> Text Source # | |
| ToHttpApiData Int8 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int8 -> Text Source # toEncodedUrlPiece :: Int8 -> Builder Source # toHeader :: Int8 -> ByteString Source # toQueryParam :: Int8 -> Text Source # | |
| ToHttpApiData Int16 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int16 -> Text Source # toEncodedUrlPiece :: Int16 -> Builder Source # toHeader :: Int16 -> ByteString Source # toQueryParam :: Int16 -> Text Source # | |
| ToHttpApiData Int32 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int32 -> Text Source # toEncodedUrlPiece :: Int32 -> Builder Source # toHeader :: Int32 -> ByteString Source # toQueryParam :: Int32 -> Text Source # | |
| ToHttpApiData Int64 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int64 -> Text Source # toEncodedUrlPiece :: Int64 -> Builder Source # toHeader :: Int64 -> ByteString Source # toQueryParam :: Int64 -> Text Source # | |
| ToHttpApiData Integer Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Integer -> Text Source # toEncodedUrlPiece :: Integer -> Builder Source # toHeader :: Integer -> ByteString Source # toQueryParam :: Integer -> Text Source # | |
| ToHttpApiData Natural Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Natural -> Text Source # toEncodedUrlPiece :: Natural -> Builder Source # toHeader :: Natural -> ByteString Source # toQueryParam :: Natural -> Text Source # | |
| ToHttpApiData Ordering Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Ordering -> Text Source # toEncodedUrlPiece :: Ordering -> Builder Source # toHeader :: Ordering -> ByteString Source # toQueryParam :: Ordering -> Text Source # | |
| ToHttpApiData Word Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word -> Text Source # toEncodedUrlPiece :: Word -> Builder Source # toHeader :: Word -> ByteString Source # toQueryParam :: Word -> Text Source # | |
| ToHttpApiData Word8 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word8 -> Text Source # toEncodedUrlPiece :: Word8 -> Builder Source # toHeader :: Word8 -> ByteString Source # toQueryParam :: Word8 -> Text Source # | |
| ToHttpApiData Word16 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word16 -> Text Source # toEncodedUrlPiece :: Word16 -> Builder Source # toHeader :: Word16 -> ByteString Source # toQueryParam :: Word16 -> Text Source # | |
| ToHttpApiData Word32 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word32 -> Text Source # toEncodedUrlPiece :: Word32 -> Builder Source # toHeader :: Word32 -> ByteString Source # toQueryParam :: Word32 -> Text Source # | |
| ToHttpApiData Word64 Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word64 -> Text Source # toEncodedUrlPiece :: Word64 -> Builder Source # toHeader :: Word64 -> ByteString Source # toQueryParam :: Word64 -> Text Source # | |
| ToHttpApiData () Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: () -> Text Source # toEncodedUrlPiece :: () -> Builder Source # toHeader :: () -> ByteString Source # toQueryParam :: () -> Text Source # | |
| ToHttpApiData String Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: String -> Text Source # toEncodedUrlPiece :: String -> Builder Source # toHeader :: String -> ByteString Source # toQueryParam :: String -> Text Source # | |
| ToHttpApiData Text Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Text -> Text Source # toEncodedUrlPiece :: Text -> Builder Source # toHeader :: Text -> ByteString Source # toQueryParam :: Text -> Text Source # | |
| ToHttpApiData Day Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Day -> Text Source # toEncodedUrlPiece :: Day -> Builder Source # toHeader :: Day -> ByteString Source # toQueryParam :: Day -> Text Source # | |
| ToHttpApiData LocalTime Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: LocalTime -> Text Source # toEncodedUrlPiece :: LocalTime -> Builder Source # toHeader :: LocalTime -> ByteString Source # toQueryParam :: LocalTime -> Text Source # | |
| ToHttpApiData TimeOfDay Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: TimeOfDay -> Text Source # toEncodedUrlPiece :: TimeOfDay -> Builder Source # toHeader :: TimeOfDay -> ByteString Source # toQueryParam :: TimeOfDay -> Text Source # | |
| ToHttpApiData UTCTime Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: UTCTime -> Text Source # toEncodedUrlPiece :: UTCTime -> Builder Source # toHeader :: UTCTime -> ByteString Source # toQueryParam :: UTCTime -> Text Source # | |
| ToHttpApiData ZonedTime Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: ZonedTime -> Text Source # toEncodedUrlPiece :: ZonedTime -> Builder Source # toHeader :: ZonedTime -> ByteString Source # toQueryParam :: ZonedTime -> Text Source # | |
| ToHttpApiData All Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: All -> Text Source # toEncodedUrlPiece :: All -> Builder Source # toHeader :: All -> ByteString Source # toQueryParam :: All -> Text Source # | |
| ToHttpApiData Any Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Any -> Text Source # toEncodedUrlPiece :: Any -> Builder Source # toHeader :: Any -> ByteString Source # toQueryParam :: Any -> Text Source # | |
| ToHttpApiData Version Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Version -> Text Source # toEncodedUrlPiece :: Version -> Builder Source # toHeader :: Version -> ByteString Source # toQueryParam :: Version -> Text Source # | |
| ToHttpApiData Text Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Text -> Text0 Source # toEncodedUrlPiece :: Text -> Builder Source # toHeader :: Text -> ByteString Source # toQueryParam :: Text -> Text0 Source # | |
| ToHttpApiData DayOfWeek Source # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: DayOfWeek -> Text Source # toEncodedUrlPiece :: DayOfWeek -> Builder Source # toHeader :: DayOfWeek -> ByteString Source # toQueryParam :: DayOfWeek -> Text Source # | |
| ToHttpApiData NominalDiffTime Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: NominalDiffTime -> Text Source # toEncodedUrlPiece :: NominalDiffTime -> Builder Source # toHeader :: NominalDiffTime -> ByteString Source # toQueryParam :: NominalDiffTime -> Text Source # | |
| ToHttpApiData UUID Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: UUID -> Text Source # toEncodedUrlPiece :: UUID -> Builder Source # toHeader :: UUID -> ByteString Source # toQueryParam :: UUID -> Text Source # | |
| ToHttpApiData Void Source # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Void -> Text Source # toEncodedUrlPiece :: Void -> Builder Source # toHeader :: Void -> ByteString Source # toQueryParam :: Void -> Text Source # | |
| ToHttpApiData SetCookie Source # | Note: this instance works correctly for alphanumeric name and value
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: SetCookie -> Text Source # toEncodedUrlPiece :: SetCookie -> Builder Source # toHeader :: SetCookie -> ByteString Source # toQueryParam :: SetCookie -> Text Source # | |
| ToHttpApiData a => ToHttpApiData (Maybe a) Source # |
|
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 # | |
| ToHttpApiData a => ToHttpApiData (Identity a) Source # | Since: 0.4.2 |
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 # | |
| ToHttpApiData a => ToHttpApiData (Dual a) Source # | |
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 # | |
| ToHttpApiData a => ToHttpApiData (First a) Source # | |
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 # | |
| ToHttpApiData a => ToHttpApiData (Last a) Source # | |
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 # | |
| ToHttpApiData a => ToHttpApiData (Product a) Source # | |
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 # | |
| ToHttpApiData a => ToHttpApiData (Sum a) Source # | |
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 # | |
| ToHttpApiData a => ToHttpApiData (First a) Source # | |
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 # | |
| ToHttpApiData a => ToHttpApiData (Last a) Source # | |
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 # | |
| ToHttpApiData a => ToHttpApiData (Max a) Source # | |
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 # | |
| ToHttpApiData a => ToHttpApiData (Min a) Source # | |
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 # | |
| (ToHttpApiData a, ToHttpApiData b) => ToHttpApiData (Either a b) Source # |
|
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 # | |
| HasResolution a => ToHttpApiData (Fixed a) Source # | Note: this instance is not polykinded |
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 # | |
| ToHttpApiData a => ToHttpApiData (Const a b) Source # | Since: 0.4.2 |
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 # | |
| ToHttpApiData a => ToHttpApiData (Tagged b a) Source # | Note: this instance is not polykinded |
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 # | |
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
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
| FromHttpApiData Bool Source # | |
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 # | |
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 # | |
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 # | |
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 # | |
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 Int8 Source # | |
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 Int16 Source # | |
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 # | |
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 # | |
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 Integer Source # | |
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 # | |
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 Ordering Source # | |
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 Word Source # | |
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 Word8 Source # | |
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 Word16 Source # | |
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 # | |
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 # | |
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 () Source # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text () Source # parseHeader :: ByteString -> Either Text () Source # parseQueryParam :: Text -> Either Text () Source # | |
| FromHttpApiData String Source # | |
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 Text Source # | |
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 # |
|
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 LocalTime Source # |
|
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 # |
|
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 UTCTime Source # |
|
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 ZonedTime Source # |
|
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 All Source # | |
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 # | |
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 # |
|
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 Text Source # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text0 -> Either Text0 Text Source # parseHeader :: ByteString -> Either Text0 Text Source # parseQueryParam :: Text0 -> Either Text0 Text Source # | |
| FromHttpApiData DayOfWeek Source # | |
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 # | |
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 UUID Source # | |
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 Void Source # | Parsing a |
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 SetCookie Source # | Note: this instance works correctly for alphanumeric name and value
|
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 a => FromHttpApiData (Maybe a) Source # |
|
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 # | |
| FromHttpApiData a => FromHttpApiData (Identity a) Source # | Since: 0.4.2 |
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 (Dual a) Source # | |
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 (First a) Source # | |
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 # | |
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 (Product a) Source # | |
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 # | |
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 (First a) Source # | |
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 # | |
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 # | |
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 # | |
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 (LenientData a) Source # | |
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 b) => FromHttpApiData (Either a b) Source # |
|
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 # | |
| HasResolution a => FromHttpApiData (Fixed a) Source # | Note: this instance is not polykinded |
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 (Const a b) Source # | Since: 0.4.2 |
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 |
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 IntJust 12
parseHeaderMaybe :: FromHttpApiData a => ByteString -> Maybe a Source #
Parse HTTP header value in a .Maybe
>>>parseHeaderMaybe "hello" :: Maybe TextJust "hello"
parseQueryParamMaybe :: FromHttpApiData a => Text -> Maybe a Source #
Parse query param value in a .Maybe
>>>parseQueryParamMaybe "true" :: Maybe BoolJust True
defaultParseError :: Text -> Either Text a Source #
Default parsing error.
parseMaybeTextData :: (Text -> Maybe a) -> Text -> Either Text a Source #
Convert parser into Maybe parser with default error message.Either Text
showTextData :: Show a => a -> Text Source #
Lower case.
Convert to URL piece using instance.
The result is always lower cased.Show
>>>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"
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 IntRight 10>>>parseUrlPieceWithPrefix "Left " "left" :: Either Text BoolLeft "could not parse: `left'"
This can be used to implement for single field constructors:FromHttpApiData
>>>data Foo = Foo Int deriving (Show)>>>instance FromHttpApiData Foo where parseUrlPiece s = Foo <$> parseUrlPieceWithPrefix "Foo " s>>>parseUrlPiece "foo 1" :: Either Text FooRight (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 BasicAuthTokenRight (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 IntRight 10
parseBoundedTextData :: (Show a, Bounded a, Enum a) => Text -> Either Text a Source #
Case insensitive.
Parse values case insensitively based on instance.Show
>>>parseBoundedTextData "true" :: Either Text BoolRight True>>>parseBoundedTextData "FALSE" :: Either Text BoolRight 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 MyDataRight 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 representation.Text
>>>parseBoundedEnumOf toUrlPiece "true" :: Either Text BoolRight 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 representations.Text
>>>parseBoundedEnumOfI toUrlPiece "FALSE" :: Either Text BoolRight 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 instance.
Uses ToHttpApiData to get possible values.toUrlPiece
parseBoundedQueryParam :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either Text a Source #
Case insensitive.
Parse values case insensitively based on instance.
Uses ToHttpApiData to get possible values.toQueryParam
parseBoundedHeader :: (ToHttpApiData a, Bounded a, Enum a) => ByteString -> Either Text a Source #
Parse values based on instance.
Uses ToHttpApiData to get possible values.toHeader
readTextData :: Read a => Text -> Either Text a Source #
Parse URL piece using instance.Read
Use for types which do not involve letters:
>>>readTextData "1991-06-02" :: Either Text DayRight 1991-06-02
This parser is case sensitive and will not match
in presence of letters:showTextData
>>>readTextData (showTextData True) :: Either Text BoolLeft "could not parse: `true'"
See .parseBoundedTextData
parseBounded :: forall a. (Bounded a, Integral a) => Reader Integer -> Text -> Either Text a Source #
Run to parse bounded integral value with bounds checking.Reader
>>>parseBounded decimal "256" :: Either Text Word8Left "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.
timeToUrlPiece :: FormatTime t => String -> t -> Text Source #
newtype LenientData a Source #
Lenient parameters. FromHttpApiData combinators always return Right.
Since: 0.3.5
Constructors
| LenientData | |
Fields
| |
Instances
| Functor LenientData Source # | |
Defined in Web.Internal.HttpApiData Methods fmap :: (a -> b) -> LenientData a -> LenientData b (<$) :: a -> LenientData b -> LenientData a | |
| Foldable LenientData Source # | |
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 # | |
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) | |
| Eq a => Eq (LenientData a) Source # | |
Defined in Web.Internal.HttpApiData | |
| Data a => Data (LenientData a) Source # | |
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) | |
| Ord a => Ord (LenientData a) Source # | |
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 | |
| Read a => Read (LenientData a) Source # | |
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 # | |
Defined in Web.Internal.HttpApiData Methods showsPrec :: Int -> LenientData a -> ShowS show :: LenientData a -> String showList :: [LenientData a] -> ShowS | |
| FromHttpApiData a => FromHttpApiData (LenientData a) Source # | |
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 # | |