Safe Haskell | Safe-Inferred |
---|---|
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
- toEncodedQueryParam :: a -> Builder
- 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
- unsafeToEncodedQueryParam :: ToHttpApiData a => a -> Builder
- newtype LenientData a = LenientData {
- getLenientData :: Either Text a
- runTT :: (a -> Builder) -> a -> Text
- runFT :: (Text -> Either String a) -> Text -> Either Text a
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 #
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 #
Convert to URL path piece.
toEncodedUrlPiece :: a -> Builder #
Convert to a URL path piece, making sure to encode any special chars.
The default definition uses
but this may be overriden with a more efficient version.urlEncodeBuilder
False
Convert to HTTP header value.
toQueryParam :: a -> Text #
Convert to query param value.
toEncodedQueryParam :: a -> Builder #
Convert to URL query param,
The default definition uses
but this may be overriden with a more efficient version.urlEncodeBuilder
True
Since: 0.5.1
Instances
ToHttpApiData All # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: All -> Text # toEncodedUrlPiece :: All -> Builder # toHeader :: All -> ByteString # toQueryParam :: All -> Text # toEncodedQueryParam :: All -> Builder # | |
ToHttpApiData Any # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Any -> Text # toEncodedUrlPiece :: Any -> Builder # toHeader :: Any -> ByteString # toQueryParam :: Any -> Text # toEncodedQueryParam :: Any -> Builder # | |
ToHttpApiData Version # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Version -> Text # toEncodedUrlPiece :: Version -> Builder # toHeader :: Version -> ByteString # toQueryParam :: Version -> Text # toEncodedQueryParam :: Version -> Builder # | |
ToHttpApiData Void # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Void -> Text # toEncodedUrlPiece :: Void -> Builder # toHeader :: Void -> ByteString # toQueryParam :: Void -> Text # toEncodedQueryParam :: Void -> Builder # | |
ToHttpApiData Int16 # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int16 -> Text # toEncodedUrlPiece :: Int16 -> Builder # toHeader :: Int16 -> ByteString # toQueryParam :: Int16 -> Text # toEncodedQueryParam :: Int16 -> Builder # | |
ToHttpApiData Int32 # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int32 -> Text # toEncodedUrlPiece :: Int32 -> Builder # toHeader :: Int32 -> ByteString # toQueryParam :: Int32 -> Text # toEncodedQueryParam :: Int32 -> Builder # | |
ToHttpApiData Int64 # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int64 -> Text # toEncodedUrlPiece :: Int64 -> Builder # toHeader :: Int64 -> ByteString # toQueryParam :: Int64 -> Text # toEncodedQueryParam :: Int64 -> Builder # | |
ToHttpApiData Int8 # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int8 -> Text # toEncodedUrlPiece :: Int8 -> Builder # toHeader :: Int8 -> ByteString # toQueryParam :: Int8 -> Text # toEncodedQueryParam :: Int8 -> Builder # | |
ToHttpApiData Word16 # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word16 -> Text # toEncodedUrlPiece :: Word16 -> Builder # toHeader :: Word16 -> ByteString # toQueryParam :: Word16 -> Text # toEncodedQueryParam :: Word16 -> Builder # | |
ToHttpApiData Word32 # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word32 -> Text # toEncodedUrlPiece :: Word32 -> Builder # toHeader :: Word32 -> ByteString # toQueryParam :: Word32 -> Text # toEncodedQueryParam :: Word32 -> Builder # | |
ToHttpApiData Word64 # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word64 -> Text # toEncodedUrlPiece :: Word64 -> Builder # toHeader :: Word64 -> ByteString # toQueryParam :: Word64 -> Text # toEncodedQueryParam :: Word64 -> Builder # | |
ToHttpApiData Word8 # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word8 -> Text # toEncodedUrlPiece :: Word8 -> Builder # toHeader :: Word8 -> ByteString # toQueryParam :: Word8 -> Text # toEncodedQueryParam :: Word8 -> Builder # | |
ToHttpApiData SetCookie # | Note: this instance works correctly for alphanumeric name and value
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: SetCookie -> Text # toEncodedUrlPiece :: SetCookie -> Builder # toHeader :: SetCookie -> ByteString # toQueryParam :: SetCookie -> Text # toEncodedQueryParam :: SetCookie -> Builder # | |
ToHttpApiData Ordering # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Ordering -> Text # toEncodedUrlPiece :: Ordering -> Builder # toHeader :: Ordering -> ByteString # toQueryParam :: Ordering -> Text # toEncodedQueryParam :: Ordering -> Builder # | |
ToHttpApiData Text # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Text -> Text # toEncodedUrlPiece :: Text -> Builder # toHeader :: Text -> ByteString # toQueryParam :: Text -> Text # toEncodedQueryParam :: Text -> Builder # | |
ToHttpApiData Text # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Text -> Text0 # toEncodedUrlPiece :: Text -> Builder # toHeader :: Text -> ByteString # toQueryParam :: Text -> Text0 # toEncodedQueryParam :: Text -> Builder # | |
ToHttpApiData Day # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Day -> Text # toEncodedUrlPiece :: Day -> Builder # toHeader :: Day -> ByteString # toQueryParam :: Day -> Text # toEncodedQueryParam :: Day -> Builder # | |
ToHttpApiData Month # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Month -> Text # toEncodedUrlPiece :: Month -> Builder # toHeader :: Month -> ByteString # toQueryParam :: Month -> Text # toEncodedQueryParam :: Month -> Builder # | |
ToHttpApiData Quarter # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Quarter -> Text # toEncodedUrlPiece :: Quarter -> Builder # toHeader :: Quarter -> ByteString # toQueryParam :: Quarter -> Text # toEncodedQueryParam :: Quarter -> Builder # | |
ToHttpApiData QuarterOfYear # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: QuarterOfYear -> Text # toEncodedUrlPiece :: QuarterOfYear -> Builder # toHeader :: QuarterOfYear -> ByteString # toQueryParam :: QuarterOfYear -> Text # toEncodedQueryParam :: QuarterOfYear -> Builder # | |
ToHttpApiData DayOfWeek # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: DayOfWeek -> Text # toEncodedUrlPiece :: DayOfWeek -> Builder # toHeader :: DayOfWeek -> ByteString # toQueryParam :: DayOfWeek -> Text # toEncodedQueryParam :: DayOfWeek -> Builder # | |
ToHttpApiData NominalDiffTime # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: NominalDiffTime -> Text # toEncodedUrlPiece :: NominalDiffTime -> Builder # toHeader :: NominalDiffTime -> ByteString # toQueryParam :: NominalDiffTime -> Text # toEncodedQueryParam :: NominalDiffTime -> Builder # | |
ToHttpApiData UTCTime # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: UTCTime -> Text # toEncodedUrlPiece :: UTCTime -> Builder # toHeader :: UTCTime -> ByteString # toQueryParam :: UTCTime -> Text # toEncodedQueryParam :: UTCTime -> Builder # | |
ToHttpApiData LocalTime # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: LocalTime -> Text # toEncodedUrlPiece :: LocalTime -> Builder # toHeader :: LocalTime -> ByteString # toQueryParam :: LocalTime -> Text # toEncodedQueryParam :: LocalTime -> Builder # | |
ToHttpApiData TimeOfDay # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: TimeOfDay -> Text # toEncodedUrlPiece :: TimeOfDay -> Builder # toHeader :: TimeOfDay -> ByteString # toQueryParam :: TimeOfDay -> Text # toEncodedQueryParam :: TimeOfDay -> Builder # | |
ToHttpApiData ZonedTime # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: ZonedTime -> Text # toEncodedUrlPiece :: ZonedTime -> Builder # toHeader :: ZonedTime -> ByteString # toQueryParam :: ZonedTime -> Text # toEncodedQueryParam :: ZonedTime -> Builder # | |
ToHttpApiData UUID # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: UUID -> Text # toEncodedUrlPiece :: UUID -> Builder # toHeader :: UUID -> ByteString # toQueryParam :: UUID -> Text # toEncodedQueryParam :: UUID -> Builder # | |
ToHttpApiData String # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: String -> Text # toEncodedUrlPiece :: String -> Builder # toHeader :: String -> ByteString # toQueryParam :: String -> Text # toEncodedQueryParam :: String -> Builder # | |
ToHttpApiData Integer # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Integer -> Text # toEncodedUrlPiece :: Integer -> Builder # toHeader :: Integer -> ByteString # toQueryParam :: Integer -> Text # toEncodedQueryParam :: Integer -> Builder # | |
ToHttpApiData Natural # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Natural -> Text # toEncodedUrlPiece :: Natural -> Builder # toHeader :: Natural -> ByteString # toQueryParam :: Natural -> Text # toEncodedQueryParam :: Natural -> Builder # | |
ToHttpApiData () # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: () -> Text # toEncodedUrlPiece :: () -> Builder # toHeader :: () -> ByteString # toQueryParam :: () -> Text # toEncodedQueryParam :: () -> Builder # | |
ToHttpApiData Bool # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Bool -> Text # toEncodedUrlPiece :: Bool -> Builder # toHeader :: Bool -> ByteString # toQueryParam :: Bool -> Text # toEncodedQueryParam :: Bool -> Builder # | |
ToHttpApiData Char # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Char -> Text # toEncodedUrlPiece :: Char -> Builder # toHeader :: Char -> ByteString # toQueryParam :: Char -> Text # toEncodedQueryParam :: Char -> Builder # | |
ToHttpApiData Double # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Double -> Text # toEncodedUrlPiece :: Double -> Builder # toHeader :: Double -> ByteString # toQueryParam :: Double -> Text # toEncodedQueryParam :: Double -> Builder # | |
ToHttpApiData Float # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Float -> Text # toEncodedUrlPiece :: Float -> Builder # toHeader :: Float -> ByteString # toQueryParam :: Float -> Text # toEncodedQueryParam :: Float -> Builder # | |
ToHttpApiData Int # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int -> Text # toEncodedUrlPiece :: Int -> Builder # toHeader :: Int -> ByteString # toQueryParam :: Int -> Text # toEncodedQueryParam :: Int -> Builder # | |
ToHttpApiData Word # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word -> Text # toEncodedUrlPiece :: Word -> Builder # toHeader :: Word -> ByteString # toQueryParam :: Word -> Text # toEncodedQueryParam :: Word -> Builder # | |
ToHttpApiData a => ToHttpApiData (Identity a) # | Since: 0.4.2 |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Identity a -> Text # toEncodedUrlPiece :: Identity a -> Builder # toHeader :: Identity a -> ByteString # toQueryParam :: Identity a -> Text # toEncodedQueryParam :: Identity a -> Builder # | |
ToHttpApiData a => ToHttpApiData (First a) # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: First a -> Text # toEncodedUrlPiece :: First a -> Builder # toHeader :: First a -> ByteString # toQueryParam :: First a -> Text # toEncodedQueryParam :: First a -> Builder # | |
ToHttpApiData a => ToHttpApiData (Last a) # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Last a -> Text # toEncodedUrlPiece :: Last a -> Builder # toHeader :: Last a -> ByteString # toQueryParam :: Last a -> Text # toEncodedQueryParam :: Last a -> Builder # | |
ToHttpApiData a => ToHttpApiData (First a) # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: First a -> Text # toEncodedUrlPiece :: First a -> Builder # toHeader :: First a -> ByteString # toQueryParam :: First a -> Text # toEncodedQueryParam :: First a -> Builder # | |
ToHttpApiData a => ToHttpApiData (Last a) # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Last a -> Text # toEncodedUrlPiece :: Last a -> Builder # toHeader :: Last a -> ByteString # toQueryParam :: Last a -> Text # toEncodedQueryParam :: Last a -> Builder # | |
ToHttpApiData a => ToHttpApiData (Max a) # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Max a -> Text # toEncodedUrlPiece :: Max a -> Builder # toHeader :: Max a -> ByteString # toQueryParam :: Max a -> Text # toEncodedQueryParam :: Max a -> Builder # | |
ToHttpApiData a => ToHttpApiData (Min a) # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Min a -> Text # toEncodedUrlPiece :: Min a -> Builder # toHeader :: Min a -> ByteString # toQueryParam :: Min a -> Text # toEncodedQueryParam :: Min a -> Builder # | |
ToHttpApiData a => ToHttpApiData (Dual a) # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Dual a -> Text # toEncodedUrlPiece :: Dual a -> Builder # toHeader :: Dual a -> ByteString # toQueryParam :: Dual a -> Text # toEncodedQueryParam :: Dual a -> Builder # | |
ToHttpApiData a => ToHttpApiData (Product a) # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Product a -> Text # toEncodedUrlPiece :: Product a -> Builder # toHeader :: Product a -> ByteString # toQueryParam :: Product a -> Text # toEncodedQueryParam :: Product a -> Builder # | |
ToHttpApiData a => ToHttpApiData (Sum a) # | |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Sum a -> Text # toEncodedUrlPiece :: Sum a -> Builder # toHeader :: Sum a -> ByteString # toQueryParam :: Sum a -> Text # toEncodedQueryParam :: Sum a -> Builder # | |
ToHttpApiData a => ToHttpApiData (Maybe a) # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Maybe a -> Text # toEncodedUrlPiece :: Maybe a -> Builder # toHeader :: Maybe a -> ByteString # toQueryParam :: Maybe a -> Text # toEncodedQueryParam :: Maybe a -> Builder # | |
(ToHttpApiData a, ToHttpApiData b) => ToHttpApiData (Either a b) # |
|
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Either a b -> Text # toEncodedUrlPiece :: Either a b -> Builder # toHeader :: Either a b -> ByteString # toQueryParam :: Either a b -> Text # toEncodedQueryParam :: Either a b -> Builder # | |
HasResolution a => ToHttpApiData (Fixed a) # | Note: this instance is not polykinded |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Fixed a -> Text # toEncodedUrlPiece :: Fixed a -> Builder # toHeader :: Fixed a -> ByteString # toQueryParam :: Fixed a -> Text # toEncodedQueryParam :: Fixed a -> Builder # | |
ToHttpApiData a => ToHttpApiData (Const a b) # | Since: 0.4.2 |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Const a b -> Text # toEncodedUrlPiece :: Const a b -> Builder # toHeader :: Const a b -> ByteString # toQueryParam :: Const a b -> Text # toEncodedQueryParam :: Const a b -> Builder # | |
ToHttpApiData a => ToHttpApiData (Tagged b a) # | Note: this instance is not polykinded |
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Tagged b a -> Text # toEncodedUrlPiece :: Tagged b a -> Builder # toHeader :: Tagged b a -> ByteString # toQueryParam :: Tagged b a -> Text # toEncodedQueryParam :: Tagged b a -> Builder # |
class FromHttpApiData a where #
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 #
Parse URL path piece.
parseHeader :: ByteString -> Either Text a #
Parse HTTP header value.
parseQueryParam :: Text -> Either Text a #
Parse query param value.
Instances
FromHttpApiData All # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text All # parseHeader :: ByteString -> Either Text All # parseQueryParam :: Text -> Either Text All # | |
FromHttpApiData Any # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Any # parseHeader :: ByteString -> Either Text Any # parseQueryParam :: Text -> Either Text Any # | |
FromHttpApiData Version # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Version # parseHeader :: ByteString -> Either Text Version # parseQueryParam :: Text -> Either Text Version # | |
FromHttpApiData Void # | Parsing a |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Void # parseHeader :: ByteString -> Either Text Void # parseQueryParam :: Text -> Either Text Void # | |
FromHttpApiData Int16 # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Int16 # parseHeader :: ByteString -> Either Text Int16 # parseQueryParam :: Text -> Either Text Int16 # | |
FromHttpApiData Int32 # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Int32 # parseHeader :: ByteString -> Either Text Int32 # parseQueryParam :: Text -> Either Text Int32 # | |
FromHttpApiData Int64 # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Int64 # parseHeader :: ByteString -> Either Text Int64 # parseQueryParam :: Text -> Either Text Int64 # | |
FromHttpApiData Int8 # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Int8 # parseHeader :: ByteString -> Either Text Int8 # parseQueryParam :: Text -> Either Text Int8 # | |
FromHttpApiData Word16 # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Word16 # parseHeader :: ByteString -> Either Text Word16 # parseQueryParam :: Text -> Either Text Word16 # | |
FromHttpApiData Word32 # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Word32 # parseHeader :: ByteString -> Either Text Word32 # parseQueryParam :: Text -> Either Text Word32 # | |
FromHttpApiData Word64 # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Word64 # parseHeader :: ByteString -> Either Text Word64 # parseQueryParam :: Text -> Either Text Word64 # | |
FromHttpApiData Word8 # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Word8 # parseHeader :: ByteString -> Either Text Word8 # parseQueryParam :: Text -> Either Text Word8 # | |
FromHttpApiData SetCookie # | Note: this instance works correctly for alphanumeric name and value
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text SetCookie # parseHeader :: ByteString -> Either Text SetCookie # parseQueryParam :: Text -> Either Text SetCookie # | |
FromHttpApiData Ordering # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Ordering # parseHeader :: ByteString -> Either Text Ordering # parseQueryParam :: Text -> Either Text Ordering # | |
FromHttpApiData Text # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Text # parseHeader :: ByteString -> Either Text Text # parseQueryParam :: Text -> Either Text Text # | |
FromHttpApiData Text # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text0 -> Either Text0 Text # parseHeader :: ByteString -> Either Text0 Text # parseQueryParam :: Text0 -> Either Text0 Text # | |
FromHttpApiData Day # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Day # parseHeader :: ByteString -> Either Text Day # parseQueryParam :: Text -> Either Text Day # | |
FromHttpApiData Month # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Month # parseHeader :: ByteString -> Either Text Month # parseQueryParam :: Text -> Either Text Month # | |
FromHttpApiData Quarter # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Quarter # parseHeader :: ByteString -> Either Text Quarter # parseQueryParam :: Text -> Either Text Quarter # | |
FromHttpApiData QuarterOfYear # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text QuarterOfYear # parseHeader :: ByteString -> Either Text QuarterOfYear # parseQueryParam :: Text -> Either Text QuarterOfYear # | |
FromHttpApiData DayOfWeek # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text DayOfWeek # parseHeader :: ByteString -> Either Text DayOfWeek # parseQueryParam :: Text -> Either Text DayOfWeek # | |
FromHttpApiData NominalDiffTime # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text NominalDiffTime # parseHeader :: ByteString -> Either Text NominalDiffTime # parseQueryParam :: Text -> Either Text NominalDiffTime # | |
FromHttpApiData UTCTime # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text UTCTime # parseHeader :: ByteString -> Either Text UTCTime # parseQueryParam :: Text -> Either Text UTCTime # | |
FromHttpApiData LocalTime # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text LocalTime # parseHeader :: ByteString -> Either Text LocalTime # parseQueryParam :: Text -> Either Text LocalTime # | |
FromHttpApiData TimeOfDay # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text TimeOfDay # parseHeader :: ByteString -> Either Text TimeOfDay # parseQueryParam :: Text -> Either Text TimeOfDay # | |
FromHttpApiData ZonedTime # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text ZonedTime # parseHeader :: ByteString -> Either Text ZonedTime # parseQueryParam :: Text -> Either Text ZonedTime # | |
FromHttpApiData UUID # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text UUID # parseHeader :: ByteString -> Either Text UUID # parseQueryParam :: Text -> Either Text UUID # | |
FromHttpApiData String # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text String # parseHeader :: ByteString -> Either Text String # parseQueryParam :: Text -> Either Text String # | |
FromHttpApiData Integer # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Integer # parseHeader :: ByteString -> Either Text Integer # parseQueryParam :: Text -> Either Text Integer # | |
FromHttpApiData Natural # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Natural # parseHeader :: ByteString -> Either Text Natural # parseQueryParam :: Text -> Either Text Natural # | |
FromHttpApiData () # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text () # parseHeader :: ByteString -> Either Text () # parseQueryParam :: Text -> Either Text () # | |
FromHttpApiData Bool # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Bool # parseHeader :: ByteString -> Either Text Bool # parseQueryParam :: Text -> Either Text Bool # | |
FromHttpApiData Char # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Char # parseHeader :: ByteString -> Either Text Char # parseQueryParam :: Text -> Either Text Char # | |
FromHttpApiData Double # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Double # parseHeader :: ByteString -> Either Text Double # parseQueryParam :: Text -> Either Text Double # | |
FromHttpApiData Float # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Float # parseHeader :: ByteString -> Either Text Float # parseQueryParam :: Text -> Either Text Float # | |
FromHttpApiData Int # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Int # parseHeader :: ByteString -> Either Text Int # parseQueryParam :: Text -> Either Text Int # | |
FromHttpApiData Word # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Word # parseHeader :: ByteString -> Either Text Word # parseQueryParam :: Text -> Either Text Word # | |
FromHttpApiData a => FromHttpApiData (Identity a) # | Since: 0.4.2 |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Identity a) # parseHeader :: ByteString -> Either Text (Identity a) # parseQueryParam :: Text -> Either Text (Identity a) # | |
FromHttpApiData a => FromHttpApiData (First a) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (First a) # parseHeader :: ByteString -> Either Text (First a) # parseQueryParam :: Text -> Either Text (First a) # | |
FromHttpApiData a => FromHttpApiData (Last a) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Last a) # parseHeader :: ByteString -> Either Text (Last a) # parseQueryParam :: Text -> Either Text (Last a) # | |
FromHttpApiData a => FromHttpApiData (First a) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (First a) # parseHeader :: ByteString -> Either Text (First a) # parseQueryParam :: Text -> Either Text (First a) # | |
FromHttpApiData a => FromHttpApiData (Last a) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Last a) # parseHeader :: ByteString -> Either Text (Last a) # parseQueryParam :: Text -> Either Text (Last a) # | |
FromHttpApiData a => FromHttpApiData (Max a) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Max a) # parseHeader :: ByteString -> Either Text (Max a) # parseQueryParam :: Text -> Either Text (Max a) # | |
FromHttpApiData a => FromHttpApiData (Min a) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Min a) # parseHeader :: ByteString -> Either Text (Min a) # parseQueryParam :: Text -> Either Text (Min a) # | |
FromHttpApiData a => FromHttpApiData (Dual a) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Dual a) # parseHeader :: ByteString -> Either Text (Dual a) # parseQueryParam :: Text -> Either Text (Dual a) # | |
FromHttpApiData a => FromHttpApiData (Product a) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Product a) # parseHeader :: ByteString -> Either Text (Product a) # parseQueryParam :: Text -> Either Text (Product a) # | |
FromHttpApiData a => FromHttpApiData (Sum a) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Sum a) # parseHeader :: ByteString -> Either Text (Sum a) # parseQueryParam :: Text -> Either Text (Sum a) # | |
FromHttpApiData a => FromHttpApiData (LenientData a) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (LenientData a) # parseHeader :: ByteString -> Either Text (LenientData a) # parseQueryParam :: Text -> Either Text (LenientData a) # | |
FromHttpApiData a => FromHttpApiData (Maybe a) # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Maybe a) # parseHeader :: ByteString -> Either Text (Maybe a) # parseQueryParam :: Text -> Either Text (Maybe a) # | |
(FromHttpApiData a, FromHttpApiData b) => FromHttpApiData (Either a b) # |
|
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Either a b) # parseHeader :: ByteString -> Either Text (Either a b) # parseQueryParam :: Text -> Either Text (Either a b) # | |
HasResolution a => FromHttpApiData (Fixed a) # | Note: this instance is not polykinded |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Fixed a) # parseHeader :: ByteString -> Either Text (Fixed a) # parseQueryParam :: Text -> Either Text (Fixed a) # | |
FromHttpApiData a => FromHttpApiData (Const a b) # | Since: 0.4.2 |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Const a b) # parseHeader :: ByteString -> Either Text (Const a b) # parseQueryParam :: Text -> Either Text (Const a b) # | |
FromHttpApiData a => FromHttpApiData (Tagged b a) # | Note: this instance is not polykinded |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Tagged b a) # parseHeader :: ByteString -> Either Text (Tagged b a) # parseQueryParam :: Text -> Either Text (Tagged b a) # |
toUrlPieces :: (Functor t, ToHttpApiData a) => t a -> t Text #
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) #
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 #
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) #
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 #
Parse URL path piece in a
.Maybe
>>>
parseUrlPieceMaybe "12" :: Maybe Int
Just 12
parseHeaderMaybe :: FromHttpApiData a => ByteString -> Maybe a #
Parse HTTP header value in a
.Maybe
>>>
parseHeaderMaybe "hello" :: Maybe Text
Just "hello"
parseQueryParamMaybe :: FromHttpApiData a => Text -> Maybe a #
Parse query param value in a
.Maybe
>>>
parseQueryParamMaybe "true" :: Maybe Bool
Just True
defaultParseError :: Text -> Either Text a #
Default parsing error.
parseMaybeTextData :: (Text -> Maybe a) -> Text -> Either Text a #
Convert
parser into Maybe
parser with default error message.Either
Text
showTextData :: Show a => a -> Text #
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 #
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
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 Foo
Right (Foo 1)
parseHeaderWithPrefix :: FromHttpApiData a => ByteString -> ByteString -> Either Text a #
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 #
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 #
Case insensitive.
Parse values case insensitively based on
instance.Show
>>>
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 #
Lookup values based on a precalculated mapping of their representations.
parseBoundedEnumOf :: (Bounded a, Enum a) => (a -> Text) -> Text -> Either Text a #
Parse values based on a precalculated mapping of their
representation.Text
>>>
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 #
Case insensitive.
Parse values case insensitively based on a precalculated mapping
of their
representations.Text
>>>
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 #
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 #
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 #
Parse values based on
instance.
Uses ToHttpApiData
to get possible values.toHeader
readTextData :: Read a => Text -> Either Text a #
Parse URL piece using
instance.Read
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
in presence of letters:showTextData
>>>
readTextData (showTextData True) :: Either Text Bool
Left "could not parse: `true'"
See
.parseBoundedTextData
parseBounded :: forall a. (Bounded a, Integral a) => Reader Integer -> Text -> Either Text a #
Run
to parse bounded integral value with bounds checking.Reader
>>>
parseBounded decimal "256" :: Either Text Word8
Left "out of bounds: `256' (should be between 0 and 255)"
unsafeToEncodedUrlPiece :: ToHttpApiData a => a -> Builder #
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 #
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 #
Lenient parameters. FromHttpApiData
combinators always return Right
.
Since: 0.3.5
Constructors
LenientData | |
Fields
|
Instances
Foldable LenientData # | |
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 # | |
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) | |
Functor LenientData # | |
Defined in Web.Internal.HttpApiData Methods fmap :: (a -> b) -> LenientData a -> LenientData b (<$) :: a -> LenientData b -> LenientData a | |
Data a => Data (LenientData a) # | |
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) # | |
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) # | |
Defined in Web.Internal.HttpApiData Methods showsPrec :: Int -> LenientData a -> ShowS show :: LenientData a -> String showList :: [LenientData a] -> ShowS | |
Eq a => Eq (LenientData a) # | |
Defined in Web.Internal.HttpApiData | |
Ord a => Ord (LenientData a) # | |
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) # | |
Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (LenientData a) # parseHeader :: ByteString -> Either Text (LenientData a) # parseQueryParam :: Text -> Either Text (LenientData a) # |