magicbane-0.4.0: A web framework that integrates Servant, RIO, EKG, fast-logger, wai-cli…

Safe HaskellTrustworthy
LanguageHaskell2010

Magicbane

Description

A Dropwizard-inspired web framework that integrates Servant, monad-metricsEKG, monad-loggerfast-logger, and other useful libraries to provide a smooth web service development experience.

This module provides all the stuff you need for an application: - reexports from all the modules below, including orphan instances from Magicbane.Has - orphan instances for RIO - reexports from various utility packages - a basic example context for simple apps

Synopsis

Documentation

assert :: Bool -> a -> a #

If the first argument evaluates to True, then the result is the second argument. Otherwise an AssertionFailed exception is raised, containing a String with the source file and line number of the call to assert.

Assertions can normally be turned on or off with a compiler flag (for GHC, assertions are normally on unless optimisation is turned on with -O or the -fignore-asserts option is given). When assertions are turned off, the first argument to assert is ignored, and the second argument is returned as the result.

class Typeable (a :: k) #

The class Typeable allows a concrete representation of a type to be calculated.

Minimal complete definition

typeRep#

eitherDecodeFileStrict' :: FromJSON a => FilePath -> IO (Either String a) #

Like decodeFileStrict' but returns an error message when decoding fails.

eitherDecodeStrict' :: FromJSON a => ByteString -> Either String a #

Like decodeStrict' but returns an error message when decoding fails.

eitherDecode' :: FromJSON a => ByteString -> Either String a #

Like decode' but returns an error message when decoding fails.

eitherDecodeFileStrict :: FromJSON a => FilePath -> IO (Either String a) #

Like decodeFileStrict but returns an error message when decoding fails.

eitherDecodeStrict :: FromJSON a => ByteString -> Either String a #

Like decodeStrict but returns an error message when decoding fails.

eitherDecode :: FromJSON a => ByteString -> Either String a #

Like decode but returns an error message when decoding fails.

decodeFileStrict' :: FromJSON a => FilePath -> IO (Maybe a) #

Efficiently deserialize a JSON value from a file. If this fails due to incomplete or invalid input, Nothing is returned.

The input file's content must consist solely of a JSON document, with no trailing data except for whitespace.

This function parses and performs conversion immediately. See json' for details.

decodeStrict' :: FromJSON a => ByteString -> Maybe a #

Efficiently deserialize a JSON value from a strict ByteString. If this fails due to incomplete or invalid input, Nothing is returned.

The input must consist solely of a JSON document, with no trailing data except for whitespace.

This function parses and performs conversion immediately. See json' for details.

decode' :: FromJSON a => ByteString -> Maybe a #

Efficiently deserialize a JSON value from a lazy ByteString. If this fails due to incomplete or invalid input, Nothing is returned.

The input must consist solely of a JSON document, with no trailing data except for whitespace.

This function parses and performs conversion immediately. See json' for details.

decodeFileStrict :: FromJSON a => FilePath -> IO (Maybe a) #

Efficiently deserialize a JSON value from a file. If this fails due to incomplete or invalid input, Nothing is returned.

The input file's content must consist solely of a JSON document, with no trailing data except for whitespace.

This function parses immediately, but defers conversion. See json for details.

decodeStrict :: FromJSON a => ByteString -> Maybe a #

Efficiently deserialize a JSON value from a strict ByteString. If this fails due to incomplete or invalid input, Nothing is returned.

The input must consist solely of a JSON document, with no trailing data except for whitespace.

This function parses immediately, but defers conversion. See json for details.

decode :: FromJSON a => ByteString -> Maybe a #

Efficiently deserialize a JSON value from a lazy ByteString. If this fails due to incomplete or invalid input, Nothing is returned.

The input must consist solely of a JSON document, with no trailing data except for whitespace.

This function parses immediately, but defers conversion. See json for details.

encodeFile :: ToJSON a => FilePath -> a -> IO () #

Efficiently serialize a JSON value as a lazy ByteString and write it to a file.

encode :: ToJSON a => a -> ByteString #

Efficiently serialize a JSON value as a lazy ByteString.

This is implemented in terms of the ToJSON class's toEncoding method.

foldable :: (Foldable t, ToJSON a) => t a -> Encoding #

Encode a Foldable as a JSON array.

type GToJSON = GToJSON Value #

type GToEncoding = GToJSON Encoding #

toEncoding2 :: (ToJSON2 f, ToJSON a, ToJSON b) => f a b -> Encoding #

Lift the standard toEncoding function through the type constructor.

toJSON2 :: (ToJSON2 f, ToJSON a, ToJSON b) => f a b -> Value #

Lift the standard toJSON function through the type constructor.

toEncoding1 :: (ToJSON1 f, ToJSON a) => f a -> Encoding #

Lift the standard toEncoding function through the type constructor.

toJSON1 :: (ToJSON1 f, ToJSON a) => f a -> Value #

Lift the standard toJSON function through the type constructor.

genericLiftToEncoding :: (Generic1 f, GToJSON Encoding One (Rep1 f)) => Options -> (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding #

A configurable generic JSON encoder. This function applied to defaultOptions is used as the default for liftToEncoding when the type is an instance of Generic1.

genericToEncoding :: (Generic a, GToJSON Encoding Zero (Rep a)) => Options -> a -> Encoding #

A configurable generic JSON encoder. This function applied to defaultOptions is used as the default for toEncoding when the type is an instance of Generic.

genericLiftToJSON :: (Generic1 f, GToJSON Value One (Rep1 f)) => Options -> (a -> Value) -> ([a] -> Value) -> f a -> Value #

A configurable generic JSON creator. This function applied to defaultOptions is used as the default for liftToJSON when the type is an instance of Generic1.

genericToJSON :: (Generic a, GToJSON Value Zero (Rep a)) => Options -> a -> Value #

A configurable generic JSON creator. This function applied to defaultOptions is used as the default for toJSON when the type is an instance of Generic.

data ToArgs res arity a where #

A ToArgs value either stores nothing (for ToJSON) or it stores the two function arguments that encode occurrences of the type parameter (for ToJSON1).

Constructors

NoToArgs :: ToArgs res Zero a 
To1Args :: ToArgs res One a 

class ToJSON a where #

A type that can be converted to JSON.

Instances in general must specify toJSON and should (but don't need to) specify toEncoding.

An example type and instance:

-- Allow ourselves to write Text literals.
{-# LANGUAGE OverloadedStrings #-}

data Coord = Coord { x :: Double, y :: Double }

instance ToJSON Coord where
  toJSON (Coord x y) = object ["x" .= x, "y" .= y]

  toEncoding (Coord x y) = pairs ("x" .= x <> "y" .= y)

Instead of manually writing your ToJSON instance, there are two options to do it automatically:

  • Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
  • The compiler can provide a default generic implementation for toJSON.

To use the second, simply add a deriving Generic clause to your datatype and declare a ToJSON instance. If you require nothing other than defaultOptions, it is sufficient to write (and this is the only alternative where the default toJSON implementation is sufficient):

{-# LANGUAGE DeriveGeneric #-}

import GHC.Generics

data Coord = Coord { x :: Double, y :: Double } deriving Generic

instance ToJSON Coord where
    toEncoding = genericToEncoding defaultOptions

If on the other hand you wish to customize the generic decoding, you have to implement both methods:

customOptions = defaultOptions
                { fieldLabelModifier = map toUpper
                }

instance ToJSON Coord where
    toJSON     = genericToJSON customOptions
    toEncoding = genericToEncoding customOptions

Previous versions of this library only had the toJSON method. Adding toEncoding had to reasons:

  1. toEncoding is more efficient for the common case that the output of toJSON is directly serialized to a ByteString. Further, expressing either method in terms of the other would be non-optimal.
  2. The choice of defaults allows a smooth transition for existing users: Existing instances that do not define toEncoding still compile and have the correct semantics. This is ensured by making the default implementation of toEncoding use toJSON. This produces correct results, but since it performs an intermediate conversion to a Value, it will be less efficient than directly emitting an Encoding. (this also means that specifying nothing more than instance ToJSON Coord would be sufficient as a generically decoding instance, but there probably exists no good reason to not specify toEncoding in new instances.)

Methods

toJSON :: a -> Value #

Convert a Haskell value to a JSON-friendly intermediate type.

toEncoding :: a -> Encoding #

Encode a Haskell value as JSON.

The default implementation of this method creates an intermediate Value using toJSON. This provides source-level compatibility for people upgrading from older versions of this library, but obviously offers no performance advantage.

To benefit from direct encoding, you must provide an implementation for this method. The easiest way to do so is by having your types implement Generic using the DeriveGeneric extension, and then have GHC generate a method body as follows.

instance ToJSON Coord where
    toEncoding = genericToEncoding defaultOptions

toJSONList :: [a] -> Value #

toEncodingList :: [a] -> Encoding #

Instances
ToJSON Bool 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Char 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Double 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Float 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Int 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Int8 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Int16 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Int32 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Int64 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Integer 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Natural 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Ordering 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Word 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Word8 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Word16 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Word32 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Word64 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON () 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: () -> Value #

toEncoding :: () -> Encoding #

toJSONList :: [()] -> Value #

toEncodingList :: [()] -> Encoding #

ToJSON Version 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Scientific 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Text 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON UTCTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Value 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON DotNetTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Text 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Number 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON CTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON IntSet 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON DiffTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Day 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON NominalDiffTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON TimeOfDay 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON LocalTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON ZonedTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON UUID 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON [a] 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: [a] -> Value #

toEncoding :: [a] -> Encoding #

toJSONList :: [[a]] -> Value #

toEncodingList :: [[a]] -> Encoding #

ToJSON a => ToJSON (Maybe a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(ToJSON a, Integral a) => ToJSON (Ratio a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

HasResolution a => ToJSON (Fixed a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (Min a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Min a -> Value #

toEncoding :: Min a -> Encoding #

toJSONList :: [Min a] -> Value #

toEncodingList :: [Min a] -> Encoding #

ToJSON a => ToJSON (Max a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Max a -> Value #

toEncoding :: Max a -> Encoding #

toJSONList :: [Max a] -> Value #

toEncodingList :: [Max a] -> Encoding #

ToJSON a => ToJSON (First a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (Last a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (WrappedMonoid a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (Option a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (Identity a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (First a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (Last a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (Dual a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (NonEmpty a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (IntMap a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON v => ToJSON (Tree v) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (Seq a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Seq a -> Value #

toEncoding :: Seq a -> Encoding #

toJSONList :: [Seq a] -> Value #

toEncodingList :: [Seq a] -> Encoding #

ToJSON a => ToJSON (Set a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Set a -> Value #

toEncoding :: Set a -> Encoding #

toJSONList :: [Set a] -> Value #

toEncodingList :: [Set a] -> Encoding #

ToJSON a => ToJSON (DList a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (Vector a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(Storable a, ToJSON a) => ToJSON (Vector a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(Vector Vector a, ToJSON a) => ToJSON (Vector a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON (HashSet a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(Prim a, ToJSON a) => ToJSON (Vector a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(ToJSON a, ToJSON b) => ToJSON (Either a b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Either a b -> Value #

toEncoding :: Either a b -> Encoding #

toJSONList :: [Either a b] -> Value #

toEncodingList :: [Either a b] -> Encoding #

(ToJSON a, ToJSON b) => ToJSON (a, b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b) -> Value #

toEncoding :: (a, b) -> Encoding #

toJSONList :: [(a, b)] -> Value #

toEncodingList :: [(a, b)] -> Encoding #

(ToJSON v, ToJSONKey k) => ToJSON (HashMap k v) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(ToJSON v, ToJSONKey k) => ToJSON (Map k v) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Map k v -> Value #

toEncoding :: Map k v -> Encoding #

toJSONList :: [Map k v] -> Value #

toEncodingList :: [Map k v] -> Encoding #

ToJSON (Proxy a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(ToJSON a, ToJSON b) => ToJSON (These a b) 
Instance details

Defined in Data.These

Methods

toJSON :: These a b -> Value #

toEncoding :: These a b -> Encoding #

toJSONList :: [These a b] -> Value #

toEncodingList :: [These a b] -> Encoding #

ToJSON α => ToJSON (Refined ρ α) # 
Instance details

Defined in Magicbane.Validation

Methods

toJSON :: Refined ρ α -> Value #

toEncoding :: Refined ρ α -> Encoding #

toJSONList :: [Refined ρ α] -> Value #

toEncodingList :: [Refined ρ α] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c) => ToJSON (a, b, c) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c) -> Value #

toEncoding :: (a, b, c) -> Encoding #

toJSONList :: [(a, b, c)] -> Value #

toEncodingList :: [(a, b, c)] -> Encoding #

ToJSON a => ToJSON (Const a b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Const a b -> Value #

toEncoding :: Const a b -> Encoding #

toJSONList :: [Const a b] -> Value #

toEncodingList :: [Const a b] -> Encoding #

ToJSON b => ToJSON (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Tagged a b -> Value #

toEncoding :: Tagged a b -> Encoding #

toJSONList :: [Tagged a b] -> Value #

toEncodingList :: [Tagged a b] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON (a, b, c, d) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d) -> Value #

toEncoding :: (a, b, c, d) -> Encoding #

toJSONList :: [(a, b, c, d)] -> Value #

toEncodingList :: [(a, b, c, d)] -> Encoding #

(ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Product f g a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Product f g a -> Value #

toEncoding :: Product f g a -> Encoding #

toJSONList :: [Product f g a] -> Value #

toEncodingList :: [Product f g a] -> Encoding #

(ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Sum f g a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Sum f g a -> Value #

toEncoding :: Sum f g a -> Encoding #

toJSONList :: [Sum f g a] -> Value #

toEncodingList :: [Sum f g a] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) => ToJSON (a, b, c, d, e) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e) -> Value #

toEncoding :: (a, b, c, d, e) -> Encoding #

toJSONList :: [(a, b, c, d, e)] -> Value #

toEncodingList :: [(a, b, c, d, e)] -> Encoding #

(ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Compose f g a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Compose f g a -> Value #

toEncoding :: Compose f g a -> Encoding #

toJSONList :: [Compose f g a] -> Value #

toEncodingList :: [Compose f g a] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) => ToJSON (a, b, c, d, e, f) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f) -> Value #

toEncoding :: (a, b, c, d, e, f) -> Encoding #

toJSONList :: [(a, b, c, d, e, f)] -> Value #

toEncodingList :: [(a, b, c, d, e, f)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g) => ToJSON (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g) -> Value #

toEncoding :: (a, b, c, d, e, f, g) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h) => ToJSON (a, b, c, d, e, f, g, h) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i) => ToJSON (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j) => ToJSON (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k) => ToJSON (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n, ToJSON o) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Value #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Encoding #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Value #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Encoding #

class KeyValue kv where #

A key-value pair for encoding a JSON object.

Minimal complete definition

(.=)

Methods

(.=) :: ToJSON v => Text -> v -> kv infixr 8 #

Instances
KeyValue Series 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Text -> v -> Series #

KeyValue Pair 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Text -> v -> Pair #

class ToJSONKey a where #

Typeclass for types that can be used as the key of a map-like container (like Map or HashMap). For example, since Text has a ToJSONKey instance and Char has a ToJSON instance, we can encode a value of type Map Text Char:

>>> LBC8.putStrLn $ encode $ Map.fromList [("foo" :: Text, 'a')]
{"foo":"a"}

Since Int also has a ToJSONKey instance, we can similarly write:

>>> LBC8.putStrLn $ encode $ Map.fromList [(5 :: Int, 'a')]
{"5":"a"}

JSON documents only accept strings as object keys. For any type from base that has a natural textual representation, it can be expected that its ToJSONKey instance will choose that representation.

For data types that lack a natural textual representation, an alternative is provided. The map-like container is represented as a JSON array instead of a JSON object. Each value in the array is an array with exactly two values. The first is the key and the second is the value.

For example, values of type '[Text]' cannot be encoded to a string, so a Map with keys of type '[Text]' is encoded as follows:

>>> LBC8.putStrLn $ encode $ Map.fromList [(["foo","bar","baz" :: Text], 'a')]
[[["foo","bar","baz"],"a"]]

The default implementation of ToJSONKey chooses this method of encoding a key, using the ToJSON instance of the type.

To use your own data type as the key in a map, all that is needed is to write a ToJSONKey (and possibly a FromJSONKey) instance for it. If the type cannot be trivially converted to and from Text, it is recommended that ToJSONKeyValue is used. Since the default implementations of the typeclass methods can build this from a ToJSON instance, there is nothing that needs to be written:

data Foo = Foo { fooAge :: Int, fooName :: Text }
  deriving (Eq,Ord,Generic)
instance ToJSON Foo
instance ToJSONKey Foo

That's it. We can now write:

>>> let m = Map.fromList [(Foo 4 "bar",'a'),(Foo 6 "arg",'b')]
>>> LBC8.putStrLn $ encode m
[[{"fooName":"bar","fooAge":4},"a"],[{"fooName":"arg","fooAge":6},"b"]]

The next case to consider is if we have a type that is a newtype wrapper around Text. The recommended approach is to use generalized newtype deriving:

newtype RecordId = RecordId { getRecordId :: Text}
  deriving (Eq,Ord,ToJSONKey)

Then we may write:

>>> LBC8.putStrLn $ encode $ Map.fromList [(RecordId "abc",'a')]
{"abc":"a"}

Simple sum types are a final case worth considering. Suppose we have:

data Color = Red | Green | Blue
  deriving (Show,Read,Eq,Ord)

It is possible to get the ToJSONKey instance for free as we did with Foo. However, in this case, we have a natural way to go to and from Text that does not require any escape sequences. So, in this example, ToJSONKeyText will be used instead of ToJSONKeyValue. The Show instance can be used to help write ToJSONKey:

instance ToJSONKey Color where
  toJSONKey = ToJSONKeyText f g
    where f = Text.pack . show
          g = text . Text.pack . show
          -- text function is from Data.Aeson.Encoding

The situation of needing to turning function a -> Text into a ToJSONKeyFunction is common enough that a special combinator is provided for it. The above instance can be rewritten as:

instance ToJSONKey Color where
  toJSONKey = toJSONKeyText (Text.pack . show)

The performance of the above instance can be improved by not using String as an intermediate step when converting to Text. One option for improving performance would be to use template haskell machinery from the text-show package. However, even with the approach, the Encoding (a wrapper around a bytestring builder) is generated by encoding the Text to a ByteString, an intermediate step that could be avoided. The fastest possible implementation would be:

-- Assuming that OverloadedStrings is enabled
instance ToJSONKey Color where
  toJSONKey = ToJSONKeyText f g
    where f x = case x of {Red -> "Red";Green ->"Green";Blue -> "Blue"}
          g x = case x of {Red -> text "Red";Green -> text "Green";Blue -> text "Blue"}
          -- text function is from Data.Aeson.Encoding

This works because GHC can lift the encoded values out of the case statements, which means that they are only evaluated once. This approach should only be used when there is a serious need to maximize performance.

Methods

toJSONKey :: ToJSONKeyFunction a #

Strategy for rendering the key for a map-like container.

toJSONKeyList :: ToJSONKeyFunction [a] #

This is similar in spirit to the showsList method of Show. It makes it possible to give String keys special treatment without using OverlappingInstances. End users should always be able to use the default implementation of this method.

Instances
ToJSONKey Bool 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Char 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Double 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Float 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Int 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Int8 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Int16 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Int32 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Int64 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Integer 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Natural 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Word 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Word8 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Word16 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Word32 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Word64 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Version 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Scientific 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Text 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey UTCTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Text 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Day 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey TimeOfDay 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey LocalTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey ZonedTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey UUID 
Instance details

Defined in Data.Aeson.Types.ToJSON

(ToJSONKey a, ToJSON a) => ToJSONKey [a] 
Instance details

Defined in Data.Aeson.Types.ToJSON

HasResolution a => ToJSONKey (Fixed a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey a => ToJSONKey (Identity a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(ToJSON a, ToJSON b) => ToJSONKey (a, b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(ToJSON a, ToJSON b, ToJSON c) => ToJSONKey (a, b, c) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSONKey :: ToJSONKeyFunction (a, b, c) #

toJSONKeyList :: ToJSONKeyFunction [(a, b, c)] #

ToJSONKey b => ToJSONKey (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSONKey (a, b, c, d) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSONKey :: ToJSONKeyFunction (a, b, c, d) #

toJSONKeyList :: ToJSONKeyFunction [(a, b, c, d)] #

data ToJSONKeyFunction a #

Constructors

ToJSONKeyText !(a -> Text) !(a -> Encoding' Text)

key is encoded to string, produces object

ToJSONKeyValue !(a -> Value) !(a -> Encoding)

key is encoded to value, produces array

class ToJSON1 (f :: * -> *) where #

Lifting of the ToJSON class to unary type constructors.

Instead of manually writing your ToJSON1 instance, there are two options to do it automatically:

  • Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
  • The compiler can provide a default generic implementation for toJSON1.

To use the second, simply add a deriving Generic1 clause to your datatype and declare a ToJSON1 instance for your datatype without giving definitions for liftToJSON or liftToEncoding.

For example:

{-# LANGUAGE DeriveGeneric #-}

import GHC.Generics

data Pair = Pair { pairFst :: a, pairSnd :: b } deriving Generic1

instance ToJSON a => ToJSON1 (Pair a)

If the default implementation doesn't give exactly the results you want, you can customize the generic encoding with only a tiny amount of effort, using genericLiftToJSON and genericLiftToEncoding with your preferred Options:

customOptions = defaultOptions
                { fieldLabelModifier = map toUpper
                }

instance ToJSON a => ToJSON1 (Pair a) where
    liftToJSON     = genericLiftToJSON customOptions
    liftToEncoding = genericLiftToEncoding customOptions

See also ToJSON.

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> f a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [f a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [f a] -> Encoding #

Instances
ToJSON1 [] 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> [a] -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [[a]] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> [a] -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [[a]] -> Encoding #

ToJSON1 Maybe 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Maybe a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Maybe a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Maybe a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Maybe a] -> Encoding #

ToJSON1 Min 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Min a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Min a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Min a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Min a] -> Encoding #

ToJSON1 Max 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Max a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Max a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Max a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Max a] -> Encoding #

ToJSON1 First 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> First a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [First a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> First a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [First a] -> Encoding #

ToJSON1 Last 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Last a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Last a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Last a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Last a] -> Encoding #

ToJSON1 WrappedMonoid 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> WrappedMonoid a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [WrappedMonoid a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> WrappedMonoid a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [WrappedMonoid a] -> Encoding #

ToJSON1 Option 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Option a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Option a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Option a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Option a] -> Encoding #

ToJSON1 Identity 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Identity a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Identity a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Identity a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Identity a] -> Encoding #

ToJSON1 First 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> First a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [First a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> First a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [First a] -> Encoding #

ToJSON1 Last 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Last a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Last a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Last a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Last a] -> Encoding #

ToJSON1 Dual 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Dual a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Dual a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Dual a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Dual a] -> Encoding #

ToJSON1 NonEmpty 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> NonEmpty a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [NonEmpty a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> NonEmpty a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [NonEmpty a] -> Encoding #

ToJSON1 IntMap 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> IntMap a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [IntMap a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> IntMap a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [IntMap a] -> Encoding #

ToJSON1 Tree 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Tree a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Tree a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Tree a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Tree a] -> Encoding #

ToJSON1 Seq 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Seq a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Seq a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Seq a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Seq a] -> Encoding #

ToJSON1 Set 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Set a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Set a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Set a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Set a] -> Encoding #

ToJSON1 DList 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> DList a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [DList a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> DList a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [DList a] -> Encoding #

ToJSON1 Vector 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Vector a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Vector a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Vector a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Vector a] -> Encoding #

ToJSON1 HashSet 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> HashSet a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [HashSet a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> HashSet a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [HashSet a] -> Encoding #

ToJSON a => ToJSON1 (Either a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> Either a a0 -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [Either a a0] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> Either a a0 -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [Either a a0] -> Encoding #

ToJSON a => ToJSON1 ((,) a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, a0)] -> Encoding #

ToJSONKey k => ToJSON1 (HashMap k) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> HashMap k a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [HashMap k a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> HashMap k a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [HashMap k a] -> Encoding #

ToJSONKey k => ToJSON1 (Map k) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Map k a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Map k a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Map k a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Map k a] -> Encoding #

ToJSON1 (Proxy :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Proxy a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Proxy a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Proxy a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Proxy a] -> Encoding #

ToJSON a => ToJSON1 (These a) 
Instance details

Defined in Data.These

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> These a a0 -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [These a a0] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> These a a0 -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [These a a0] -> Encoding #

(ToJSON a, ToJSON b) => ToJSON1 ((,,) a b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, a0)] -> Encoding #

ToJSON a => ToJSON1 (Const a :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> Const a a0 -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [Const a a0] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> Const a a0 -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [Const a a0] -> Encoding #

ToJSON1 (Tagged a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> Tagged a a0 -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [Tagged a a0] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> Tagged a a0 -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [Tagged a a0] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c) => ToJSON1 ((,,,) a b c) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, a0)] -> Encoding #

(ToJSON1 f, ToJSON1 g) => ToJSON1 (Product f g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Product f g a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Product f g a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Product f g a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Product f g a] -> Encoding #

(ToJSON1 f, ToJSON1 g) => ToJSON1 (Sum f g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Sum f g a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Sum f g a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Sum f g a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Sum f g a] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON1 ((,,,,) a b c d) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, a0)] -> Encoding #

(ToJSON1 f, ToJSON1 g) => ToJSON1 (Compose f g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Compose f g a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Compose f g a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Compose f g a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Compose f g a] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) => ToJSON1 ((,,,,,) a b c d e) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, e, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, e, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, e, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, e, a0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) => ToJSON1 ((,,,,,,) a b c d e f) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, e, f, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, e, f, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, e, f, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, e, f, a0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g) => ToJSON1 ((,,,,,,,) a b c d e f g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, e, f, g, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, e, f, g, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, e, f, g, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, e, f, g, a0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h) => ToJSON1 ((,,,,,,,,) a b c d e f g h) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, e, f, g, h, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, e, f, g, h, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, e, f, g, h, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, e, f, g, h, a0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i) => ToJSON1 ((,,,,,,,,,) a b c d e f g h i) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, e, f, g, h, i, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, e, f, g, h, i, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, a0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j) => ToJSON1 ((,,,,,,,,,,) a b c d e f g h i j) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, e, f, g, h, i, j, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, e, f, g, h, i, j, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, j, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, j, a0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k) => ToJSON1 ((,,,,,,,,,,,) a b c d e f g h i j k) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, e, f, g, h, i, j, k, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, e, f, g, h, i, j, k, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, j, k, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, j, k, a0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l) => ToJSON1 ((,,,,,,,,,,,,) a b c d e f g h i j k l) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, e, f, g, h, i, j, k, l, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, e, f, g, h, i, j, k, l, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, j, k, l, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, j, k, l, a0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m) => ToJSON1 ((,,,,,,,,,,,,,) a b c d e f g h i j k l m) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, e, f, g, h, i, j, k, l, m, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, j, k, l, m, a0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n) => ToJSON1 ((,,,,,,,,,,,,,,) a b c d e f g h i j k l m n) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, a0) -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, a0)] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, a0) -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, a0)] -> Encoding #

class ToJSON2 (f :: * -> * -> *) where #

Lifting of the ToJSON class to binary type constructors.

Instead of manually writing your ToJSON2 instance, Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time.

The compiler cannot provide a default generic implementation for liftToJSON2, unlike toJSON and liftToJSON.

Minimal complete definition

liftToJSON2, liftToEncoding2

Methods

liftToJSON2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> f a b -> Value #

liftToJSONList2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [f a b] -> Value #

liftToEncoding2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> f a b -> Encoding #

liftToEncodingList2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [f a b] -> Encoding #

Instances
ToJSON2 Either 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> Either a b -> Value #

liftToJSONList2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [Either a b] -> Value #

liftToEncoding2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> Either a b -> Encoding #

liftToEncodingList2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [Either a b] -> Encoding #

ToJSON2 (,) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> (a, b) -> Value #

liftToJSONList2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [(a, b)] -> Value #

liftToEncoding2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> (a, b) -> Encoding #

liftToEncodingList2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [(a, b)] -> Encoding #

ToJSON2 These 
Instance details

Defined in Data.These

Methods

liftToJSON2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> These a b -> Value #

liftToJSONList2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [These a b] -> Value #

liftToEncoding2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> These a b -> Encoding #

liftToEncodingList2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [These a b] -> Encoding #

ToJSON a => ToJSON2 ((,,) a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b -> Value) -> ([b] -> Value) -> (a, a0, b) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b -> Value) -> ([b] -> Value) -> [(a, a0, b)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> (a, a0, b) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [(a, a0, b)] -> Encoding #

ToJSON2 (Const :: * -> * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> Const a b -> Value #

liftToJSONList2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [Const a b] -> Value #

liftToEncoding2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> Const a b -> Encoding #

liftToEncodingList2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [Const a b] -> Encoding #

ToJSON2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> Tagged a b -> Value #

liftToJSONList2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [Tagged a b] -> Value #

liftToEncoding2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> Tagged a b -> Encoding #

liftToEncodingList2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [Tagged a b] -> Encoding #

(ToJSON a, ToJSON b) => ToJSON2 ((,,,) a b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c) => ToJSON2 ((,,,,) a b c) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON2 ((,,,,,) a b c d) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, d, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, d, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, d, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, d, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) => ToJSON2 ((,,,,,,) a b c d e) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, d, e, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, d, e, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, d, e, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, d, e, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) => ToJSON2 ((,,,,,,,) a b c d e f) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, d, e, f, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, d, e, f, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, d, e, f, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, d, e, f, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g) => ToJSON2 ((,,,,,,,,) a b c d e f g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, d, e, f, g, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, d, e, f, g, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, d, e, f, g, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, d, e, f, g, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h) => ToJSON2 ((,,,,,,,,,) a b c d e f g h) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, d, e, f, g, h, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, d, e, f, g, h, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, d, e, f, g, h, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, d, e, f, g, h, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i) => ToJSON2 ((,,,,,,,,,,) a b c d e f g h i) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, d, e, f, g, h, i, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, d, e, f, g, h, i, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j) => ToJSON2 ((,,,,,,,,,,,) a b c d e f g h i j) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, d, e, f, g, h, i, j, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, d, e, f, g, h, i, j, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, j, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, j, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k) => ToJSON2 ((,,,,,,,,,,,,) a b c d e f g h i j k) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, d, e, f, g, h, i, j, k, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, d, e, f, g, h, i, j, k, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, j, k, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, j, k, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l) => ToJSON2 ((,,,,,,,,,,,,,) a b c d e f g h i j k l) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, d, e, f, g, h, i, j, k, l, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, d, e, f, g, h, i, j, k, l, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, j, k, l, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, j, k, l, a0, b0)] -> Encoding #

(ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m) => ToJSON2 ((,,,,,,,,,,,,,,) a b c d e f g h i j k l m) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, a0, b0) -> Value #

liftToJSONList2 :: (a0 -> Value) -> ([a0] -> Value) -> (b0 -> Value) -> ([b0] -> Value) -> [(a, b, c, d, e, f, g, h, i, j, k, l, m, a0, b0)] -> Value #

liftToEncoding2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, a0, b0) -> Encoding #

liftToEncodingList2 :: (a0 -> Encoding) -> ([a0] -> Encoding) -> (b0 -> Encoding) -> ([b0] -> Encoding) -> [(a, b, c, d, e, f, g, h, i, j, k, l, m, a0, b0)] -> Encoding #

pairs :: Series -> Encoding #

Encode a series of key/value pairs, separated by commas.

fromEncoding :: Encoding' tag -> Builder #

Acquire the underlying bytestring builder.

type Encoding = Encoding' Value #

Often used synonym for Encoding'.

data Series #

A series of values that, when encoded, should be separated by commas. Since 0.11.0.0, the .= operator is overloaded to create either (Text, Value) or Series. You can use Series when encoding directly to a bytestring builder as in the following example:

toEncoding (Person name age) = pairs ("name" .= name <> "age" .= age)
Instances
Semigroup Series 
Instance details

Defined in Data.Aeson.Encoding.Internal

Monoid Series 
Instance details

Defined in Data.Aeson.Encoding.Internal

KeyValue Series 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Text -> v -> Series #

e ~ Encoding => KeyValuePair e Series 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

pair :: String -> e -> Series

a ~ Value => FromPairs (Encoding' a) Series 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

fromPairs :: Series -> Encoding' a

(.!=) :: Parser (Maybe a) -> a -> Parser a #

Helper for use in combination with .:? to provide default values for optional JSON object fields.

This combinator is most useful if the key and value can be absent from an object without affecting its validity and we know a default value to assign in that case. If the key and value are mandatory, use .: instead.

Example usage:

 v1 <- o .:? "opt_field_with_dfl" .!= "default_val"
 v2 <- o .:  "mandatory_field"
 v3 <- o .:? "opt_field2"

(.:!) :: FromJSON a => Object -> Text -> Parser (Maybe a) #

Retrieve the value associated with the given key of an Object. The result is Nothing if the key is not present or empty if the value cannot be converted to the desired type.

This differs from .:? by attempting to parse Null the same as any other JSON value, instead of interpreting it as Nothing.

(.:?) :: FromJSON a => Object -> Text -> Parser (Maybe a) #

Retrieve the value associated with the given key of an Object. The result is Nothing if the key is not present or if its value is Null, or empty if the value cannot be converted to the desired type.

This accessor is most useful if the key and value can be absent from an object without affecting its validity. If the key and value are mandatory, use .: instead.

(.:) :: FromJSON a => Object -> Text -> Parser a #

Retrieve the value associated with the given key of an Object. The result is empty if the key is not present or the value cannot be converted to the desired type.

This accessor is appropriate if the key and value must be present in an object for it to be valid. If the key and value are optional, use .:? instead.

fromJSON :: FromJSON a => Value -> Result a #

Convert a value from JSON, failing if the types do not match.

withEmbeddedJSON :: String -> (Value -> Parser a) -> Value -> Parser a #

Decode a nested JSON-encoded string.

withBool :: String -> (Bool -> Parser a) -> Value -> Parser a #

withBool expected f value applies f to the Bool when value is a Bool and fails using typeMismatch expected otherwise.

withScientific :: String -> (Scientific -> Parser a) -> Value -> Parser a #

withScientific expected f value applies f to the Scientific number when value is a Number and fails using typeMismatch expected otherwise. . Warning: If you are converting from a scientific to an unbounded type such as Integer you may want to add a restriction on the size of the exponent (see withBoundedScientific) to prevent malicious input from filling up the memory of the target system.

withArray :: String -> (Array -> Parser a) -> Value -> Parser a #

withArray expected f value applies f to the Array when value is an Array and fails using typeMismatch expected otherwise.

withText :: String -> (Text -> Parser a) -> Value -> Parser a #

withText expected f value applies f to the Text when value is a String and fails using typeMismatch expected otherwise.

withObject :: String -> (Object -> Parser a) -> Value -> Parser a #

withObject expected f value applies f to the Object when value is an Object and fails using typeMismatch expected otherwise.

parseJSON2 :: (FromJSON2 f, FromJSON a, FromJSON b) => Value -> Parser (f a b) #

Lift the standard parseJSON function through the type constructor.

parseJSON1 :: (FromJSON1 f, FromJSON a) => Value -> Parser (f a) #

Lift the standard parseJSON function through the type constructor.

genericLiftParseJSON :: (Generic1 f, GFromJSON One (Rep1 f)) => Options -> (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (f a) #

A configurable generic JSON decoder. This function applied to defaultOptions is used as the default for liftParseJSON when the type is an instance of Generic1.

genericParseJSON :: (Generic a, GFromJSON Zero (Rep a)) => Options -> Value -> Parser a #

A configurable generic JSON decoder. This function applied to defaultOptions is used as the default for parseJSON when the type is an instance of Generic.

class GFromJSON arity (f :: * -> *) where #

Class of generic representation types that can be converted from JSON.

Minimal complete definition

gParseJSON

Methods

gParseJSON :: Options -> FromArgs arity a -> Value -> Parser (f a) #

This method (applied to defaultOptions) is used as the default generic implementation of parseJSON (if the arity is Zero) or liftParseJSON (if the arity is One).

Instances
GFromJSON One Par1 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs One a -> Value -> Parser (Par1 a) #

GFromJSON arity (U1 :: * -> *) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs arity a -> Value -> Parser (U1 a) #

FromJSON1 f => GFromJSON One (Rec1 f) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs One a -> Value -> Parser (Rec1 f a) #

(ConsFromJSON arity a, AllNullary (C1 c a) allNullary, ParseSum arity (C1 c a) allNullary) => GFromJSON arity (D1 d (C1 c a)) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs arity a0 -> Value -> Parser (D1 d (C1 c a) a0) #

ConsFromJSON arity a => GFromJSON arity (C1 c a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs arity a0 -> Value -> Parser (C1 c a a0) #

FromJSON a => GFromJSON arity (K1 i a :: * -> *) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs arity a0 -> Value -> Parser (K1 i a a0) #

(AllNullary (a :+: b) allNullary, ParseSum arity (a :+: b) allNullary) => GFromJSON arity (a :+: b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs arity a0 -> Value -> Parser ((a :+: b) a0) #

(FromProduct arity a, FromProduct arity b, ProductSize a, ProductSize b) => GFromJSON arity (a :*: b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs arity a0 -> Value -> Parser ((a :*: b) a0) #

GFromJSON arity a => GFromJSON arity (M1 i c a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs arity a0 -> Value -> Parser (M1 i c a a0) #

(FromJSON1 f, GFromJSON One g) => GFromJSON One (f :.: g) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs One a -> Value -> Parser ((f :.: g) a) #

data FromArgs arity a where #

A FromArgs value either stores nothing (for FromJSON) or it stores the two function arguments that decode occurrences of the type parameter (for FromJSON1).

Constructors

NoFromArgs :: FromArgs Zero a 
From1Args :: FromArgs One a 

class FromJSON a where #

A type that can be converted from JSON, with the possibility of failure.

In many cases, you can get the compiler to generate parsing code for you (see below). To begin, let's cover writing an instance by hand.

There are various reasons a conversion could fail. For example, an Object could be missing a required key, an Array could be of the wrong size, or a value could be of an incompatible type.

The basic ways to signal a failed conversion are as follows:

  • empty and mzero work, but are terse and uninformative;
  • fail yields a custom error message;
  • typeMismatch produces an informative message for cases when the value encountered is not of the expected type.

An example type and instance using typeMismatch:

-- Allow ourselves to write Text literals.
{-# LANGUAGE OverloadedStrings #-}

data Coord = Coord { x :: Double, y :: Double }

instance FromJSON Coord where
    parseJSON (Object v) = Coord
        <$> v .: "x"
        <*> v .: "y"

    -- We do not expect a non-Object value here.
    -- We could use mzero to fail, but typeMismatch
    -- gives a much more informative error message.
    parseJSON invalid    = typeMismatch "Coord" invalid

For this common case of only being concerned with a single type of JSON value, the functions withObject, withNumber, etc. are provided. Their use is to be preferred when possible, since they are more terse. Using withObject, we can rewrite the above instance (assuming the same language extension and data type) as:

instance FromJSON Coord where
    parseJSON = withObject "Coord" $ \v -> Coord
        <$> v .: "x"
        <*> v .: "y"

Instead of manually writing your FromJSON instance, there are two options to do it automatically:

  • Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
  • The compiler can provide a default generic implementation for parseJSON.

To use the second, simply add a deriving Generic clause to your datatype and declare a FromJSON instance for your datatype without giving a definition for parseJSON.

For example, the previous example can be simplified to just:

{-# LANGUAGE DeriveGeneric #-}

import GHC.Generics

data Coord = Coord { x :: Double, y :: Double } deriving Generic

instance FromJSON Coord

The default implementation will be equivalent to parseJSON = genericParseJSON defaultOptions; If you need different options, you can customize the generic decoding by defining:

customOptions = defaultOptions
                { fieldLabelModifier = map toUpper
                }

instance FromJSON Coord where
    parseJSON = genericParseJSON customOptions

Methods

parseJSON :: Value -> Parser a #

parseJSONList :: Value -> Parser [a] #

Instances
FromJSON Bool 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Char 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Double 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Float 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Int 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Int8 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Int16 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Int32 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Int64 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Integer

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Natural 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Ordering 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Word 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Word8 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Word16 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Word32 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Word64 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON () 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser () #

parseJSONList :: Value -> Parser [()] #

FromJSON Version 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Scientific 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Text 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON UTCTime 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Value 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON DotNetTime 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Text 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON CTime 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON IntSet 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON DiffTime

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Day 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON NominalDiffTime

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON TimeOfDay 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON LocalTime 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON ZonedTime

Supported string formats:

YYYY-MM-DD HH:MM Z YYYY-MM-DD HH:MM:SS Z YYYY-MM-DD HH:MM:SS.SSS Z

The first space may instead be a T, and the second space is optional. The Z represents UTC. The Z may be replaced with a time zone offset of the form +0000 or -08:00, where the first two digits are hours, the : is optional and the second two digits (also optional) are minutes.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON UUID 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON [a] 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser [a] #

parseJSONList :: Value -> Parser [[a]] #

FromJSON a => FromJSON (Maybe a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(FromJSON a, Integral a) => FromJSON (Ratio a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

HasResolution a => FromJSON (Fixed a)

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (Min a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Min a) #

parseJSONList :: Value -> Parser [Min a] #

FromJSON a => FromJSON (Max a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Max a) #

parseJSONList :: Value -> Parser [Max a] #

FromJSON a => FromJSON (First a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (Last a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (WrappedMonoid a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (Option a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (Identity a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (First a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (Last a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (Dual a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (NonEmpty a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (IntMap a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON v => FromJSON (Tree v) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (Seq a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Seq a) #

parseJSONList :: Value -> Parser [Seq a] #

(Ord a, FromJSON a) => FromJSON (Set a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Set a) #

parseJSONList :: Value -> Parser [Set a] #

FromJSON a => FromJSON (DList a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON (Vector a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(Storable a, FromJSON a) => FromJSON (Vector a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(Vector Vector a, FromJSON a) => FromJSON (Vector a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(Eq a, Hashable a, FromJSON a) => FromJSON (HashSet a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(Prim a, FromJSON a) => FromJSON (Vector a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(FromJSON a, FromJSON b) => FromJSON (Either a b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Either a b) #

parseJSONList :: Value -> Parser [Either a b] #

(FromJSON a, FromJSON b) => FromJSON (a, b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b) #

parseJSONList :: Value -> Parser [(a, b)] #

(FromJSON v, FromJSONKey k, Eq k, Hashable k) => FromJSON (HashMap k v) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(FromJSONKey k, Ord k, FromJSON v) => FromJSON (Map k v) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Map k v) #

parseJSONList :: Value -> Parser [Map k v] #

FromJSON (Proxy a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(FromJSON a, FromJSON b) => FromJSON (These a b) 
Instance details

Defined in Data.These

Methods

parseJSON :: Value -> Parser (These a b) #

parseJSONList :: Value -> Parser [These a b] #

(FromJSON α, Predicate ρ α) => FromJSON (Refined ρ α) # 
Instance details

Defined in Magicbane.Validation

Methods

parseJSON :: Value -> Parser (Refined ρ α) #

parseJSONList :: Value -> Parser [Refined ρ α] #

(FromJSON a, FromJSON b, FromJSON c) => FromJSON (a, b, c) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c) #

parseJSONList :: Value -> Parser [(a, b, c)] #

FromJSON a => FromJSON (Const a b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Const a b) #

parseJSONList :: Value -> Parser [Const a b] #

FromJSON b => FromJSON (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Tagged a b) #

parseJSONList :: Value -> Parser [Tagged a b] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d) => FromJSON (a, b, c, d) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d) #

parseJSONList :: Value -> Parser [(a, b, c, d)] #

(FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON (Product f g a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Product f g a) #

parseJSONList :: Value -> Parser [Product f g a] #

(FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON (Sum f g a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Sum f g a) #

parseJSONList :: Value -> Parser [Sum f g a] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e) => FromJSON (a, b, c, d, e) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e) #

parseJSONList :: Value -> Parser [(a, b, c, d, e)] #

(FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON (Compose f g a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Compose f g a) #

parseJSONList :: Value -> Parser [Compose f g a] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f) => FromJSON (a, b, c, d, e, f) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g) => FromJSON (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h) => FromJSON (a, b, c, d, e, f, g, h) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i) => FromJSON (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j) => FromJSON (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k) => FromJSON (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m, FromJSON n) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m, n) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m, FromJSON n, FromJSON o) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] #

class FromJSONKey a where #

Read the docs for ToJSONKey first. This class is a conversion in the opposite direction. If you have a newtype wrapper around Text, the recommended way to define instances is with generalized newtype deriving:

newtype SomeId = SomeId { getSomeId :: Text }
  deriving (Eq,Ord,Hashable,FromJSONKey)

Methods

fromJSONKey :: FromJSONKeyFunction a #

Strategy for parsing the key of a map-like container.

fromJSONKeyList :: FromJSONKeyFunction [a] #

This is similar in spirit to the readList method of Read. It makes it possible to give String keys special treatment without using OverlappingInstances. End users should always be able to use the default implementation of this method.

Instances
FromJSONKey Bool 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Char 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Double 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Float 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Int 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Int8 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Int16 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Int32 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Int64 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Integer 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Natural 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Word 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Word8 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Word16 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Word32 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Word64 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Version 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Text 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey UTCTime 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Text 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Day 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey TimeOfDay 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey LocalTime 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey ZonedTime 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey UUID 
Instance details

Defined in Data.Aeson.Types.FromJSON

(FromJSONKey a, FromJSON a) => FromJSONKey [a] 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey a => FromJSONKey (Identity a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(FromJSON a, FromJSON b) => FromJSONKey (a, b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(FromJSON a, FromJSON b, FromJSON c) => FromJSONKey (a, b, c) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey b => FromJSONKey (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

(FromJSON a, FromJSON b, FromJSON c, FromJSON d) => FromJSONKey (a, b, c, d) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

fromJSONKey :: FromJSONKeyFunction (a, b, c, d) #

fromJSONKeyList :: FromJSONKeyFunction [(a, b, c, d)] #

data FromJSONKeyFunction a #

This type is related to ToJSONKeyFunction. If FromJSONKeyValue is used in the FromJSONKey instance, then ToJSONKeyValue should be used in the ToJSONKey instance. The other three data constructors for this type all correspond to ToJSONKeyText. Strictly speaking, FromJSONKeyTextParser is more powerful than FromJSONKeyText, which is in turn more powerful than FromJSONKeyCoerce. For performance reasons, these exist as three options instead of one.

Constructors

FromJSONKeyCoerce !(CoerceText a)

uses coerce (unsafeCoerce in older GHCs)

FromJSONKeyText !(Text -> a)

conversion from Text that always succeeds

FromJSONKeyTextParser !(Text -> Parser a)

conversion from Text that may fail

FromJSONKeyValue !(Value -> Parser a)

conversion for non-textual keys

Instances
Functor FromJSONKeyFunction

Only law abiding up to interpretation

Instance details

Defined in Data.Aeson.Types.FromJSON

class FromJSON1 (f :: * -> *) where #

Lifting of the FromJSON class to unary type constructors.

Instead of manually writing your FromJSON1 instance, there are two options to do it automatically:

  • Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
  • The compiler can provide a default generic implementation for liftParseJSON.

To use the second, simply add a deriving Generic1 clause to your datatype and declare a FromJSON1 instance for your datatype without giving a definition for liftParseJSON.

For example:

{-# LANGUAGE DeriveGeneric #-}

import GHC.Generics

data Pair a b = Pair { pairFst :: a, pairSnd :: b } deriving Generic1

instance FromJSON a => FromJSON1 (Pair a)

If the default implementation doesn't give exactly the results you want, you can customize the generic decoding with only a tiny amount of effort, using genericLiftParseJSON with your preferred Options:

customOptions = defaultOptions
                { fieldLabelModifier = map toUpper
                }

instance FromJSON a => FromJSON1 (Pair a) where
    liftParseJSON = genericLiftParseJSON customOptions

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (f a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [f a] #

Instances
FromJSON1 [] 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [a] #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [[a]] #

FromJSON1 Maybe 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Maybe a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Maybe a] #

FromJSON1 Min 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Min a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Min a] #

FromJSON1 Max 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Max a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Max a] #

FromJSON1 First 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (First a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [First a] #

FromJSON1 Last 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Last a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Last a] #

FromJSON1 WrappedMonoid 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (WrappedMonoid a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [WrappedMonoid a] #

FromJSON1 Option 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Option a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Option a] #

FromJSON1 Identity 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Identity a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Identity a] #

FromJSON1 First 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (First a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [First a] #

FromJSON1 Last 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Last a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Last a] #

FromJSON1 Dual 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Dual a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Dual a] #

FromJSON1 NonEmpty 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (NonEmpty a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [NonEmpty a] #

FromJSON1 IntMap 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (IntMap a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [IntMap a] #

FromJSON1 Tree 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Tree a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Tree a] #

FromJSON1 Seq 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Seq a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Seq a] #

FromJSON1 DList 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (DList a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [DList a] #

FromJSON1 Vector 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Vector a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Vector a] #

FromJSON a => FromJSON1 (Either a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (Either a a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [Either a a0] #

FromJSON a => FromJSON1 ((,) a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, a0)] #

(FromJSONKey k, Eq k, Hashable k) => FromJSON1 (HashMap k) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (HashMap k a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [HashMap k a] #

(FromJSONKey k, Ord k) => FromJSON1 (Map k) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Map k a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Map k a] #

FromJSON1 (Proxy :: * -> *) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Proxy a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Proxy a] #

FromJSON a => FromJSON1 (These a) 
Instance details

Defined in Data.These

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (These a a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [These a a0] #

(FromJSON a, FromJSON b) => FromJSON1 ((,,) a b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, a0)] #

FromJSON a => FromJSON1 (Const a :: * -> *) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (Const a a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [Const a a0] #

FromJSON1 (Tagged a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (Tagged a a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [Tagged a a0] #

(FromJSON a, FromJSON b, FromJSON c) => FromJSON1 ((,,,) a b c) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, a0)] #

(FromJSON1 f, FromJSON1 g) => FromJSON1 (Product f g) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Product f g a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Product f g a] #

(FromJSON1 f, FromJSON1 g) => FromJSON1 (Sum f g) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Sum f g a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Sum f g a] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d) => FromJSON1 ((,,,,) a b c d) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, a0)] #

(FromJSON1 f, FromJSON1 g) => FromJSON1 (Compose f g) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Compose f g a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Compose f g a] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e) => FromJSON1 ((,,,,,) a b c d e) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, e, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, e, a0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f) => FromJSON1 ((,,,,,,) a b c d e f) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, e, f, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, e, f, a0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g) => FromJSON1 ((,,,,,,,) a b c d e f g) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, e, f, g, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, e, f, g, a0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h) => FromJSON1 ((,,,,,,,,) a b c d e f g h) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, e, f, g, h, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, a0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i) => FromJSON1 ((,,,,,,,,,) a b c d e f g h i) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, a0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j) => FromJSON1 ((,,,,,,,,,,) a b c d e f g h i j) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, j, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, j, a0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k) => FromJSON1 ((,,,,,,,,,,,) a b c d e f g h i j k) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, a0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l) => FromJSON1 ((,,,,,,,,,,,,) a b c d e f g h i j k l) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, a0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m) => FromJSON1 ((,,,,,,,,,,,,,) a b c d e f g h i j k l m) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m, a0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m, FromJSON n) => FromJSON1 ((,,,,,,,,,,,,,,) a b c d e f g h i j k l m n) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m, n, a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, a0)] #

class FromJSON2 (f :: * -> * -> *) where #

Lifting of the FromJSON class to binary type constructors.

Instead of manually writing your FromJSON2 instance, Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time.

Minimal complete definition

liftParseJSON2

Methods

liftParseJSON2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (f a b) #

liftParseJSONList2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [f a b] #

Instances
FromJSON2 Either 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (Either a b) #

liftParseJSONList2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [Either a b] #

FromJSON2 (,) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (a, b) #

liftParseJSONList2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [(a, b)] #

FromJSON2 These 
Instance details

Defined in Data.These

Methods

liftParseJSON2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (These a b) #

liftParseJSONList2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [These a b] #

FromJSON a => FromJSON2 ((,,) a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (a, a0, b) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [(a, a0, b)] #

FromJSON2 (Const :: * -> * -> *) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (Const a b) #

liftParseJSONList2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [Const a b] #

FromJSON2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (Tagged a b) #

liftParseJSONList2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [Tagged a b] #

(FromJSON a, FromJSON b) => FromJSON2 ((,,,) a b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c) => FromJSON2 ((,,,,) a b c) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d) => FromJSON2 ((,,,,,) a b c d) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, d, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, d, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e) => FromJSON2 ((,,,,,,) a b c d e) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, d, e, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, d, e, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f) => FromJSON2 ((,,,,,,,) a b c d e f) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, d, e, f, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, d, e, f, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g) => FromJSON2 ((,,,,,,,,) a b c d e f g) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, d, e, f, g, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, d, e, f, g, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h) => FromJSON2 ((,,,,,,,,,) a b c d e f g h) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, d, e, f, g, h, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i) => FromJSON2 ((,,,,,,,,,,) a b c d e f g h i) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j) => FromJSON2 ((,,,,,,,,,,,) a b c d e f g h i j) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, j, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, j, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k) => FromJSON2 ((,,,,,,,,,,,,) a b c d e f g h i j k) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l) => FromJSON2 ((,,,,,,,,,,,,,) a b c d e f g h i j k l) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, a0, b0)] #

(FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m) => FromJSON2 ((,,,,,,,,,,,,,,) a b c d e f g h i j k l m) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m, a0, b0) #

liftParseJSONList2 :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> (Value -> Parser b0) -> (Value -> Parser [b0]) -> Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m, a0, b0)] #

json' :: Parser Value #

Parse a top-level JSON value.

This is a strict version of json which avoids building up thunks during parsing; it performs all conversions immediately. Prefer this version if most of the JSON data needs to be accessed.

This function is an alias for value'. In aeson 0.8 and earlier, it parsed only object or array types, in conformance with the now-obsolete RFC 4627.

json :: Parser Value #

Parse a top-level JSON value.

The conversion of a parsed value to a Haskell value is deferred until the Haskell value is needed. This may improve performance if only a subset of the results of conversions are needed, but at a cost in thunk allocation.

This function is an alias for value. In aeson 0.8 and earlier, it parsed only object or array types, in conformance with the now-obsolete RFC 4627.

camelTo2 :: Char -> String -> String #

Better version of camelTo. Example where it works better:

camelTo '_' 'CamelAPICase' == "camel_apicase"
camelTo2 '_' 'CamelAPICase' == "camel_api_case"

defaultTaggedObject :: SumEncoding #

Default TaggedObject SumEncoding options:

defaultTaggedObject = TaggedObject
                      { tagFieldName      = "tag"
                      , contentsFieldName = "contents"
                      }

object :: [Pair] -> Value #

Create a Value from a list of name/value Pairs. If duplicate keys arise, earlier keys and their associated values win.

data Result a #

The result of running a Parser.

Constructors

Error String 
Success a 
Instances
Monad Result 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(>>=) :: Result a -> (a -> Result b) -> Result b #

(>>) :: Result a -> Result b -> Result b #

return :: a -> Result a #

fail :: String -> Result a #

Functor Result 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fmap :: (a -> b) -> Result a -> Result b #

(<$) :: a -> Result b -> Result a #

MonadFail Result 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fail :: String -> Result a #

Applicative Result 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

pure :: a -> Result a #

(<*>) :: Result (a -> b) -> Result a -> Result b #

liftA2 :: (a -> b -> c) -> Result a -> Result b -> Result c #

(*>) :: Result a -> Result b -> Result b #

(<*) :: Result a -> Result b -> Result a #

Foldable Result 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fold :: Monoid m => Result m -> m #

foldMap :: Monoid m => (a -> m) -> Result a -> m #

foldr :: (a -> b -> b) -> b -> Result a -> b #

foldr' :: (a -> b -> b) -> b -> Result a -> b #

foldl :: (b -> a -> b) -> b -> Result a -> b #

foldl' :: (b -> a -> b) -> b -> Result a -> b #

foldr1 :: (a -> a -> a) -> Result a -> a #

foldl1 :: (a -> a -> a) -> Result a -> a #

toList :: Result a -> [a] #

null :: Result a -> Bool #

length :: Result a -> Int #

elem :: Eq a => a -> Result a -> Bool #

maximum :: Ord a => Result a -> a #

minimum :: Ord a => Result a -> a #

sum :: Num a => Result a -> a #

product :: Num a => Result a -> a #

Traversable Result 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

traverse :: Applicative f => (a -> f b) -> Result a -> f (Result b) #

sequenceA :: Applicative f => Result (f a) -> f (Result a) #

mapM :: Monad m => (a -> m b) -> Result a -> m (Result b) #

sequence :: Monad m => Result (m a) -> m (Result a) #

Alternative Result 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

empty :: Result a #

(<|>) :: Result a -> Result a -> Result a #

some :: Result a -> Result [a] #

many :: Result a -> Result [a] #

MonadPlus Result 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

mzero :: Result a #

mplus :: Result a -> Result a -> Result a #

Eq a => Eq (Result a) 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(==) :: Result a -> Result a -> Bool #

(/=) :: Result a -> Result a -> Bool #

Show a => Show (Result a) 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

showsPrec :: Int -> Result a -> ShowS #

show :: Result a -> String #

showList :: [Result a] -> ShowS #

Semigroup (Result a) 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(<>) :: Result a -> Result a -> Result a #

sconcat :: NonEmpty (Result a) -> Result a #

stimes :: Integral b => b -> Result a -> Result a #

Monoid (Result a) 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

mempty :: Result a #

mappend :: Result a -> Result a -> Result a #

mconcat :: [Result a] -> Result a #

NFData a => NFData (Result a) 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

rnf :: Result a -> () #

type Object = HashMap Text Value #

A JSON "object" (key/value map).

type Array = Vector Value #

A JSON "array" (sequence).

data Value #

A JSON value represented as a Haskell value.

Instances
Eq Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Data Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Value -> c Value #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Value #

toConstr :: Value -> Constr #

dataTypeOf :: Value -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Value) #

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

gmapT :: (forall b. Data b => b -> b) -> Value -> Value #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r #

gmapQ :: (forall d. Data d => d -> u) -> Value -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Value -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Value -> m Value #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value #

Read Value 
Instance details

Defined in Data.Aeson.Types.Internal

Show Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

IsString Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fromString :: String -> Value #

Generic Value 
Instance details

Defined in Data.Aeson.Types.Internal

Associated Types

type Rep Value :: * -> * #

Methods

from :: Value -> Rep Value x #

to :: Rep Value x -> Value #

Lift Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

lift :: Value -> Q Exp #

Hashable Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

hashWithSalt :: Int -> Value -> Int #

hash :: Value -> Int #

ToJSON Value 
Instance details

Defined in Data.Aeson.Types.ToJSON

KeyValue Pair 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Text -> v -> Pair #

FromJSON Value 
Instance details

Defined in Data.Aeson.Types.FromJSON

NFData Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

rnf :: Value -> () #

FromString Encoding 
Instance details

Defined in Data.Aeson.Types.ToJSON

FromString Value 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

fromString :: String -> Value

GToJSON Encoding arity (U1 :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a -> U1 a -> Encoding

GToJSON Value arity (U1 :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a -> U1 a -> Value

ToJSON1 f => GToJSON Encoding One (Rec1 f) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding One a -> Rec1 f a -> Encoding

ToJSON1 f => GToJSON Value One (Rec1 f) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value One a -> Rec1 f a -> Value

ToJSON a => GToJSON Encoding arity (K1 i a :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a0 -> K1 i a a0 -> Encoding

(EncodeProduct arity a, EncodeProduct arity b) => GToJSON Encoding arity (a :*: b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a0 -> (a :*: b) a0 -> Encoding

ToJSON a => GToJSON Value arity (K1 i a :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a0 -> K1 i a a0 -> Value

(WriteProduct arity a, WriteProduct arity b, ProductSize a, ProductSize b) => GToJSON Value arity (a :*: b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a0 -> (a :*: b) a0 -> Value

(ToJSON1 f, GToJSON Encoding One g) => GToJSON Encoding One (f :.: g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding One a -> (f :.: g) a -> Encoding

(ToJSON1 f, GToJSON Value One g) => GToJSON Value One (f :.: g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value One a -> (f :.: g) a -> Value

FromPairs Value (DList Pair) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

fromPairs :: DList Pair -> Value

v ~ Value => KeyValuePair v (DList Pair) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

pair :: String -> v -> DList Pair

(GToJSON Encoding arity a, ConsToJSON Encoding arity a, Constructor c) => SumToJSON' TwoElemArray Encoding arity (C1 c a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

sumToJSON' :: Options -> ToArgs Encoding arity a0 -> C1 c a a0 -> Tagged TwoElemArray Encoding

(GToJSON Value arity a, ConsToJSON Value arity a, Constructor c) => SumToJSON' TwoElemArray Value arity (C1 c a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

sumToJSON' :: Options -> ToArgs Value arity a0 -> C1 c a a0 -> Tagged TwoElemArray Value

type Rep Value 
Instance details

Defined in Data.Aeson.Types.Internal

newtype DotNetTime #

A newtype wrapper for UTCTime that uses the same non-standard serialization format as Microsoft .NET, whose System.DateTime type is by default serialized to JSON as in the following example:

/Date(1302547608878)/

The number represents milliseconds since the Unix epoch.

Constructors

DotNetTime 

Fields

Instances
Eq DotNetTime 
Instance details

Defined in Data.Aeson.Types.Internal

Ord DotNetTime 
Instance details

Defined in Data.Aeson.Types.Internal

Read DotNetTime 
Instance details

Defined in Data.Aeson.Types.Internal

Show DotNetTime 
Instance details

Defined in Data.Aeson.Types.Internal

ToJSON DotNetTime 
Instance details

Defined in Data.Aeson.Types.ToJSON

FromJSON DotNetTime 
Instance details

Defined in Data.Aeson.Types.FromJSON

FormatTime DotNetTime 
Instance details

Defined in Data.Aeson.Types.Internal

data Options #

Options that specify how to encode/decode your datatype to/from JSON.

Options can be set using record syntax on defaultOptions with the fields below.

Instances
Show Options 
Instance details

Defined in Data.Aeson.Types.Internal

data SumEncoding #

Specifies how to encode constructors of a sum datatype.

Constructors

TaggedObject

A constructor will be encoded to an object with a field tagFieldName which specifies the constructor tag (modified by the constructorTagModifier). If the constructor is a record the encoded record fields will be unpacked into this object. So make sure that your record doesn't have a field with the same label as the tagFieldName. Otherwise the tag gets overwritten by the encoded value of that field! If the constructor is not a record the encoded constructor contents will be stored under the contentsFieldName field.

UntaggedValue

Constructor names won't be encoded. Instead only the contents of the constructor will be encoded as if the type had a single constructor. JSON encodings have to be disjoint for decoding to work properly.

When decoding, constructors are tried in the order of definition. If some encodings overlap, the first one defined will succeed.

Note: Nullary constructors are encoded as strings (using constructorTagModifier). Having a nullary constructor alongside a single field constructor that encodes to a string leads to ambiguity.

Note: Only the last error is kept when decoding, so in the case of malformed JSON, only an error for the last constructor will be reported.

ObjectWithSingleField

A constructor will be encoded to an object with a single field named after the constructor tag (modified by the constructorTagModifier) which maps to the encoded contents of the constructor.

TwoElemArray

A constructor will be encoded to a 2-element array where the first element is the tag of the constructor (modified by the constructorTagModifier) and the second element the encoded contents of the constructor.

Instances
Eq SumEncoding 
Instance details

Defined in Data.Aeson.Types.Internal

Show SumEncoding 
Instance details

Defined in Data.Aeson.Types.Internal

data Zero #

A type-level indicator that ToJSON or FromJSON is being derived generically.

data One #

A type-level indicator that ToJSON1 or FromJSON1 is being derived generically.

Instances
GFromJSON One Par1 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs One a -> Value -> Parser (Par1 a) #

GToJSON enc One Par1 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs enc One a -> Par1 a -> enc

ToJSON1 f => GToJSON Encoding One (Rec1 f) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding One a -> Rec1 f a -> Encoding

ToJSON1 f => GToJSON Value One (Rec1 f) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value One a -> Rec1 f a -> Value

(ToJSON1 f, GToJSON Encoding One g) => GToJSON Encoding One (f :.: g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding One a -> (f :.: g) a -> Encoding

(ToJSON1 f, GToJSON Value One g) => GToJSON Value One (f :.: g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value One a -> (f :.: g) a -> Value

FromJSON1 f => GFromJSON One (Rec1 f) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs One a -> Value -> Parser (Rec1 f a) #

(FromJSON1 f, GFromJSON One g) => GFromJSON One (f :.: g) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

gParseJSON :: Options -> FromArgs One a -> Value -> Parser ((f :.: g) a) #

data ThreadId #

A ThreadId is an abstract type representing a handle to a thread. ThreadId is an instance of Eq, Ord and Show, where the Ord instance implements an arbitrary total ordering over ThreadIds. The Show instance lets you convert an arbitrary-valued ThreadId to string form; showing a ThreadId value is occasionally useful when debugging or diagnosing the behaviour of a concurrent program.

Note: in GHC, if you have a ThreadId, you essentially have a pointer to the thread itself. This means the thread itself can't be garbage collected until you drop the ThreadId. This misfeature will hopefully be corrected at a later date.

Instances
Eq ThreadId

Since: base-4.2.0.0

Instance details

Defined in GHC.Conc.Sync

Ord ThreadId

Since: base-4.2.0.0

Instance details

Defined in GHC.Conc.Sync

Show ThreadId

Since: base-4.2.0.0

Instance details

Defined in GHC.Conc.Sync

Hashable ThreadId 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSalt :: Int -> ThreadId -> Int #

hash :: ThreadId -> Int #

NFData ThreadId

Since: deepseq-1.4.0.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: ThreadId -> () #

PrimUnlifted ThreadId

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.UnliftedArray

rtsSupportsBoundThreads :: Bool #

True if bound threads are supported. If rtsSupportsBoundThreads is False, isCurrentThreadBound will always return False and both forkOS and runInBoundThread will fail.

data Chan a #

Chan is an abstract type representing an unbounded FIFO channel.

Instances
Eq (Chan a) 
Instance details

Defined in Control.Concurrent.Chan

Methods

(==) :: Chan a -> Chan a -> Bool #

(/=) :: Chan a -> Chan a -> Bool #

data SomeAsyncException where #

Superclass for asynchronous exceptions.

Since: base-4.7.0.0

data IOException #

Exceptions that occur in the IO monad. An IOException records a more specific error type, a descriptive string and maybe the handle that was used when the error was flagged.

Instances
Eq IOException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Show IOException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception IOException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Error IOException 
Instance details

Defined in Control.Monad.Trans.Error

Display IOException

Since: rio-0.1.0.0

Instance details

Defined in RIO.Prelude.Display

MonadError IOException IO 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: IOException -> IO a #

catchError :: IO a -> (IOException -> IO a) -> IO a #

class (Typeable e, Show e) => Exception e where #

Any type that you wish to throw or catch as an exception must be an instance of the Exception class. The simplest case is a new exception type directly below the root:

data MyException = ThisException | ThatException
    deriving Show

instance Exception MyException

The default method definitions in the Exception class do what we need in this case. You can now throw and catch ThisException and ThatException as exceptions:

*Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
Caught ThisException

In more complicated examples, you may wish to define a whole hierarchy of exceptions:

---------------------------------------------------------------------
-- Make the root exception type for all the exceptions in a compiler

data SomeCompilerException = forall e . Exception e => SomeCompilerException e

instance Show SomeCompilerException where
    show (SomeCompilerException e) = show e

instance Exception SomeCompilerException

compilerExceptionToException :: Exception e => e -> SomeException
compilerExceptionToException = toException . SomeCompilerException

compilerExceptionFromException :: Exception e => SomeException -> Maybe e
compilerExceptionFromException x = do
    SomeCompilerException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make a subhierarchy for exceptions in the frontend of the compiler

data SomeFrontendException = forall e . Exception e => SomeFrontendException e

instance Show SomeFrontendException where
    show (SomeFrontendException e) = show e

instance Exception SomeFrontendException where
    toException = compilerExceptionToException
    fromException = compilerExceptionFromException

frontendExceptionToException :: Exception e => e -> SomeException
frontendExceptionToException = toException . SomeFrontendException

frontendExceptionFromException :: Exception e => SomeException -> Maybe e
frontendExceptionFromException x = do
    SomeFrontendException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make an exception type for a particular frontend compiler exception

data MismatchedParentheses = MismatchedParentheses
    deriving Show

instance Exception MismatchedParentheses where
    toException   = frontendExceptionToException
    fromException = frontendExceptionFromException

We can now catch a MismatchedParentheses exception as MismatchedParentheses, SomeFrontendException or SomeCompilerException, but not other types, e.g. IOException:

*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
*** Exception: MismatchedParentheses

Methods

toException :: e -> SomeException #

fromException :: SomeException -> Maybe e #

displayException :: e -> String #

Render this exception value in a human-friendly manner.

Default implementation: show.

Since: base-4.8.0.0

Instances
Exception AsyncCancelled 
Instance details

Defined in Control.Concurrent.Async

Exception ExceptionInLinkedThread 
Instance details

Defined in Control.Concurrent.Async

Exception Void

Since: base-4.8.0.0

Instance details

Defined in Data.Void

Exception BlockedIndefinitelyOnMVar

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception BlockedIndefinitelyOnSTM

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception Deadlock

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception AllocationLimitExceeded

Since: base-4.8.0.0

Instance details

Defined in GHC.IO.Exception

Exception CompactionFailed

Since: base-4.10.0.0

Instance details

Defined in GHC.IO.Exception

Exception AssertionFailed

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception SomeAsyncException

Since: base-4.7.0.0

Instance details

Defined in GHC.IO.Exception

Exception AsyncException

Since: base-4.7.0.0

Instance details

Defined in GHC.IO.Exception

Exception ArrayException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception FixIOException

Since: base-4.11.0.0

Instance details

Defined in GHC.IO.Exception

Exception ExitCode

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception IOException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception ErrorCall

Since: base-4.0.0.0

Instance details

Defined in GHC.Exception

Exception ArithException

Since: base-4.0.0.0

Instance details

Defined in GHC.Exception

Exception SomeException

Since: base-3.0

Instance details

Defined in GHC.Exception

Exception ASCII7_Invalid 
Instance details

Defined in Basement.String.Encoding.ASCII7

Methods

toException :: ASCII7_Invalid -> SomeException #

fromException :: SomeException -> Maybe ASCII7_Invalid #

displayException :: ASCII7_Invalid -> String #

Exception ISO_8859_1_Invalid 
Instance details

Defined in Basement.String.Encoding.ISO_8859_1

Methods

toException :: ISO_8859_1_Invalid -> SomeException #

fromException :: SomeException -> Maybe ISO_8859_1_Invalid #

displayException :: ISO_8859_1_Invalid -> String #

Exception UTF16_Invalid 
Instance details

Defined in Basement.String.Encoding.UTF16

Methods

toException :: UTF16_Invalid -> SomeException #

fromException :: SomeException -> Maybe UTF16_Invalid #

displayException :: UTF16_Invalid -> String #

Exception UTF32_Invalid 
Instance details

Defined in Basement.String.Encoding.UTF32

Methods

toException :: UTF32_Invalid -> SomeException #

fromException :: SomeException -> Maybe UTF32_Invalid #

displayException :: UTF32_Invalid -> String #

Exception CryptoError 
Instance details

Defined in Crypto.Error.Types

Exception HttpExceptionContentWrapper 
Instance details

Defined in Network.HTTP.Client.Types

Methods

toException :: HttpExceptionContentWrapper -> SomeException #

fromException :: SomeException -> Maybe HttpExceptionContentWrapper #

displayException :: HttpExceptionContentWrapper -> String #

Exception HttpException 
Instance details

Defined in Network.HTTP.Client.Types

Exception DigestAuthException 
Instance details

Defined in Network.HTTP.Client.TLS

Exception RefineException

Encode a RefineException for use with Control.Exception.

Instance details

Defined in Refined

Exception InvalidAccess 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Exception ResourceCleanupException 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Exception StringException

Since: unliftio-0.1.0.0

Instance details

Defined in UnliftIO.Exception

Exception AsyncExceptionWrapper

Since: unliftio-0.1.0.0

Instance details

Defined in UnliftIO.Exception

Exception SyncExceptionWrapper

Since: unliftio-0.1.0.0

Instance details

Defined in UnliftIO.Exception

Exception UnicodeException 
Instance details

Defined in Data.Text.Encoding.Error

Exception ServantErr 
Instance details

Defined in Servant.Server.Internal.ServantErr

Exception NullError 
Instance details

Defined in Data.NonNull

Methods

toException :: NullError -> SomeException #

fromException :: SomeException -> Maybe NullError #

displayException :: NullError -> String #

asProxyTypeOf :: a -> proxy a -> a #

asProxyTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the tag of the second.

>>> import Data.Word
>>> :type asProxyTypeOf 123 (Proxy :: Proxy Word8)
asProxyTypeOf 123 (Proxy :: Proxy Word8) :: Word8

Note the lower-case proxy in the definition. This allows any type constructor with just one argument to be passed to the function, for example we could also write

>>> import Data.Word
>>> :type asProxyTypeOf 123 (Just (undefined :: Word8))
asProxyTypeOf 123 (Just (undefined :: Word8)) :: Word8

data Proxy (t :: k) :: forall k. k -> * #

Proxy is a type that holds no data, but has a phantom parameter of arbitrary type (or even kind). Its use is to provide type information, even though there is no value available of that type (or it may be too costly to create one).

Historically, Proxy :: Proxy a is a safer alternative to the 'undefined :: a' idiom.

>>> Proxy :: Proxy (Void, Int -> Int)
Proxy

Proxy can even hold types of higher kinds,

>>> Proxy :: Proxy Either
Proxy
>>> Proxy :: Proxy Functor
Proxy
>>> Proxy :: Proxy complicatedStructure
Proxy

Constructors

Proxy 
Instances
Generic1 (Proxy :: k -> *) 
Instance details

Defined in GHC.Generics

Associated Types

type Rep1 Proxy :: k -> * #

Methods

from1 :: Proxy a -> Rep1 Proxy a #

to1 :: Rep1 Proxy a -> Proxy a #

Monad (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

(>>=) :: Proxy a -> (a -> Proxy b) -> Proxy b #

(>>) :: Proxy a -> Proxy b -> Proxy b #

return :: a -> Proxy a #

fail :: String -> Proxy a #

Functor (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

fmap :: (a -> b) -> Proxy a -> Proxy b #

(<$) :: a -> Proxy b -> Proxy a #

Applicative (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

pure :: a -> Proxy a #

(<*>) :: Proxy (a -> b) -> Proxy a -> Proxy b #

liftA2 :: (a -> b -> c) -> Proxy a -> Proxy b -> Proxy c #

(*>) :: Proxy a -> Proxy b -> Proxy b #

(<*) :: Proxy a -> Proxy b -> Proxy a #

Foldable (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Proxy m -> m #

foldMap :: Monoid m => (a -> m) -> Proxy a -> m #

foldr :: (a -> b -> b) -> b -> Proxy a -> b #

foldr' :: (a -> b -> b) -> b -> Proxy a -> b #

foldl :: (b -> a -> b) -> b -> Proxy a -> b #

foldl' :: (b -> a -> b) -> b -> Proxy a -> b #

foldr1 :: (a -> a -> a) -> Proxy a -> a #

foldl1 :: (a -> a -> a) -> Proxy a -> a #

toList :: Proxy a -> [a] #

null :: Proxy a -> Bool #

length :: Proxy a -> Int #

elem :: Eq a => a -> Proxy a -> Bool #

maximum :: Ord a => Proxy a -> a #

minimum :: Ord a => Proxy a -> a #

sum :: Num a => Proxy a -> a #

product :: Num a => Proxy a -> a #

Traversable (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> Proxy a -> f (Proxy b) #

sequenceA :: Applicative f => Proxy (f a) -> f (Proxy a) #

mapM :: Monad m => (a -> m b) -> Proxy a -> m (Proxy b) #

sequence :: Monad m => Proxy (m a) -> m (Proxy a) #

ToJSON1 (Proxy :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Proxy a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Proxy a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Proxy a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Proxy a] -> Encoding #

FromJSON1 (Proxy :: * -> *) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Proxy a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Proxy a] #

Alternative (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Proxy

Methods

empty :: Proxy a #

(<|>) :: Proxy a -> Proxy a -> Proxy a #

some :: Proxy a -> Proxy [a] #

many :: Proxy a -> Proxy [a] #

MonadPlus (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Proxy

Methods

mzero :: Proxy a #

mplus :: Proxy a -> Proxy a -> Proxy a #

Eq1 (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> Proxy a -> Proxy b -> Bool #

Ord1 (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a -> b -> Ordering) -> Proxy a -> Proxy b -> Ordering #

Read1 (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Proxy a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Proxy a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Proxy a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Proxy a] #

Show1 (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Proxy a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Proxy a] -> ShowS #

NFData1 (Proxy :: * -> *)

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf :: (a -> ()) -> Proxy a -> () #

Hashable1 (Proxy :: * -> *) 
Instance details

Defined in Data.Hashable.Class

Methods

liftHashWithSalt :: (Int -> a -> Int) -> Int -> Proxy a -> Int #

Bounded (Proxy t) 
Instance details

Defined in Data.Proxy

Methods

minBound :: Proxy t #

maxBound :: Proxy t #

Enum (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

succ :: Proxy s -> Proxy s #

pred :: Proxy s -> Proxy s #

toEnum :: Int -> Proxy s #

fromEnum :: Proxy s -> Int #

enumFrom :: Proxy s -> [Proxy s] #

enumFromThen :: Proxy s -> Proxy s -> [Proxy s] #

enumFromTo :: Proxy s -> Proxy s -> [Proxy s] #

enumFromThenTo :: Proxy s -> Proxy s -> Proxy s -> [Proxy s] #

Eq (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

(==) :: Proxy s -> Proxy s -> Bool #

(/=) :: Proxy s -> Proxy s -> Bool #

Data t => Data (Proxy t)

Since: base-4.7.0.0

Instance details

Defined in Data.Data

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Proxy t -> c (Proxy t) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Proxy t) #

toConstr :: Proxy t -> Constr #

dataTypeOf :: Proxy t -> DataType #

dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Proxy t)) #

dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Proxy t)) #

gmapT :: (forall b. Data b => b -> b) -> Proxy t -> Proxy t #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Proxy t -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Proxy t -> r #

gmapQ :: (forall d. Data d => d -> u) -> Proxy t -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Proxy t -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Proxy t -> m (Proxy t) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Proxy t -> m (Proxy t) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Proxy t -> m (Proxy t) #

Ord (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

compare :: Proxy s -> Proxy s -> Ordering #

(<) :: Proxy s -> Proxy s -> Bool #

(<=) :: Proxy s -> Proxy s -> Bool #

(>) :: Proxy s -> Proxy s -> Bool #

(>=) :: Proxy s -> Proxy s -> Bool #

max :: Proxy s -> Proxy s -> Proxy s #

min :: Proxy s -> Proxy s -> Proxy s #

Read (Proxy t)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Show (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

showsPrec :: Int -> Proxy s -> ShowS #

show :: Proxy s -> String #

showList :: [Proxy s] -> ShowS #

Ix (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

range :: (Proxy s, Proxy s) -> [Proxy s] #

index :: (Proxy s, Proxy s) -> Proxy s -> Int #

unsafeIndex :: (Proxy s, Proxy s) -> Proxy s -> Int

inRange :: (Proxy s, Proxy s) -> Proxy s -> Bool #

rangeSize :: (Proxy s, Proxy s) -> Int #

unsafeRangeSize :: (Proxy s, Proxy s) -> Int

Generic (Proxy t) 
Instance details

Defined in GHC.Generics

Associated Types

type Rep (Proxy t) :: * -> * #

Methods

from :: Proxy t -> Rep (Proxy t) x #

to :: Rep (Proxy t) x -> Proxy t #

Semigroup (Proxy s)

Since: base-4.9.0.0

Instance details

Defined in Data.Proxy

Methods

(<>) :: Proxy s -> Proxy s -> Proxy s #

sconcat :: NonEmpty (Proxy s) -> Proxy s #

stimes :: Integral b => b -> Proxy s -> Proxy s #

Monoid (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

mempty :: Proxy s #

mappend :: Proxy s -> Proxy s -> Proxy s #

mconcat :: [Proxy s] -> Proxy s #

Hashable (Proxy a) 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSalt :: Int -> Proxy a -> Int #

hash :: Proxy a -> Int #

ToJSON (Proxy a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

FromJSON (Proxy a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

NFData (Proxy a)

Since: deepseq-1.4.0.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: Proxy a -> () #

type Rep1 (Proxy :: k -> *) 
Instance details

Defined in GHC.Generics

type Rep1 (Proxy :: k -> *) = D1 (MetaData "Proxy" "Data.Proxy" "base" False) (C1 (MetaCons "Proxy" PrefixI False) (U1 :: k -> *))
type Rep (Proxy t) 
Instance details

Defined in GHC.Generics

type Rep (Proxy t) = D1 (MetaData "Proxy" "Data.Proxy" "base" False) (C1 (MetaCons "Proxy" PrefixI False) (U1 :: * -> *))

data KProxy t #

A concrete, promotable proxy type, for use at the kind level There are no instances for this because it is intended at the kind level only

Constructors

KProxy 

type family If (cond :: Bool) (tru :: k) (fls :: k) :: k where ... #

Type-level If. If True a b ==> a; If False a b ==> b

Equations

If True (tru :: k) (fls :: k) = tru 
If False (tru :: k) (fls :: k) = fls 

data MVar a #

An MVar (pronounced "em-var") is a synchronising variable, used for communication between concurrent threads. It can be thought of as a a box, which may be empty or full.

Instances
NFData1 MVar

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf :: (a -> ()) -> MVar a -> () #

Eq (MVar a)

Since: base-4.1.0.0

Instance details

Defined in GHC.MVar

Methods

(==) :: MVar a -> MVar a -> Bool #

(/=) :: MVar a -> MVar a -> Bool #

NFData (MVar a)

NOTE: Only strict in the reference and not the referenced value.

Since: deepseq-1.4.2.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: MVar a -> () #

PrimUnlifted (MVar a)

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.UnliftedArray

data SomeException where #

The SomeException type is the root of the exception type hierarchy. When an exception of type e is thrown, behind the scenes it is encapsulated in a SomeException.

Constructors

SomeException :: SomeException 
Instances
Show SomeException

Since: base-3.0

Instance details

Defined in GHC.Exception

Exception SomeException

Since: base-3.0

Instance details

Defined in GHC.Exception

Display SomeException

Since: rio-0.1.0.0

Instance details

Defined in RIO.Prelude.Display

newtype MaybeT (m :: * -> *) a #

The parameterizable maybe monad, obtained by composing an arbitrary monad with the Maybe monad.

Computations are actions that may produce a value or exit.

The return function yields a computation that produces that value, while >>= sequences two subcomputations, exiting if either computation does.

Constructors

MaybeT 

Fields

Instances
MonadTrans MaybeT 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

lift :: Monad m => m a -> MaybeT m a #

MonadTransControl MaybeT 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT MaybeT a :: * #

Methods

liftWith :: Monad m => (Run MaybeT -> m a) -> MaybeT m a #

restoreT :: Monad m => m (StT MaybeT a) -> MaybeT m a #

MonadReader r m => MonadReader r (MaybeT m) 
Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: MaybeT m r #

local :: (r -> r) -> MaybeT m a -> MaybeT m a #

reader :: (r -> a) -> MaybeT m a #

MonadBaseControl b m => MonadBaseControl b (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (MaybeT m) a :: * #

Methods

liftBaseWith :: (RunInBase (MaybeT m) b -> b a) -> MaybeT m a #

restoreM :: StM (MaybeT m) a -> MaybeT m a #

MonadError e m => MonadError e (MaybeT m) 
Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> MaybeT m a #

catchError :: MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a #

Monad m => Monad (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

(>>=) :: MaybeT m a -> (a -> MaybeT m b) -> MaybeT m b #

(>>) :: MaybeT m a -> MaybeT m b -> MaybeT m b #

return :: a -> MaybeT m a #

fail :: String -> MaybeT m a #

Functor m => Functor (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

fmap :: (a -> b) -> MaybeT m a -> MaybeT m b #

(<$) :: a -> MaybeT m b -> MaybeT m a #

MonadFix m => MonadFix (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

mfix :: (a -> MaybeT m a) -> MaybeT m a #

Monad m => MonadFail (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

fail :: String -> MaybeT m a #

(Functor m, Monad m) => Applicative (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

pure :: a -> MaybeT m a #

(<*>) :: MaybeT m (a -> b) -> MaybeT m a -> MaybeT m b #

liftA2 :: (a -> b -> c) -> MaybeT m a -> MaybeT m b -> MaybeT m c #

(*>) :: MaybeT m a -> MaybeT m b -> MaybeT m b #

(<*) :: MaybeT m a -> MaybeT m b -> MaybeT m a #

Foldable f => Foldable (MaybeT f) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

fold :: Monoid m => MaybeT f m -> m #

foldMap :: Monoid m => (a -> m) -> MaybeT f a -> m #

foldr :: (a -> b -> b) -> b -> MaybeT f a -> b #

foldr' :: (a -> b -> b) -> b -> MaybeT f a -> b #

foldl :: (b -> a -> b) -> b -> MaybeT f a -> b #

foldl' :: (b -> a -> b) -> b -> MaybeT f a -> b #

foldr1 :: (a -> a -> a) -> MaybeT f a -> a #

foldl1 :: (a -> a -> a) -> MaybeT f a -> a #

toList :: MaybeT f a -> [a] #

null :: MaybeT f a -> Bool #

length :: MaybeT f a -> Int #

elem :: Eq a => a -> MaybeT f a -> Bool #

maximum :: Ord a => MaybeT f a -> a #

minimum :: Ord a => MaybeT f a -> a #

sum :: Num a => MaybeT f a -> a #

product :: Num a => MaybeT f a -> a #

Traversable f => Traversable (MaybeT f) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

traverse :: Applicative f0 => (a -> f0 b) -> MaybeT f a -> f0 (MaybeT f b) #

sequenceA :: Applicative f0 => MaybeT f (f0 a) -> f0 (MaybeT f a) #

mapM :: Monad m => (a -> m b) -> MaybeT f a -> m (MaybeT f b) #

sequence :: Monad m => MaybeT f (m a) -> m (MaybeT f a) #

(Functor m, Monad m) => Alternative (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

empty :: MaybeT m a #

(<|>) :: MaybeT m a -> MaybeT m a -> MaybeT m a #

some :: MaybeT m a -> MaybeT m [a] #

many :: MaybeT m a -> MaybeT m [a] #

Monad m => MonadPlus (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

mzero :: MaybeT m a #

mplus :: MaybeT m a -> MaybeT m a -> MaybeT m a #

Eq1 m => Eq1 (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftEq :: (a -> b -> Bool) -> MaybeT m a -> MaybeT m b -> Bool #

Ord1 m => Ord1 (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftCompare :: (a -> b -> Ordering) -> MaybeT m a -> MaybeT m b -> Ordering #

Read1 m => Read1 (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (MaybeT m a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [MaybeT m a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (MaybeT m a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [MaybeT m a] #

Show1 m => Show1 (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> MaybeT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [MaybeT m a] -> ShowS #

MonadZip m => MonadZip (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

mzip :: MaybeT m a -> MaybeT m b -> MaybeT m (a, b) #

mzipWith :: (a -> b -> c) -> MaybeT m a -> MaybeT m b -> MaybeT m c #

munzip :: MaybeT m (a, b) -> (MaybeT m a, MaybeT m b) #

MonadIO m => MonadIO (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftIO :: IO a -> MaybeT m a #

MonadResource m => MonadResource (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> MaybeT m a #

PrimMonad m => PrimMonad (MaybeT m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (MaybeT m) :: * #

Methods

primitive :: (State# (PrimState (MaybeT m)) -> (#State# (PrimState (MaybeT m)), a#)) -> MaybeT m a #

MonadThrow m => MonadThrow (MaybeT m)

Throws exceptions into the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> MaybeT m a #

MonadCatch m => MonadCatch (MaybeT m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a #

MonadMask m => MonadMask (MaybeT m)

Since: exceptions-0.10.0

Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. MaybeT m a -> MaybeT m a) -> MaybeT m b) -> MaybeT m b #

uninterruptibleMask :: ((forall a. MaybeT m a -> MaybeT m a) -> MaybeT m b) -> MaybeT m b #

generalBracket :: MaybeT m a -> (a -> ExitCase b -> MaybeT m c) -> (a -> MaybeT m b) -> MaybeT m (b, c) #

MonadLogger m => MonadLogger (MaybeT m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> MaybeT m () #

MonadLoggerIO m => MonadLoggerIO (MaybeT m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: MaybeT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadWriter m => MonadWriter (MaybeT m) 
Instance details

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (MaybeT m) :: * #

Methods

tell :: WriterType (MaybeT m) -> MaybeT m () #

listen :: MaybeT m a -> MaybeT m (a, WriterType (MaybeT m)) #

pass :: MaybeT m (a, WriterType (MaybeT m) -> WriterType (MaybeT m)) -> MaybeT m a #

MonadError m => MonadError (MaybeT m) 
Instance details

Defined in Control.Monad.Error.Class

Associated Types

type ErrorType (MaybeT m) :: * #

Methods

throwError :: ErrorType (MaybeT m) -> MaybeT m a #

catchError :: MaybeT m a -> (ErrorType (MaybeT m) -> MaybeT m a) -> MaybeT m a #

MonadState m => MonadState (MaybeT m) 
Instance details

Defined in Control.Monad.State.Class

Associated Types

type StateType (MaybeT m) :: * #

Methods

get :: MaybeT m (StateType (MaybeT m)) #

put :: StateType (MaybeT m) -> MaybeT m () #

(Eq1 m, Eq a) => Eq (MaybeT m a) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

(==) :: MaybeT m a -> MaybeT m a -> Bool #

(/=) :: MaybeT m a -> MaybeT m a -> Bool #

(Ord1 m, Ord a) => Ord (MaybeT m a) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

compare :: MaybeT m a -> MaybeT m a -> Ordering #

(<) :: MaybeT m a -> MaybeT m a -> Bool #

(<=) :: MaybeT m a -> MaybeT m a -> Bool #

(>) :: MaybeT m a -> MaybeT m a -> Bool #

(>=) :: MaybeT m a -> MaybeT m a -> Bool #

max :: MaybeT m a -> MaybeT m a -> MaybeT m a #

min :: MaybeT m a -> MaybeT m a -> MaybeT m a #

(Read1 m, Read a) => Read (MaybeT m a) 
Instance details

Defined in Control.Monad.Trans.Maybe

(Show1 m, Show a) => Show (MaybeT m a) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

showsPrec :: Int -> MaybeT m a -> ShowS #

show :: MaybeT m a -> String #

showList :: [MaybeT m a] -> ShowS #

Functor m => MonoFunctor (MaybeT m a) 
Instance details

Defined in Data.MonoTraversable

Methods

omap :: (Element (MaybeT m a) -> Element (MaybeT m a)) -> MaybeT m a -> MaybeT m a #

Foldable f => MonoFoldable (MaybeT f a) 
Instance details

Defined in Data.MonoTraversable

Methods

ofoldMap :: Monoid m => (Element (MaybeT f a) -> m) -> MaybeT f a -> m #

ofoldr :: (Element (MaybeT f a) -> b -> b) -> b -> MaybeT f a -> b #

ofoldl' :: (a0 -> Element (MaybeT f a) -> a0) -> a0 -> MaybeT f a -> a0 #

otoList :: MaybeT f a -> [Element (MaybeT f a)] #

oall :: (Element (MaybeT f a) -> Bool) -> MaybeT f a -> Bool #

oany :: (Element (MaybeT f a) -> Bool) -> MaybeT f a -> Bool #

onull :: MaybeT f a -> Bool #

olength :: MaybeT f a -> Int #

olength64 :: MaybeT f a -> Int64 #

ocompareLength :: Integral i => MaybeT f a -> i -> Ordering #

otraverse_ :: Applicative f0 => (Element (MaybeT f a) -> f0 b) -> MaybeT f a -> f0 () #

ofor_ :: Applicative f0 => MaybeT f a -> (Element (MaybeT f a) -> f0 b) -> f0 () #

omapM_ :: Applicative m => (Element (MaybeT f a) -> m ()) -> MaybeT f a -> m () #

oforM_ :: Applicative m => MaybeT f a -> (Element (MaybeT f a) -> m ()) -> m () #

ofoldlM :: Monad m => (a0 -> Element (MaybeT f a) -> m a0) -> a0 -> MaybeT f a -> m a0 #

ofoldMap1Ex :: Semigroup m => (Element (MaybeT f a) -> m) -> MaybeT f a -> m #

ofoldr1Ex :: (Element (MaybeT f a) -> Element (MaybeT f a) -> Element (MaybeT f a)) -> MaybeT f a -> Element (MaybeT f a) #

ofoldl1Ex' :: (Element (MaybeT f a) -> Element (MaybeT f a) -> Element (MaybeT f a)) -> MaybeT f a -> Element (MaybeT f a) #

headEx :: MaybeT f a -> Element (MaybeT f a) #

lastEx :: MaybeT f a -> Element (MaybeT f a) #

unsafeHead :: MaybeT f a -> Element (MaybeT f a) #

unsafeLast :: MaybeT f a -> Element (MaybeT f a) #

maximumByEx :: (Element (MaybeT f a) -> Element (MaybeT f a) -> Ordering) -> MaybeT f a -> Element (MaybeT f a) #

minimumByEx :: (Element (MaybeT f a) -> Element (MaybeT f a) -> Ordering) -> MaybeT f a -> Element (MaybeT f a) #

oelem :: Element (MaybeT f a) -> MaybeT f a -> Bool #

onotElem :: Element (MaybeT f a) -> MaybeT f a -> Bool #

Traversable f => MonoTraversable (MaybeT f a) 
Instance details

Defined in Data.MonoTraversable

Methods

otraverse :: Applicative f0 => (Element (MaybeT f a) -> f0 (Element (MaybeT f a))) -> MaybeT f a -> f0 (MaybeT f a) #

omapM :: Applicative m => (Element (MaybeT f a) -> m (Element (MaybeT f a))) -> MaybeT f a -> m (MaybeT f a) #

Applicative f => MonoPointed (MaybeT f a) 
Instance details

Defined in Data.MonoTraversable

Methods

opoint :: Element (MaybeT f a) -> MaybeT f a #

type StT MaybeT a 
Instance details

Defined in Control.Monad.Trans.Control

type StT MaybeT a = Maybe a
type PrimState (MaybeT m) 
Instance details

Defined in Control.Monad.Primitive

type WriterType (MaybeT m) 
Instance details

Defined in Control.Monad.Writer.Class

type ErrorType (MaybeT m) 
Instance details

Defined in Control.Monad.Error.Class

type StateType (MaybeT m) 
Instance details

Defined in Control.Monad.State.Class

type StM (MaybeT m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (MaybeT m) a = ComposeSt MaybeT m a
type Element (MaybeT m a) 
Instance details

Defined in Data.MonoTraversable

type Element (MaybeT m a) = a

newtype ExceptT e (m :: * -> *) a #

A monad transformer that adds exceptions to other monads.

ExceptT constructs a monad parameterized over two things:

  • e - The exception type.
  • m - The inner monad.

The return function yields a computation that produces the given value, while >>= sequences two subcomputations, exiting on the first exception.

Constructors

ExceptT (m (Either e a)) 
Instances
MonadReader r m => MonadReader r (ExceptT e m)

Since: mtl-2.2

Instance details

Defined in Control.Monad.Reader.Class

Methods

ask :: ExceptT e m r #

local :: (r -> r) -> ExceptT e m a -> ExceptT e m a #

reader :: (r -> a) -> ExceptT e m a #

MonadBaseControl b m => MonadBaseControl b (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ExceptT e m) a :: * #

Methods

liftBaseWith :: (RunInBase (ExceptT e m) b -> b a) -> ExceptT e m a #

restoreM :: StM (ExceptT e m) a -> ExceptT e m a #

Monad m => MonadError e (ExceptT e m)

Since: mtl-2.2

Instance details

Defined in Control.Monad.Error.Class

Methods

throwError :: e -> ExceptT e m a #

catchError :: ExceptT e m a -> (e -> ExceptT e m a) -> ExceptT e m a #

MonadTrans (ExceptT e) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

lift :: Monad m => m a -> ExceptT e m a #

MonadTransControl (ExceptT e) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT (ExceptT e) a :: * #

Methods

liftWith :: Monad m => (Run (ExceptT e) -> m a) -> ExceptT e m a #

restoreT :: Monad m => m (StT (ExceptT e) a) -> ExceptT e m a #

Monad m => Monad (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

(>>=) :: ExceptT e m a -> (a -> ExceptT e m b) -> ExceptT e m b #

(>>) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m b #

return :: a -> ExceptT e m a #

fail :: String -> ExceptT e m a #

Functor m => Functor (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

fmap :: (a -> b) -> ExceptT e m a -> ExceptT e m b #

(<$) :: a -> ExceptT e m b -> ExceptT e m a #

MonadFix m => MonadFix (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

mfix :: (a -> ExceptT e m a) -> ExceptT e m a #

MonadFail m => MonadFail (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

fail :: String -> ExceptT e m a #

(Functor m, Monad m) => Applicative (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

pure :: a -> ExceptT e m a #

(<*>) :: ExceptT e m (a -> b) -> ExceptT e m a -> ExceptT e m b #

liftA2 :: (a -> b -> c) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c #

(*>) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m b #

(<*) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m a #

Foldable f => Foldable (ExceptT e f) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

fold :: Monoid m => ExceptT e f m -> m #

foldMap :: Monoid m => (a -> m) -> ExceptT e f a -> m #

foldr :: (a -> b -> b) -> b -> ExceptT e f a -> b #

foldr' :: (a -> b -> b) -> b -> ExceptT e f a -> b #

foldl :: (b -> a -> b) -> b -> ExceptT e f a -> b #

foldl' :: (b -> a -> b) -> b -> ExceptT e f a -> b #

foldr1 :: (a -> a -> a) -> ExceptT e f a -> a #

foldl1 :: (a -> a -> a) -> ExceptT e f a -> a #

toList :: ExceptT e f a -> [a] #

null :: ExceptT e f a -> Bool #

length :: ExceptT e f a -> Int #

elem :: Eq a => a -> ExceptT e f a -> Bool #

maximum :: Ord a => ExceptT e f a -> a #

minimum :: Ord a => ExceptT e f a -> a #

sum :: Num a => ExceptT e f a -> a #

product :: Num a => ExceptT e f a -> a #

Traversable f => Traversable (ExceptT e f) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

traverse :: Applicative f0 => (a -> f0 b) -> ExceptT e f a -> f0 (ExceptT e f b) #

sequenceA :: Applicative f0 => ExceptT e f (f0 a) -> f0 (ExceptT e f a) #

mapM :: Monad m => (a -> m b) -> ExceptT e f a -> m (ExceptT e f b) #

sequence :: Monad m => ExceptT e f (m a) -> m (ExceptT e f a) #

(Functor m, Monad m, Monoid e) => Alternative (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

empty :: ExceptT e m a #

(<|>) :: ExceptT e m a -> ExceptT e m a -> ExceptT e m a #

some :: ExceptT e m a -> ExceptT e m [a] #

many :: ExceptT e m a -> ExceptT e m [a] #

(Monad m, Monoid e) => MonadPlus (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

mzero :: ExceptT e m a #

mplus :: ExceptT e m a -> ExceptT e m a -> ExceptT e m a #

(Eq e, Eq1 m) => Eq1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftEq :: (a -> b -> Bool) -> ExceptT e m a -> ExceptT e m b -> Bool #

(Ord e, Ord1 m) => Ord1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftCompare :: (a -> b -> Ordering) -> ExceptT e m a -> ExceptT e m b -> Ordering #

(Read e, Read1 m) => Read1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (ExceptT e m a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [ExceptT e m a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (ExceptT e m a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [ExceptT e m a] #

(Show e, Show1 m) => Show1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ExceptT e m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ExceptT e m a] -> ShowS #

MonadZip m => MonadZip (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

mzip :: ExceptT e m a -> ExceptT e m b -> ExceptT e m (a, b) #

mzipWith :: (a -> b -> c) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c #

munzip :: ExceptT e m (a, b) -> (ExceptT e m a, ExceptT e m b) #

MonadIO m => MonadIO (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftIO :: IO a -> ExceptT e m a #

MonadResource m => MonadResource (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> ExceptT e m a #

PrimMonad m => PrimMonad (ExceptT e m) 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState (ExceptT e m) :: * #

Methods

primitive :: (State# (PrimState (ExceptT e m)) -> (#State# (PrimState (ExceptT e m)), a#)) -> ExceptT e m a #

MonadThrow m => MonadThrow (ExceptT e m)

Throws exceptions into the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e0 => e0 -> ExceptT e m a #

MonadCatch m => MonadCatch (ExceptT e m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e0 => ExceptT e m a -> (e0 -> ExceptT e m a) -> ExceptT e m a #

MonadMask m => MonadMask (ExceptT e m)

Since: exceptions-0.9.0

Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b) -> ExceptT e m b #

uninterruptibleMask :: ((forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b) -> ExceptT e m b #

generalBracket :: ExceptT e m a -> (a -> ExitCase b -> ExceptT e m c) -> (a -> ExceptT e m b) -> ExceptT e m (b, c) #

MonadLogger m => MonadLogger (ExceptT e m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ExceptT e m () #

MonadLoggerIO m => MonadLoggerIO (ExceptT e m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: ExceptT e m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

(Eq e, Eq1 m, Eq a) => Eq (ExceptT e m a) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

(==) :: ExceptT e m a -> ExceptT e m a -> Bool #

(/=) :: ExceptT e m a -> ExceptT e m a -> Bool #

(Ord e, Ord1 m, Ord a) => Ord (ExceptT e m a) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

compare :: ExceptT e m a -> ExceptT e m a -> Ordering #

(<) :: ExceptT e m a -> ExceptT e m a -> Bool #

(<=) :: ExceptT e m a -> ExceptT e m a -> Bool #

(>) :: ExceptT e m a -> ExceptT e m a -> Bool #

(>=) :: ExceptT e m a -> ExceptT e m a -> Bool #

max :: ExceptT e m a -> ExceptT e m a -> ExceptT e m a #

min :: ExceptT e m a -> ExceptT e m a -> ExceptT e m a #

(Read e, Read1 m, Read a) => Read (ExceptT e m a) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

readsPrec :: Int -> ReadS (ExceptT e m a) #

readList :: ReadS [ExceptT e m a] #

readPrec :: ReadPrec (ExceptT e m a) #

readListPrec :: ReadPrec [ExceptT e m a] #

(Show e, Show1 m, Show a) => Show (ExceptT e m a) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

showsPrec :: Int -> ExceptT e m a -> ShowS #

show :: ExceptT e m a -> String #

showList :: [ExceptT e m a] -> ShowS #

type StT (ExceptT e) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (ExceptT e) a = Either e a
type PrimState (ExceptT e m) 
Instance details

Defined in Control.Monad.Primitive

type PrimState (ExceptT e m) = PrimState m
type StM (ExceptT e m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (ExceptT e m) a = ComposeSt (ExceptT e) m a

class MonadIO m => MonadUnliftIO (m :: * -> *) #

Monads which allow their actions to be run in IO.

While MonadIO allows an IO action to be lifted into another monad, this class captures the opposite concept: allowing you to capture the monadic context. Note that, in order to meet the laws given below, the intuition is that a monad must have no monadic state, but may have monadic context. This essentially limits MonadUnliftIO to ReaderT and IdentityT transformers on top of IO.

Laws. For any value u returned by askUnliftIO, it must meet the monad transformer laws as reformulated for MonadUnliftIO:

  • unliftIO u . return = return
  • unliftIO u (m >>= f) = unliftIO u m >>= unliftIO u . f

The third is a currently nameless law which ensures that the current context is preserved.

  • askUnliftIO >>= (u -> liftIO (unliftIO u m)) = m

If you have a name for this, please submit it in a pull request for great glory.

Since: unliftio-core-0.1.0.0

Minimal complete definition

askUnliftIO | withRunInIO

Instances
MonadUnliftIO IO 
Instance details

Defined in Control.Monad.IO.Unlift

Methods

askUnliftIO :: IO (UnliftIO IO) #

withRunInIO :: ((forall a. IO a -> IO a) -> IO b) -> IO b #

MonadUnliftIO m => MonadUnliftIO (ResourceT m)

Since: resourcet-1.1.10

Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

askUnliftIO :: ResourceT m (UnliftIO (ResourceT m)) #

withRunInIO :: ((forall a. ResourceT m a -> IO a) -> IO b) -> ResourceT m b #

MonadUnliftIO m => MonadUnliftIO (NoLoggingT m)

Since: monad-logger-0.3.26

Instance details

Defined in Control.Monad.Logger

Methods

askUnliftIO :: NoLoggingT m (UnliftIO (NoLoggingT m)) #

withRunInIO :: ((forall a. NoLoggingT m a -> IO a) -> IO b) -> NoLoggingT m b #

MonadUnliftIO m => MonadUnliftIO (LoggingT m)

Since: monad-logger-0.3.26

Instance details

Defined in Control.Monad.Logger

Methods

askUnliftIO :: LoggingT m (UnliftIO (LoggingT m)) #

withRunInIO :: ((forall a. LoggingT m a -> IO a) -> IO b) -> LoggingT m b #

MonadUnliftIO (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

askUnliftIO :: RIO env (UnliftIO (RIO env)) #

withRunInIO :: ((forall a. RIO env a -> IO a) -> IO b) -> RIO env b #

MonadUnliftIO m => MonadUnliftIO (IdentityT m) 
Instance details

Defined in Control.Monad.IO.Unlift

Methods

askUnliftIO :: IdentityT m (UnliftIO (IdentityT m)) #

withRunInIO :: ((forall a. IdentityT m a -> IO a) -> IO b) -> IdentityT m b #

MonadUnliftIO m => MonadUnliftIO (ReaderT r m) 
Instance details

Defined in Control.Monad.IO.Unlift

Methods

askUnliftIO :: ReaderT r m (UnliftIO (ReaderT r m)) #

withRunInIO :: ((forall a. ReaderT r m a -> IO a) -> IO b) -> ReaderT r m b #

class Has a t where #

A type class for extensible product.

We provide instances for tuples up to 12 elements by default. You can define your own instance of Has, but most of the time tuples will do fine.

Minimal complete definition

getter, modifier | hasLens

Methods

getter :: t -> a #

modifier :: (a -> a) -> t -> t #

hasLens :: Lens t a #

Instances
Has a a 
Instance details

Defined in Data.Has

Methods

getter :: a -> a #

modifier :: (a -> a) -> a -> a #

hasLens :: Lens a a #

Has b (a, b) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b) -> b #

modifier :: (b -> b) -> (a, b) -> (a, b) #

hasLens :: Lens (a, b) b #

Has a (a, b) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b) -> a #

modifier :: (a -> a) -> (a, b) -> (a, b) #

hasLens :: Lens (a, b) a #

Has c (a, b, c) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c) -> c #

modifier :: (c -> c) -> (a, b, c) -> (a, b, c) #

hasLens :: Lens (a, b, c) c #

Has b (a, b, c) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c) -> b #

modifier :: (b -> b) -> (a, b, c) -> (a, b, c) #

hasLens :: Lens (a, b, c) b #

Has a (a, b, c) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c) -> a #

modifier :: (a -> a) -> (a, b, c) -> (a, b, c) #

hasLens :: Lens (a, b, c) a #

Has d (a, b, c, d) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d) -> d #

modifier :: (d -> d) -> (a, b, c, d) -> (a, b, c, d) #

hasLens :: Lens (a, b, c, d) d #

Has c (a, b, c, d) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d) -> c #

modifier :: (c -> c) -> (a, b, c, d) -> (a, b, c, d) #

hasLens :: Lens (a, b, c, d) c #

Has b (a, b, c, d) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d) -> b #

modifier :: (b -> b) -> (a, b, c, d) -> (a, b, c, d) #

hasLens :: Lens (a, b, c, d) b #

Has a (a, b, c, d) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d) -> a #

modifier :: (a -> a) -> (a, b, c, d) -> (a, b, c, d) #

hasLens :: Lens (a, b, c, d) a #

Has e (a, b, c, d, e) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e) -> e #

modifier :: (e -> e) -> (a, b, c, d, e) -> (a, b, c, d, e) #

hasLens :: Lens (a, b, c, d, e) e #

Has d (a, b, c, d, e) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e) -> d #

modifier :: (d -> d) -> (a, b, c, d, e) -> (a, b, c, d, e) #

hasLens :: Lens (a, b, c, d, e) d #

Has c (a, b, c, d, e) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e) -> c #

modifier :: (c -> c) -> (a, b, c, d, e) -> (a, b, c, d, e) #

hasLens :: Lens (a, b, c, d, e) c #

Has b (a, b, c, d, e) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e) -> b #

modifier :: (b -> b) -> (a, b, c, d, e) -> (a, b, c, d, e) #

hasLens :: Lens (a, b, c, d, e) b #

Has a (a, b, c, d, e) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e) -> a #

modifier :: (a -> a) -> (a, b, c, d, e) -> (a, b, c, d, e) #

hasLens :: Lens (a, b, c, d, e) a #

Has f (a, b, c, d, e, f) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f) -> f #

modifier :: (f -> f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) #

hasLens :: Lens (a, b, c, d, e, f) f #

Has e (a, b, c, d, e, f) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f) -> e #

modifier :: (e -> e) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) #

hasLens :: Lens (a, b, c, d, e, f) e #

Has d (a, b, c, d, e, f) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f) -> d #

modifier :: (d -> d) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) #

hasLens :: Lens (a, b, c, d, e, f) d #

Has c (a, b, c, d, e, f) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f) -> c #

modifier :: (c -> c) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) #

hasLens :: Lens (a, b, c, d, e, f) c #

Has b (a, b, c, d, e, f) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f) -> b #

modifier :: (b -> b) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) #

hasLens :: Lens (a, b, c, d, e, f) b #

Has a (a, b, c, d, e, f) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f) -> a #

modifier :: (a -> a) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) #

hasLens :: Lens (a, b, c, d, e, f) a #

Has g (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g) -> g #

modifier :: (g -> g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) #

hasLens :: Lens (a, b, c, d, e, f, g) g #

Has f (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g) -> f #

modifier :: (f -> f) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) #

hasLens :: Lens (a, b, c, d, e, f, g) f #

Has e (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g) -> e #

modifier :: (e -> e) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) #

hasLens :: Lens (a, b, c, d, e, f, g) e #

Has d (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g) -> d #

modifier :: (d -> d) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) #

hasLens :: Lens (a, b, c, d, e, f, g) d #

Has c (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g) -> c #

modifier :: (c -> c) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) #

hasLens :: Lens (a, b, c, d, e, f, g) c #

Has b (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g) -> b #

modifier :: (b -> b) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) #

hasLens :: Lens (a, b, c, d, e, f, g) b #

Has a (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g) -> a #

modifier :: (a -> a) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) #

hasLens :: Lens (a, b, c, d, e, f, g) a #

Has h (a, b, c, d, e, f, g, h) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h) -> h #

modifier :: (h -> h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) #

hasLens :: Lens (a, b, c, d, e, f, g, h) h #

Has g (a, b, c, d, e, f, g, h) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h) -> g #

modifier :: (g -> g) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) #

hasLens :: Lens (a, b, c, d, e, f, g, h) g #

Has f (a, b, c, d, e, f, g, h) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h) -> f #

modifier :: (f -> f) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) #

hasLens :: Lens (a, b, c, d, e, f, g, h) f #

Has e (a, b, c, d, e, f, g, h) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h) -> e #

modifier :: (e -> e) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) #

hasLens :: Lens (a, b, c, d, e, f, g, h) e #

Has d (a, b, c, d, e, f, g, h) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h) -> d #

modifier :: (d -> d) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) #

hasLens :: Lens (a, b, c, d, e, f, g, h) d #

Has c (a, b, c, d, e, f, g, h) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h) -> c #

modifier :: (c -> c) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) #

hasLens :: Lens (a, b, c, d, e, f, g, h) c #

Has b (a, b, c, d, e, f, g, h) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h) -> b #

modifier :: (b -> b) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) #

hasLens :: Lens (a, b, c, d, e, f, g, h) b #

Has a (a, b, c, d, e, f, g, h) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h) -> a #

modifier :: (a -> a) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) #

hasLens :: Lens (a, b, c, d, e, f, g, h) a #

Has i (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i) -> i #

modifier :: (i -> i) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i) i #

Has h (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i) -> h #

modifier :: (h -> h) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i) h #

Has g (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i) -> g #

modifier :: (g -> g) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i) g #

Has f (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i) -> f #

modifier :: (f -> f) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i) f #

Has e (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i) -> e #

modifier :: (e -> e) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i) e #

Has d (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i) -> d #

modifier :: (d -> d) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i) d #

Has c (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i) -> c #

modifier :: (c -> c) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i) c #

Has b (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i) -> b #

modifier :: (b -> b) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i) b #

Has a (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i) -> a #

modifier :: (a -> a) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i) a #

Has j (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j) -> j #

modifier :: (j -> j) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j) j #

Has i (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j) -> i #

modifier :: (i -> i) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j) i #

Has h (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j) -> h #

modifier :: (h -> h) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j) h #

Has g (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j) -> g #

modifier :: (g -> g) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j) g #

Has f (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j) -> f #

modifier :: (f -> f) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j) f #

Has e (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j) -> e #

modifier :: (e -> e) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j) e #

Has d (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j) -> d #

modifier :: (d -> d) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j) d #

Has c (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j) -> c #

modifier :: (c -> c) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j) c #

Has b (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j) -> b #

modifier :: (b -> b) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j) b #

Has a (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j) -> a #

modifier :: (a -> a) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j) a #

Has k (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> k #

modifier :: (k -> k) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) k #

Has j (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> j #

modifier :: (j -> j) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) j #

Has i (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> i #

modifier :: (i -> i) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) i #

Has h (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> h #

modifier :: (h -> h) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) h #

Has g (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> g #

modifier :: (g -> g) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) g #

Has f (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> f #

modifier :: (f -> f) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) f #

Has e (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> e #

modifier :: (e -> e) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) e #

Has d (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> d #

modifier :: (d -> d) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) d #

Has c (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> c #

modifier :: (c -> c) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) c #

Has b (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> b #

modifier :: (b -> b) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) b #

Has a (a, b, c, d, e, f, g, h, i, j, k) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k) -> a #

modifier :: (a -> a) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k) a #

Has l (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> l #

modifier :: (l -> l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) l #

Has k (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> k #

modifier :: (k -> k) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) k #

Has j (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> j #

modifier :: (j -> j) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) j #

Has i (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> i #

modifier :: (i -> i) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) i #

Has h (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> h #

modifier :: (h -> h) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) h #

Has g (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> g #

modifier :: (g -> g) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) g #

Has f (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> f #

modifier :: (f -> f) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) f #

Has e (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> e #

modifier :: (e -> e) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) e #

Has d (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> d #

modifier :: (d -> d) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) d #

Has c (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> c #

modifier :: (c -> c) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) c #

Has b (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> b #

modifier :: (b -> b) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) b #

Has a (a, b, c, d, e, f, g, h, i, j, k, l) 
Instance details

Defined in Data.Has

Methods

getter :: (a, b, c, d, e, f, g, h, i, j, k, l) -> a #

modifier :: (a -> a) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) #

hasLens :: Lens (a, b, c, d, e, f, g, h, i, j, k, l) a #

registerGcMetrics :: Store -> IO () #

Register a number of metrics related to garbage collector behavior.

To enable GC statistics collection, either run your program with

+RTS -T

or compile it with

-with-rtsopts=-T

The runtime overhead of -T is very small so it's safe to always leave it enabled.

Registered counters:

rts.gc.bytes_allocated
Total number of bytes allocated
rts.gc.num_gcs
Number of garbage collections performed
rts.gc.num_bytes_usage_samples
Number of byte usage samples taken
rts.gc.cumulative_bytes_used
Sum of all byte usage samples, can be used with numByteUsageSamples to calculate averages with arbitrary weighting (if you are sampling this record multiple times).
rts.gc.bytes_copied
Number of bytes copied during GC
rts.gc.mutator_cpu_ms
CPU time spent running mutator threads, in milliseconds. This does not include any profiling overhead or initialization.
rts.gc.mutator_wall_ms
Wall clock time spent running mutator threads, in milliseconds. This does not include initialization.
rts.gc.gc_cpu_ms
CPU time spent running GC, in milliseconds.
rts.gc.gc_wall_ms
Wall clock time spent running GC, in milliseconds.
rts.gc.cpu_ms
Total CPU time elapsed since program start, in milliseconds.
rts.gc.wall_ms
Total wall clock time elapsed since start, in milliseconds.

Registered gauges:

rts.gc.max_bytes_used
Maximum number of live bytes seen so far
rts.gc.current_bytes_used
Current number of live bytes
rts.gc.current_bytes_slop
Current number of bytes lost to slop
rts.gc.max_bytes_slop
Maximum number of bytes lost to slop at any one time so far
rts.gc.peak_megabytes_allocated
Maximum number of megabytes allocated
rts.gc.par_tot_bytes_copied
Number of bytes copied during GC, minus space held by mutable lists held by the capabilities. Can be used with parMaxBytesCopied to determine how well parallel GC utilized all cores.
rts.gc.par_avg_bytes_copied
Deprecated alias for par_tot_bytes_copied.
rts.gc.par_max_bytes_copied
Sum of number of bytes copied each GC by the most active GC thread each GC. The ratio of par_tot_bytes_copied divided by par_max_bytes_copied approaches 1 for a maximally sequential run and approaches the number of threads (set by the RTS flag -N) for a maximally parallel run.

data Store #

A mutable metric store.

serverMetricStore :: Server -> Store #

The metric store associated with the server. If you want to add metric to the default store created by forkServer you need to use this function to retrieve it.

showEnv :: IO () #

Display all environment variables, for convenience

unsetEnvironment' :: ToEnv a => a -> IO (Either String ()) #

Unset Environment using a value of class ToEnv

unsetEnvironment :: EnvList a -> IO (Either String ()) #

Unset Environment from a ToEnv constrained type

setEnvironment' :: ToEnv a => a -> IO (Either String ()) #

Set environment directly using a value of class ToEnv

setEnvironment :: EnvList a -> IO (Either String ()) #

Set environment via a ToEnv constrained type

decodeEnv :: FromEnv a => IO (Either String a) #

Environment retrieval with failure info

makeEnv :: [EnvVar] -> EnvList a #

Smart constructor, environment creation helper.

gFromEnvCustom :: (DefConfig a, Generic a, GFromEnv (Rep a)) => Option -> Parser a #

Meant for specifying a custom Option for environment retrieval

instance FromEnv PGConfig where
  fromEnv = gFromEnvCustom Option { dropPrefixCount = 8, customPrefix = "PG" }

envMaybe #

Arguments

:: Var a 
=> String

Key to look up.

-> Parser (Maybe a)

Return Nothing if variable isn't set.

Environment variable getter returning Maybe

env #

Arguments

:: Var a 
=> String

Key to look up.

-> Parser a

Return a value of this type or throw an error.

Environment variable getter. Fails if the variable is not set or fails to parse.

runEnv :: Parser a -> IO (Either String a) #

For use with Generics, no FromEnv typeclass necessary

getPgConfig :: IO (Either String ConnectInfo)
getPgConfig = runEnv $ gFromEnvCustom defOption

newtype Parser a #

Parser Monad for environment variable retrieval

Constructors

Parser 

Fields

Instances
Monad Parser 
Instance details

Defined in System.Envy

Methods

(>>=) :: Parser a -> (a -> Parser b) -> Parser b #

(>>) :: Parser a -> Parser b -> Parser b #

return :: a -> Parser a #

fail :: String -> Parser a #

Functor Parser 
Instance details

Defined in System.Envy

Methods

fmap :: (a -> b) -> Parser a -> Parser b #

(<$) :: a -> Parser b -> Parser a #

Applicative Parser 
Instance details

Defined in System.Envy

Methods

pure :: a -> Parser a #

(<*>) :: Parser (a -> b) -> Parser a -> Parser b #

liftA2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c #

(*>) :: Parser a -> Parser b -> Parser b #

(<*) :: Parser a -> Parser b -> Parser a #

Alternative Parser 
Instance details

Defined in System.Envy

Methods

empty :: Parser a #

(<|>) :: Parser a -> Parser a -> Parser a #

some :: Parser a -> Parser [a] #

many :: Parser a -> Parser [a] #

MonadPlus Parser 
Instance details

Defined in System.Envy

Methods

mzero :: Parser a #

mplus :: Parser a -> Parser a -> Parser a #

MonadIO Parser 
Instance details

Defined in System.Envy

Methods

liftIO :: IO a -> Parser a #

MonadError String Parser 
Instance details

Defined in System.Envy

Methods

throwError :: String -> Parser a #

catchError :: Parser a -> (String -> Parser a) -> Parser a #

class FromEnv a where #

FromEnv Typeclass w/ Generic default implementation

Methods

fromEnv :: Parser a #

class DefConfig a where #

Type class for objects which have a default configuration.

Minimal complete definition

defConfig

Methods

defConfig :: a #

data Option #

For customizing environment variable generation

Constructors

Option 

Fields

Instances
Show Option 
Instance details

Defined in System.Envy

class ToEnv a where #

Type class for objects which can be converted to a set of environment variable settings.

Minimal complete definition

toEnv

Methods

toEnv :: a -> EnvList a #

Convert an object into a list of environment variable settings.

data EnvList a #

List of environment variables. Captures a "phantom type" which allows the type checker to detect the proper implementation of toEnv to use.

Instances
Show (EnvList a) 
Instance details

Defined in System.Envy

Methods

showsPrec :: Int -> EnvList a -> ShowS #

show :: EnvList a -> String #

showList :: [EnvList a] -> ShowS #

class Typeable a => Var a where #

Class for converting to / from an environment variable

Minimal complete definition

toVar, fromVar

Methods

toVar :: a -> String #

Convert a value into an environment variable.

fromVar :: String -> Maybe a #

Parse an environment variable.

Instances
Var Bool 
Instance details

Defined in System.Envy

Methods

toVar :: Bool -> String #

fromVar :: String -> Maybe Bool #

Var Double 
Instance details

Defined in System.Envy

Var Int 
Instance details

Defined in System.Envy

Methods

toVar :: Int -> String #

fromVar :: String -> Maybe Int #

Var Int8 
Instance details

Defined in System.Envy

Methods

toVar :: Int8 -> String #

fromVar :: String -> Maybe Int8 #

Var Int16 
Instance details

Defined in System.Envy

Var Int32 
Instance details

Defined in System.Envy

Var Int64 
Instance details

Defined in System.Envy

Var Integer 
Instance details

Defined in System.Envy

Var Word8 
Instance details

Defined in System.Envy

Var Word16 
Instance details

Defined in System.Envy

Var Word32 
Instance details

Defined in System.Envy

Var Word64 
Instance details

Defined in System.Envy

Var () 
Instance details

Defined in System.Envy

Methods

toVar :: () -> String #

fromVar :: String -> Maybe () #

Var String 
Instance details

Defined in System.Envy

Var ByteString 
Instance details

Defined in System.Envy

Var ByteString 
Instance details

Defined in System.Envy

Var Text 
Instance details

Defined in System.Envy

Methods

toVar :: Text -> String #

fromVar :: String -> Maybe Text #

Var UTCTime 
Instance details

Defined in System.Envy

Var Text 
Instance details

Defined in System.Envy

Methods

toVar :: Text -> String #

fromVar :: String -> Maybe Text #

Var Day 
Instance details

Defined in System.Envy

Methods

toVar :: Day -> String #

fromVar :: String -> Maybe Day #

Var a => Var (Maybe a) 
Instance details

Defined in System.Envy

Methods

toVar :: Maybe a -> String #

fromVar :: String -> Maybe (Maybe a) #

fmapRT :: Monad m => (a -> b) -> ExceptT l m a -> ExceptT l m b #

fmap specialized to ExceptT, given a name symmetric to fmapLT

isRightT :: Monad m => ExceptT a m b -> m Bool #

Analogous to isRight, but for ExceptT

isLeftT :: Monad m => ExceptT a m b -> m Bool #

Analogous to isLeft, but for ExceptT

fmapR :: (a -> b) -> Either l a -> Either l b #

fmap specialized to Either, given a name symmetric to fmapL

isRight :: Either a b -> Bool #

Returns whether argument is a Right

isLeft :: Either a b -> Bool #

Returns whether argument is a Left

isNothingT :: Monad m => MaybeT m a -> m Bool #

Analogous to isNothing, but for MaybeT

isJustT :: Monad m => MaybeT m a -> m Bool #

Analogous to isJust, but for MaybeT

nothing :: Monad m => MaybeT m a #

Analogous to Nothing and equivalent to mzero

just :: Monad m => a -> MaybeT m a #

Analogous to Just and equivalent to return

maybeT :: Monad m => m b -> (a -> m b) -> MaybeT m a -> m b #

Case analysis for MaybeT

Use the first argument if the MaybeT computation fails, otherwise apply the function to the successful result.

failWithM :: Applicative m => e -> m (Maybe a) -> ExceptT e m a #

Convert an applicative Maybe value into the ExceptT monad

Named version of (!?) with arguments flipped

failWith :: Applicative m => e -> Maybe a -> ExceptT e m a #

Convert a Maybe value into the ExceptT monad

Named version of (??) with arguments flipped

(?:) :: Maybe a -> a -> a infixr 0 #

An infix form of fromMaybe with arguments flipped.

(!?) :: Applicative m => m (Maybe a) -> e -> ExceptT e m a #

Convert an applicative Maybe value into the ExceptT monad

hoistMaybe :: Monad m => Maybe b -> MaybeT m b #

Lift a Maybe to the MaybeT monad

noteT :: Monad m => a -> MaybeT m b -> ExceptT a m b #

Tag the Nothing value of a MaybeT

note :: a -> Maybe b -> Either a b #

Tag the Nothing value of a Maybe

hushT :: Monad m => ExceptT a m b -> MaybeT m b #

Suppress the Left value of an ExceptT

hush :: Either a b -> Maybe b #

Suppress the Left value of an Either

hoistEither :: Monad m => Either e a -> ExceptT e m a #

Upgrade an Either to an ExceptT

bimapExceptT :: Functor m => (e -> f) -> (a -> b) -> ExceptT e m a -> ExceptT f m b #

Transform the left and right value

exceptT :: Monad m => (a -> m c) -> (b -> m c) -> ExceptT a m b -> m c #

Fold an ExceptT by providing one continuation for each constructor

newtype AllE e r #

Run multiple Either computations and succeed if all of them succeed

mappends all successes or failures

Constructors

AllE 

Fields

Instances
(Semigroup e, Semigroup r) => Semigroup (AllE e r) 
Instance details

Defined in Control.Error.Util

Methods

(<>) :: AllE e r -> AllE e r -> AllE e r #

sconcat :: NonEmpty (AllE e r) -> AllE e r #

stimes :: Integral b => b -> AllE e r -> AllE e r #

(Monoid e, Monoid r) => Monoid (AllE e r) 
Instance details

Defined in Control.Error.Util

Methods

mempty :: AllE e r #

mappend :: AllE e r -> AllE e r -> AllE e r #

mconcat :: [AllE e r] -> AllE e r #

newtype AnyE e r #

Run multiple Either computations and succeed if any of them succeed

mappends all successes or failures

Constructors

AnyE 

Fields

Instances
(Semigroup e, Semigroup r) => Semigroup (AnyE e r) 
Instance details

Defined in Control.Error.Util

Methods

(<>) :: AnyE e r -> AnyE e r -> AnyE e r #

sconcat :: NonEmpty (AnyE e r) -> AnyE e r #

stimes :: Integral b => b -> AnyE e r -> AnyE e r #

(Monoid e, Monoid r) => Monoid (AnyE e r) 
Instance details

Defined in Control.Error.Util

Methods

mempty :: AnyE e r #

mappend :: AnyE e r -> AnyE e r -> AnyE e r #

mconcat :: [AnyE e r] -> AnyE e r #

mapMaybeT :: (m (Maybe a) -> n (Maybe b)) -> MaybeT m a -> MaybeT n b #

Transform the computation inside a MaybeT.

liftCatch :: Catch e m (Maybe a) -> Catch e (MaybeT m) a #

Lift a catchE operation to the new monad.

runExceptT :: ExceptT e m a -> m (Either e a) #

The inverse of ExceptT.

class MonadThrow m => MonadCatch (m :: * -> *) #

A class for monads which allow exceptions to be caught, in particular exceptions which were thrown by throwM.

Instances should obey the following law:

catch (throwM e) f = f e

Note that the ability to catch an exception does not guarantee that we can deal with all possible exit points from a computation. Some monads, such as continuation-based stacks, allow for more than just a success/failure strategy, and therefore catch cannot be used by those monads to properly implement a function such as finally. For more information, see MonadMask.

Minimal complete definition

catch

Instances
MonadCatch IO 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => IO a -> (e -> IO a) -> IO a #

MonadCatch STM 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => STM a -> (e -> STM a) -> STM a #

MonadCatch Handler 
Instance details

Defined in Servant.Server.Internal.Handler

Methods

catch :: Exception e => Handler a -> (e -> Handler a) -> Handler a #

e ~ SomeException => MonadCatch (Either e)

Since: exceptions-0.8.3

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e0 => Either e a -> (e0 -> Either e a) -> Either e a #

MonadCatch m => MonadCatch (MaybeT m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a #

MonadCatch m => MonadCatch (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

catch :: Exception e => ResourceT m a -> (e -> ResourceT m a) -> ResourceT m a #

MonadCatch m => MonadCatch (ListT m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => ListT m a -> (e -> ListT m a) -> ListT m a #

MonadCatch m => MonadCatch (NoLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

catch :: Exception e => NoLoggingT m a -> (e -> NoLoggingT m a) -> NoLoggingT m a #

MonadCatch m => MonadCatch (WriterLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

catch :: Exception e => WriterLoggingT m a -> (e -> WriterLoggingT m a) -> WriterLoggingT m a #

MonadCatch m => MonadCatch (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

catch :: Exception e => LoggingT m a -> (e -> LoggingT m a) -> LoggingT m a #

MonadCatch m => MonadCatch (IdentityT m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => IdentityT m a -> (e -> IdentityT m a) -> IdentityT m a #

(MonadCatch m, Monoid w) => MonadCatch (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

(MonadCatch m, Monoid w) => MonadCatch (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

MonadCatch m => MonadCatch (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a #

MonadCatch m => MonadCatch (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a #

MonadCatch m => MonadCatch (ExceptT e m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e0 => ExceptT e m a -> (e0 -> ExceptT e m a) -> ExceptT e m a #

(Error e, MonadCatch m) => MonadCatch (ErrorT e m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e0 => ErrorT e m a -> (e0 -> ErrorT e m a) -> ErrorT e m a #

MonadCatch m => MonadCatch (ReaderT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a #

(MonadCatch m, Monoid w) => MonadCatch (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

(MonadCatch m, Monoid w) => MonadCatch (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

data LogType #

Logger Type.

Constructors

LogNone

No logging.

LogStdout BufSize

Logging to stdout. BufSize is a buffer size for each capability.

LogStderr BufSize

Logging to stderr. BufSize is a buffer size for each capability.

LogFileNoRotate FilePath BufSize

Logging to a file. BufSize is a buffer size for each capability.

LogFile FileLogSpec BufSize

Logging to a file. BufSize is a buffer size for each capability. File rotation is done on-demand.

LogCallback (LogStr -> IO ()) (IO ())

Logging with a log and flush action. run flush after log each message.

defaultBufSize :: BufSize #

The default buffer size (4,096 bytes).

encodePathSegmentsRelative :: [Text] -> Builder #

Like encodePathSegments, but without the initial slash.

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

toUrlPiece | toQueryParam

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 encodePathSegmentsRelative, but this may be overriden with a more efficient version.

toHeader :: a -> ByteString #

Convert to HTTP header value.

toQueryParam :: a -> Text #

Convert to query param value.

Instances
ToHttpApiData Bool 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Char 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Double 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Float 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Int 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Int8 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Int16 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Int32 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Int64 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Integer 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Natural 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Ordering 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Word 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Word8 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Word16 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Word32 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Word64 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: () -> Text #

toEncodedUrlPiece :: () -> Builder #

toHeader :: () -> ByteString #

toQueryParam :: () -> Text #

ToHttpApiData String 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

ToHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

ToHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Void 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData All 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Any 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

ToHttpApiData NominalDiffTime 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

ToHttpApiData ZonedTime
>>> toUrlPiece $ ZonedTime (LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 51.001)) utc
"2015-10-03T14:55:51.001+0000"
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Link 
Instance details

Defined in Servant.Links

ToHttpApiData UUID 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (First a) 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (Last a) 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (Dual a) 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (Sum a) 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (Product a) 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

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

parseUrlPiece | parseQueryParam

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 Bool 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Char 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Double 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Float 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int8 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int16 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int32 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int64 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Integer 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Natural 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Ordering 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word8 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word16 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word32 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word64 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData String 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Void

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

Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData All 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Any 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData NominalDiffTime 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData ZonedTime
>>> 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

FromHttpApiData UUID 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (First a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Last a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Dual a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Sum a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Product a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (LenientData a) 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

data URI #

Represents a general universal resource identifier using its component parts.

For example, for the URI

  foo://anonymous@www.haskell.org:42/ghc?query#frag

the components are:

Constructors

URI 

Fields

Instances
Eq URI 
Instance details

Defined in Network.URI

Methods

(==) :: URI -> URI -> Bool #

(/=) :: URI -> URI -> Bool #

Data URI 
Instance details

Defined in Network.URI

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> URI -> c URI #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c URI #

toConstr :: URI -> Constr #

dataTypeOf :: URI -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c URI) #

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

gmapT :: (forall b. Data b => b -> b) -> URI -> URI #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r #

gmapQ :: (forall d. Data d => d -> u) -> URI -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> URI -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> URI -> m URI #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> URI -> m URI #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> URI -> m URI #

Ord URI 
Instance details

Defined in Network.URI

Methods

compare :: URI -> URI -> Ordering #

(<) :: URI -> URI -> Bool #

(<=) :: URI -> URI -> Bool #

(>) :: URI -> URI -> Bool #

(>=) :: URI -> URI -> Bool #

max :: URI -> URI -> URI #

min :: URI -> URI -> URI #

Show URI 
Instance details

Defined in Network.URI

Methods

showsPrec :: Int -> URI -> ShowS #

show :: URI -> String #

showList :: [URI] -> ShowS #

Generic URI 
Instance details

Defined in Network.URI

Associated Types

type Rep URI :: * -> * #

Methods

from :: URI -> Rep URI x #

to :: Rep URI x -> URI #

NFData URI 
Instance details

Defined in Network.URI

Methods

rnf :: URI -> () #

type Rep URI 
Instance details

Defined in Network.URI

responseTimeoutDefault :: ResponseTimeout #

Use the default response timeout

When used on a Request, means: use the manager's timeout value

When used on a ManagerSettings, means: default to 30 seconds

Since: http-client-0.5.0

responseTimeoutNone :: ResponseTimeout #

Do not have a response timeout

Since: http-client-0.5.0

responseTimeoutMicro :: Int -> ResponseTimeout #

Specify a response timeout in microseconds

Since: http-client-0.5.0

managerSetProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings #

Set the proxy override value, for both HTTP (insecure) and HTTPS (insecure) connections.

Since 0.4.7

managerSetSecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings #

Set the proxy override value, only for HTTPS (secure) connections.

Since 0.4.7

managerSetInsecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings #

Set the proxy override value, only for HTTP (insecure) connections.

Since 0.4.7

withResponseHistory :: Request -> Manager -> (HistoriedResponse BodyReader -> IO a) -> IO a #

A variant of withResponse which keeps a history of all redirects performed in the interim, together with the first 1024 bytes of their response bodies.

Since 0.4.1

responseOpenHistory :: Request -> Manager -> IO (HistoriedResponse BodyReader) #

A variant of responseOpen which keeps a history of all redirects performed in the interim, together with the first 1024 bytes of their response bodies.

Since 0.4.1

data HistoriedResponse body #

A datatype holding information on redirected requests and the final response.

Since 0.4.1

Instances
Functor HistoriedResponse 
Instance details

Defined in Network.HTTP.Client

Foldable HistoriedResponse 
Instance details

Defined in Network.HTTP.Client

Methods

fold :: Monoid m => HistoriedResponse m -> m #

foldMap :: Monoid m => (a -> m) -> HistoriedResponse a -> m #

foldr :: (a -> b -> b) -> b -> HistoriedResponse a -> b #

foldr' :: (a -> b -> b) -> b -> HistoriedResponse a -> b #

foldl :: (b -> a -> b) -> b -> HistoriedResponse a -> b #

foldl' :: (b -> a -> b) -> b -> HistoriedResponse a -> b #

foldr1 :: (a -> a -> a) -> HistoriedResponse a -> a #

foldl1 :: (a -> a -> a) -> HistoriedResponse a -> a #

toList :: HistoriedResponse a -> [a] #

null :: HistoriedResponse a -> Bool #

length :: HistoriedResponse a -> Int #

elem :: Eq a => a -> HistoriedResponse a -> Bool #

maximum :: Ord a => HistoriedResponse a -> a #

minimum :: Ord a => HistoriedResponse a -> a #

sum :: Num a => HistoriedResponse a -> a #

product :: Num a => HistoriedResponse a -> a #

Traversable HistoriedResponse 
Instance details

Defined in Network.HTTP.Client

Methods

traverse :: Applicative f => (a -> f b) -> HistoriedResponse a -> f (HistoriedResponse b) #

sequenceA :: Applicative f => HistoriedResponse (f a) -> f (HistoriedResponse a) #

mapM :: Monad m => (a -> m b) -> HistoriedResponse a -> m (HistoriedResponse b) #

sequence :: Monad m => HistoriedResponse (m a) -> m (HistoriedResponse a) #

Show body => Show (HistoriedResponse body) 
Instance details

Defined in Network.HTTP.Client

Generic (HistoriedResponse body) 
Instance details

Defined in Network.HTTP.Client

Associated Types

type Rep (HistoriedResponse body) :: * -> * #

Methods

from :: HistoriedResponse body -> Rep (HistoriedResponse body) x #

to :: Rep (HistoriedResponse body) x -> HistoriedResponse body #

type Rep (HistoriedResponse body) 
Instance details

Defined in Network.HTTP.Client

type Rep (HistoriedResponse body) = D1 (MetaData "HistoriedResponse" "Network.HTTP.Client" "http-client-0.5.13.1-JQVmW3vQYAt5e1zBJeeP10" False) (C1 (MetaCons "HistoriedResponse" PrefixI True) (S1 (MetaSel (Just "hrRedirects") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(Request, Response ByteString)]) :*: (S1 (MetaSel (Just "hrFinalRequest") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Request) :*: S1 (MetaSel (Just "hrFinalResponse") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Response body)))))

withConnection :: Request -> Manager -> (Connection -> IO a) -> IO a #

Perform an action using a Connection acquired from the given Manager.

You should use this only when you have to read and write interactively through the connection (e.g. connection by the WebSocket protocol).

Since: http-client-0.5.13

responseClose :: Response a -> IO () #

Close any open resources associated with the given Response. In general, this will either close an active Connection or return it to the Manager to be reused.

Since 0.1.0

responseOpen :: Request -> Manager -> IO (Response BodyReader) #

The most low-level function for initiating an HTTP request.

The first argument to this function gives a full specification on the request: the host to connect to, whether to use SSL, headers, etc. Please see Request for full details. The second argument specifies which Manager should be used.

This function then returns a Response with a BodyReader. The Response contains the status code and headers that were sent back to us, and the BodyReader contains the body of the request. Note that this BodyReader allows you to have fully interleaved IO actions during your HTTP download, making it possible to download very large responses in constant memory.

An important note: the response body returned by this function represents a live HTTP connection. As such, if you do not use the response body, an open socket will be retained indefinitely. You must be certain to call responseClose on this response to free up resources.

This function automatically performs any necessary redirects, as specified by the redirectCount setting.

When implementing a (reverse) proxy using this function or relating functions, it's wise to remove Transfer-Encoding:, Content-Length:, Content-Encoding: and Accept-Encoding: from request and response headers to be relayed.

Since 0.1.0

httpNoBody :: Request -> Manager -> IO (Response ()) #

A convenient wrapper around withResponse which ignores the response body. This is useful, for example, when performing a HEAD request.

Since 0.3.2

httpLbs :: Request -> Manager -> IO (Response ByteString) #

A convenience wrapper around withResponse which reads in the entire response body and immediately closes the connection. Note that this function performs fully strict I/O, and only uses a lazy ByteString in its response for memory efficiency. If you are anticipating a large response body, you are encouraged to use withResponse and brRead instead.

Since 0.1.0

withResponse :: Request -> Manager -> (Response BodyReader -> IO a) -> IO a #

Perform a Request using a connection acquired from the given Manager, and then provide the Response to the given function. This function is fully exception safe, guaranteeing that the response will be closed when the inner function exits. It is defined as:

withResponse req man f = bracket (responseOpen req man) responseClose f

It is recommended that you use this function in place of explicit calls to responseOpen and responseClose.

You will need to use functions such as brRead to consume the response body.

Since 0.1.0

generateCookie #

Arguments

:: SetCookie

The SetCookie we are encountering

-> Request

The request that originated the response that yielded the SetCookie

-> UTCTime

Value that should be used as "now"

-> Bool

Whether or not this request is coming from an "http" source (not javascript or anything like that)

-> Maybe Cookie

The optional output cookie

Turn a SetCookie into a Cookie, if it is valid

insertCheckedCookie #

Arguments

:: Cookie

The SetCookie the cookie jar is receiving

-> CookieJar

Input cookie jar to modify

-> Bool

Whether or not this request is coming from an "http" source (not javascript or anything like that)

-> CookieJar

Updated (or not) cookie jar

Insert a cookie created by generateCookie into the cookie jar (or not if it shouldn't be allowed in)

receiveSetCookie #

Arguments

:: SetCookie

The SetCookie the cookie jar is receiving

-> Request

The request that originated the response that yielded the SetCookie

-> UTCTime

Value that should be used as "now"

-> Bool

Whether or not this request is coming from an "http" source (not javascript or anything like that)

-> CookieJar

Input cookie jar to modify

-> CookieJar

Updated cookie jar

This corresponds to the algorithm described in Section 5.3 "Storage Model" This function consists of calling generateCookie followed by insertCheckedCookie. Use this function if you plan to do both in a row. generateCookie and insertCheckedCookie are only provided for more fine-grained control.

updateCookieJar #

Arguments

:: Response a

Response received from server

-> Request

Request which generated the response

-> UTCTime

Value that should be used as "now"

-> CookieJar

Current cookie jar

-> (CookieJar, Response a)

(Updated cookie jar with cookies from the Response, The response stripped of any "Set-Cookie" header)

This applies receiveSetCookie to a given Response

computeCookieString #

Arguments

:: Request

Input request

-> CookieJar

Current cookie jar

-> UTCTime

Value that should be used as "now"

-> Bool

Whether or not this request is coming from an "http" source (not javascript or anything like that)

-> (ByteString, CookieJar)

(Contents of a "Cookie" header, Updated cookie jar (last-access-time is updated))

This corresponds to the algorithm described in Section 5.4 "The Cookie Header"

insertCookiesIntoRequest #

Arguments

:: Request

The request to insert into

-> CookieJar

Current cookie jar

-> UTCTime

Value that should be used as "now"

-> (Request, CookieJar)

(Output request, Updated cookie jar (last-access-time is updated))

This applies the computeCookieString to a given Request

evictExpiredCookies #

Arguments

:: CookieJar

Input cookie jar

-> UTCTime

Value that should be used as "now"

-> CookieJar

Filtered cookie jar

This corresponds to the eviction algorithm described in Section 5.3 "Storage Model"

pathMatches :: ByteString -> ByteString -> Bool #

This corresponds to the subcomponent algorithm entitled "Path-Match" detailed in section 5.1.4

defaultPath :: Request -> ByteString #

This corresponds to the subcomponent algorithm entitled "Paths" detailed in section 5.1.4

domainMatches #

Arguments

:: ByteString

Domain to test

-> ByteString

Domain from a cookie

-> Bool 

This corresponds to the subcomponent algorithm entitled "Domain Matching" detailed in section 5.1.3

defaultProxy :: ProxyOverride #

The default proxy settings for a manager. In particular: if the http_proxy (or https_proxy) environment variable is set, use it. Otherwise, use the values in the Request.

Since 0.4.7

proxyEnvironmentNamed #

Arguments

:: Text

environment variable name

-> Maybe Proxy

fallback if no environment set

-> ProxyOverride 

Same as proxyEnvironment, but instead of default environment variable names, allows you to set your own name.

Since 0.4.7

proxyEnvironment #

Arguments

:: Maybe Proxy

fallback if no environment set

-> ProxyOverride 

Get the proxy settings from the default environment variable (http_proxy for insecure, https_proxy for secure). If no variable is set, then fall back to the given value. Nothing is equivalent to noProxy, Just is equivalent to useProxy.

Since 0.4.7

useProxy :: Proxy -> ProxyOverride #

Use the given proxy settings, regardless of the proxy value in the Request.

Since 0.4.7

noProxy :: ProxyOverride #

Never connect using a proxy, regardless of the proxy value in the Request.

Since 0.4.7

proxyFromRequest :: ProxyOverride #

Get the proxy settings from the Request itself.

Since 0.4.7

withManager :: ManagerSettings -> (Manager -> IO a) -> IO a #

Create, use and close a Manager.

Since 0.2.1

closeManager :: Manager -> IO () #

Close all connections in a Manager.

Note that this doesn't affect currently in-flight connections, meaning you can safely use it without hurting any queries you may have concurrently running.

Since 0.1.0

newManager :: ManagerSettings -> IO Manager #

Create a Manager. The Manager will be shut down automatically via garbage collection.

Creating a new Manager is a relatively expensive operation, you are advised to share a single Manager between requests instead.

The first argument to this function is often defaultManagerSettings, though add-on libraries may provide a recommended replacement.

Since 0.1.0

defaultManagerSettings :: ManagerSettings #

Default value for ManagerSettings.

Note that this value does not have support for SSL/TLS. If you need to make any https connections, please use the http-client-tls package, which provides a tlsManagerSettings value.

Since 0.1.0

rawConnectionModifySocketSize :: (Socket -> IO ()) -> IO (Int -> Maybe HostAddress -> String -> Int -> IO Connection) #

Same as rawConnectionModifySocket, but also takes in a chunk size.

Since: http-client-0.5.2

rawConnectionModifySocket :: (Socket -> IO ()) -> IO (Maybe HostAddress -> String -> Int -> IO Connection) #

A value for the managerRawConnection setting, but also allows you to modify the underlying Socket to set additional settings. For a motivating use case, see: https://github.com/snoyberg/http-client/issues/71.

Since 0.3.8

observedStreamFile :: (StreamFileStatus -> IO ()) -> FilePath -> IO RequestBody #

Send a file as the request body, while observing streaming progress via a PopObserver. Observations are made between reading and sending a chunk.

It is expected that the file size does not change between calling observedStreamFile and making any requests using this request body.

Since 0.4.9

streamFile :: FilePath -> IO RequestBody #

Send a file as the request body.

It is expected that the file size does not change between calling streamFile and making any requests using this request body.

Since 0.4.9

setQueryStringPartialEscape :: [(ByteString, [EscapeItem])] -> Request -> Request #

Set the query string to the given key/value pairs.

Since: http-client-0.5.10

setQueryString :: [(ByteString, Maybe ByteString)] -> Request -> Request #

Set the query string to the given key/value pairs.

Since 0.3.6

setRequestCheckStatus :: Request -> Request #

Modify the request so that non-2XX status codes generate a runtime StatusCodeException, by using throwErrorStatusCodes

Since: http-client-0.5.13

setRequestIgnoreStatus :: Request -> Request #

Modify the request so that non-2XX status codes do not generate a runtime StatusCodeException.

Since: http-client-0.4.29

urlEncodedBody :: [(ByteString, ByteString)] -> Request -> Request #

Add url-encoded parameters to the Request.

This sets a new requestBody, adds a content-type request header and changes the method to POST.

Since 0.1.0

applyBasicProxyAuth :: ByteString -> ByteString -> Request -> Request #

Add a Proxy-Authorization header (with the specified username and password) to the given Request. Ignore error handling:

applyBasicProxyAuth "user" "pass" <$> parseRequest "http://example.org"

Since 0.3.4

applyBasicAuth :: ByteString -> ByteString -> Request -> Request #

Add a Basic Auth header (with the specified user name and password) to the given Request. Ignore error handling:

 applyBasicAuth "user" "pass" $ parseRequest_ url

NOTE: The function applyDigestAuth is provided by the http-client-tls package instead of this package due to extra dependencies. Please use that package if you need to use digest authentication.

Since 0.1.0

defaultRequest :: Request #

A default request value, a GET request of localhost/:80, with an empty request body.

Note that the default checkResponse does nothing.

Since: http-client-0.4.30

getUri :: Request -> URI #

Extract a URI from the request.

Since 0.1.0

requestFromURI_ :: URI -> Request #

Same as requestFromURI, but if the conversion would fail, throws an impure exception.

Since: http-client-0.5.12

requestFromURI :: MonadThrow m => URI -> m Request #

Convert a URI into a Request.

This can fail if the given URI is not absolute, or if the URI scheme is not "http" or "https". In these cases the function will throw an error via MonadThrow.

This function defaults some of the values in Request, such as setting method to GET and requestHeaders to [].

A Request created by this function won't cause exceptions on non-2XX response status codes.

Since: http-client-0.5.12

parseRequest_ :: String -> Request #

Same as parseRequest, but parse errors cause an impure exception. Mostly useful for static strings which are known to be correctly formatted.

parseRequest :: MonadThrow m => String -> m Request #

Convert a URL into a Request.

This function defaults some of the values in Request, such as setting method to GET and requestHeaders to [].

Since this function uses MonadThrow, the return monad can be anything that is an instance of MonadThrow, such as IO or Maybe.

You can place the request method at the beginning of the URL separated by a space, e.g.:

@@ parseRequest "POST http://httpbin.org/post" @@

Note that the request method must be provided as all capital letters.

A Request created by this function won't cause exceptions on non-2XX response status codes.

To create a request which throws on non-2XX status codes, see parseUrlThrow

Since: http-client-0.4.30

throwErrorStatusCodes :: MonadIO m => Request -> Response BodyReader -> m () #

Throws a StatusCodeException wrapped in HttpExceptionRequest, if the response's status code indicates an error (if it isn't 2xx). This can be used to implement checkResponse.

Since: http-client-0.5.13

parseUrlThrow :: MonadThrow m => String -> m Request #

Same as parseRequest, except will throw an HttpException in the event of a non-2XX response. This uses throwErrorStatusCodes to implement checkResponse.

Since: http-client-0.4.30

parseUrl :: MonadThrow m => String -> m Request #

Deprecated synonym for parseUrlThrow. You probably want parseRequest or parseRequest_ instead.

Since: http-client-0.1.0

brConsume :: BodyReader -> IO [ByteString] #

Strictly consume all remaining chunks of data from the stream.

Since 0.1.0

brReadSome :: BodyReader -> Int -> IO ByteString #

Continuously call brRead, building up a lazy ByteString until a chunk is constructed that is at least as many bytes as requested.

Since 0.4.20

brRead :: BodyReader -> IO ByteString #

Get a single chunk of data from the response body, or an empty bytestring if no more data is available.

Note that in order to consume the entire request body, you will need to repeatedly call this function until you receive an empty ByteString as a result.

Since 0.1.0

socketConnection #

Arguments

:: Socket 
-> Int

chunk size

-> IO Connection 

Create a new Connection from a Socket.

Since: http-client-0.5.3

makeConnection #

Arguments

:: IO ByteString

read

-> (ByteString -> IO ())

write

-> IO ()

close

-> IO Connection 

Create a new Connection from a read, write, and close function.

Since: http-client-0.5.3

type BodyReader = IO ByteString #

An IO action that represents an incoming response body coming from the server. Data provided by this action has already been gunzipped and de-chunked, and respects any content-length headers present.

The action gets a single chunk of data from the response body, or an empty bytestring if no more data is available.

Since 0.4.0

data HttpException #

An exception which may be generated by this library

Since: http-client-0.5.0

Constructors

HttpExceptionRequest Request HttpExceptionContent

Most exceptions are specific to a Request. Inspect the HttpExceptionContent value for details on what occurred.

Since: http-client-0.5.0

InvalidUrlException String String

A URL (first field) is invalid for a given reason (second argument).

Since: http-client-0.5.0

data HttpExceptionContent #

Constructors

StatusCodeException (Response ()) ByteString

Generated by the parseUrlThrow function when the server returns a non-2XX response status code.

May include the beginning of the response body.

Since: http-client-0.5.0

TooManyRedirects [Response ByteString]

The server responded with too many redirects for a request.

Contains the list of encountered responses containing redirects in reverse chronological order; including last redirect, which triggered the exception and was not followed.

Since: http-client-0.5.0

OverlongHeaders

Either too many headers, or too many total bytes in a single header, were returned by the server, and the memory exhaustion protection in this library has kicked in.

Since: http-client-0.5.0

ResponseTimeout

The server took too long to return a response. This can be altered via responseTimeout or managerResponseTimeout.

Since: http-client-0.5.0

ConnectionTimeout

Attempting to connect to the server timed out.

Since: http-client-0.5.0

ConnectionFailure SomeException

An exception occurred when trying to connect to the server.

Since: http-client-0.5.0

InvalidStatusLine ByteString

The status line returned by the server could not be parsed.

Since: http-client-0.5.0

InvalidHeader ByteString

The given response header line could not be parsed

Since: http-client-0.5.0

InternalException SomeException

An exception was raised by an underlying library when performing the request. Most often, this is caused by a failing socket action or a TLS exception.

Since: http-client-0.5.0

ProxyConnectException ByteString Int Status

A non-200 status code was returned when trying to connect to the proxy server on the given host and port.

Since: http-client-0.5.0

NoResponseDataReceived

No response data was received from the server at all. This exception may deserve special handling within the library, since it may indicate that a pipelining has been used, and a connection thought to be open was in fact closed.

Since: http-client-0.5.0

TlsNotSupported

Exception thrown when using a Manager which does not have support for secure connections. Typically, you will want to use tlsManagerSettings from http-client-tls to overcome this.

Since: http-client-0.5.0

WrongRequestBodyStreamSize Word64 Word64

The request body provided did not match the expected size.

Provides the expected and actual size.

Since: http-client-0.4.31

ResponseBodyTooShort Word64 Word64

The returned response body is too short. Provides the expected size and actual size.

Since: http-client-0.5.0

InvalidChunkHeaders

A chunked response body had invalid headers.

Since: http-client-0.5.0

IncompleteHeaders

An incomplete set of response headers were returned.

Since: http-client-0.5.0

InvalidDestinationHost ByteString

The host we tried to connect to is invalid (e.g., an empty string).

HttpZlibException ZlibException

An exception was thrown when inflating a response body.

Since: http-client-0.5.0

InvalidProxyEnvironmentVariable Text Text

Values in the proxy environment variable were invalid. Provides the environment variable name and its value.

Since: http-client-0.5.0

ConnectionClosed

Attempted to use a Connection which was already closed

Since: http-client-0.5.0

InvalidProxySettings Text

Proxy settings are not valid (Windows specific currently) @since 0.5.7

proxyHost :: Proxy -> ByteString #

The host name of the HTTP proxy.

proxyPort :: Proxy -> Int #

The port number of the HTTP proxy.

data RequestBody #

When using one of the RequestBodyStream / RequestBodyStreamChunked constructors, you must ensure that the GivesPopper can be called multiple times. Usually this is not a problem.

The RequestBodyStreamChunked will send a chunked request body. Note that not all servers support this. Only use RequestBodyStreamChunked if you know the server you're sending to supports chunked request bodies.

Since 0.1.0

Constructors

RequestBodyLBS ByteString 
RequestBodyBS ByteString 
RequestBodyBuilder Int64 Builder 
RequestBodyStream Int64 (GivesPopper ()) 
RequestBodyStreamChunked (GivesPopper ()) 
RequestBodyIO (IO RequestBody)

Allows creation of a RequestBody inside the IO monad, which is useful for making easier APIs (like setRequestBodyFile).

Since: http-client-0.4.28

type Popper = IO ByteString #

A function which generates successive chunks of a request body, provider a single empty bytestring when no more data is available.

Since 0.1.0

type NeedsPopper a = Popper -> IO a #

A function which must be provided with a Popper.

Since 0.1.0

type GivesPopper a = NeedsPopper a -> IO a #

A function which will provide a Popper to a NeedsPopper. This seemingly convoluted structure allows for creation of request bodies which allocate scarce resources in an exception safe manner.

Since 0.1.0

data Request #

All information on how to connect to a host and what should be sent in the HTTP request.

If you simply wish to download from a URL, see parseRequest.

The constructor for this data type is not exposed. Instead, you should use either the defaultRequest value, or parseRequest to construct from a URL, and then use the records below to make modifications. This approach allows http-client to add configuration options without breaking backwards compatibility.

For example, to construct a POST request, you could do something like:

initReq <- parseRequest "http://www.example.com/path"
let req = initReq
            { method = "POST"
            }

For more information, please see http://www.yesodweb.com/book/settings-types.

Since 0.1.0

Instances
Show Request 
Instance details

Defined in Network.HTTP.Client.Types

data ResponseTimeout #

How to deal with timing out a response

Since: http-client-0.5.0

data Response body #

A simple representation of the HTTP response.

Since 0.1.0

Instances
Functor Response 
Instance details

Defined in Network.HTTP.Client.Types

Methods

fmap :: (a -> b) -> Response a -> Response b #

(<$) :: a -> Response b -> Response a #

Foldable Response 
Instance details

Defined in Network.HTTP.Client.Types

Methods

fold :: Monoid m => Response m -> m #

foldMap :: Monoid m => (a -> m) -> Response a -> m #

foldr :: (a -> b -> b) -> b -> Response a -> b #

foldr' :: (a -> b -> b) -> b -> Response a -> b #

foldl :: (b -> a -> b) -> b -> Response a -> b #

foldl' :: (b -> a -> b) -> b -> Response a -> b #

foldr1 :: (a -> a -> a) -> Response a -> a #

foldl1 :: (a -> a -> a) -> Response a -> a #

toList :: Response a -> [a] #

null :: Response a -> Bool #

length :: Response a -> Int #

elem :: Eq a => a -> Response a -> Bool #

maximum :: Ord a => Response a -> a #

minimum :: Ord a => Response a -> a #

sum :: Num a => Response a -> a #

product :: Num a => Response a -> a #

Traversable Response 
Instance details

Defined in Network.HTTP.Client.Types

Methods

traverse :: Applicative f => (a -> f b) -> Response a -> f (Response b) #

sequenceA :: Applicative f => Response (f a) -> f (Response a) #

mapM :: Monad m => (a -> m b) -> Response a -> m (Response b) #

sequence :: Monad m => Response (m a) -> m (Response a) #

Eq body => Eq (Response body) 
Instance details

Defined in Network.HTTP.Client.Types

Methods

(==) :: Response body -> Response body -> Bool #

(/=) :: Response body -> Response body -> Bool #

Show body => Show (Response body) 
Instance details

Defined in Network.HTTP.Client.Types

Methods

showsPrec :: Int -> Response body -> ShowS #

show :: Response body -> String #

showList :: [Response body] -> ShowS #

data ManagerSettings #

Settings for a Manager. Please use the defaultManagerSettings function and then modify individual settings. For more information, see http://www.yesodweb.com/book/settings-types.

Since 0.1.0

data ProxyOverride #

How the HTTP proxy server settings should be discovered.

Since 0.4.7

data Manager #

Keeps track of open connections for keep-alive.

If possible, you should share a single Manager between multiple threads and requests.

Since 0.1.0

Instances
HasHttpManager Manager 
Instance details

Defined in Network.HTTP.Client.Types

class HasHttpManager a where #

Minimal complete definition

getHttpManager

Methods

getHttpManager :: a -> Manager #

Instances
Has ModHttpClient α => HasHttpManager α # 
Instance details

Defined in Magicbane.Has

Methods

getHttpManager :: α -> Manager #

HasHttpManager Manager 
Instance details

Defined in Network.HTTP.Client.Types

type Query = [QueryItem] #

Query.

General form: a=b&c=d, but if the value is Nothing, it becomes a&c=d.

parseLinkHeaderBS :: ByteString -> Maybe [Link] #

Parses a Link header, returns a Maybe.

parseLinkHeaderBS' :: ByteString -> Either String [Link] #

Parses a Link header, returns an Either, where Left is the Attoparsec error string (probably not a useful one).

parseLinkHeader :: Text -> Maybe [Link] #

Parses a Link header, returns a Maybe.

parseLinkHeader' :: Text -> Either String [Link] #

Parses a Link header, returns an Either, where Left is the Attoparsec error string (probably not a useful one).

linkHeader :: Parser [Link] #

The Attoparsec parser for the Link header.

linkParams :: Link -> [(LinkParam, Text)] #

Extracts the parameters from the link.

href :: Link -> URI #

Extracts the URI from the link.

data LinkParam #

The link attribute key.

Instances
Eq LinkParam 
Instance details

Defined in Network.HTTP.Link.Types

Show LinkParam 
Instance details

Defined in Network.HTTP.Link.Types

http20 :: HttpVersion #

HTTP 2.0

http11 :: HttpVersion #

HTTP 1.1

http10 :: HttpVersion #

HTTP 1.0

http09 :: HttpVersion #

HTTP 0.9

data HttpVersion #

HTTP Version.

Note that the Show instance is intended merely for debugging.

Constructors

HttpVersion 

Fields

Instances
Eq HttpVersion 
Instance details

Defined in Network.HTTP.Types.Version

Ord HttpVersion 
Instance details

Defined in Network.HTTP.Types.Version

Show HttpVersion 
Instance details

Defined in Network.HTTP.Types.Version

HasLink sub => HasLink (HttpVersion :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (HttpVersion :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (HttpVersion :> sub) -> Link -> MkLink (HttpVersion :> sub) a #

HasServer api context => HasServer (HttpVersion :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (HttpVersion :> api) m :: * #

Methods

route :: Proxy (HttpVersion :> api) -> Context context -> Delayed env (Server (HttpVersion :> api)) -> Router env #

hoistServerWithContext :: Proxy (HttpVersion :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (HttpVersion :> api) m -> ServerT (HttpVersion :> api) n #

type MkLink (HttpVersion :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (HttpVersion :> sub :: *) a = MkLink sub a
type ServerT (HttpVersion :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (HttpVersion :> api :: *) m = HttpVersion -> ServerT api m

class QueryLike a where #

Types which can, and commonly are, converted to Query are in this class.

You can use lists of simple key value pairs, with ByteString (strict, or lazy: ByteString), Text, or String as the key/value types. You can also have the value type lifted into a Maybe to support keys without values; and finally it is possible to put each pair into a Maybe for key-value pairs that aren't always present.

Minimal complete definition

toQuery

Methods

toQuery :: a -> Query #

Convert to Query.

Instances
(QueryKeyLike k, QueryValueLike v) => QueryLike [Maybe (k, v)] 
Instance details

Defined in Network.HTTP.Types.QueryLike

Methods

toQuery :: [Maybe (k, v)] -> Query #

(QueryKeyLike k, QueryValueLike v) => QueryLike [(k, v)] 
Instance details

Defined in Network.HTTP.Types.QueryLike

Methods

toQuery :: [(k, v)] -> Query #

renderQueryBuilderPartialEscape #

Arguments

:: Bool

prepend a question mark?

-> PartialEscapeQuery 
-> Builder 

Convert PartialEscapeQuery to a Builder.

renderQueryPartialEscape #

Arguments

:: Bool

prepend question mark?

-> PartialEscapeQuery 
-> ByteString 

Convert PartialEscapeQuery to ByteString.

decodePath :: ByteString -> ([Text], Query) #

Decode a whole path (path segments + query).

encodePath :: [Text] -> Query -> Builder #

Encode a whole path (path segments + query).

extractPath :: ByteString -> ByteString #

Extract whole path (path segments + query) from a RFC 2616 Request-URI.

>>> extractPath "/path"
"/path"
>>> extractPath "http://example.com:8080/path"
"/path"
>>> extractPath "http://example.com"
"/"
>>> extractPath ""
"/"

decodePathSegments :: ByteString -> [Text] #

Parse a list of path segments from a valid URL fragment.

encodePathSegments :: [Text] -> Builder #

Encodes a list of path segments into a valid URL fragment.

This function takes the following three steps:

  • UTF-8 encodes the characters.
  • Performs percent encoding on all unreserved characters, as well as :@=+$,
  • Prepends each segment with a slash.

For example:

encodePathSegments [\"foo\", \"bar\", \"baz\"]

"/foo/bar/baz"

encodePathSegments [\"foo bar\", \"baz\/bin\"]

"/foo%20bar/baz%2Fbin"

encodePathSegments [\"שלום\"]

"/%D7%A9%D7%9C%D7%95%D7%9D"

Huge thanks to Jeremy Shaw who created the original implementation of this function in web-routes and did such thorough research to determine all correct escaping procedures.

urlDecode #

Arguments

:: Bool

Whether to decode + to ' '

-> ByteString 
-> ByteString 

Percent-decoding.

urlEncode #

Arguments

:: Bool

Whether to decode + to ' '

-> ByteString

The ByteString to encode as URL

-> ByteString

The encoded URL

Percent-encoding for URLs.

urlEncodeBuilder #

Arguments

:: Bool

Whether input is in query string. True: Query string, False: Path element

-> ByteString 
-> Builder 

Percent-encoding for URLs (using Builder).

parseSimpleQuery :: ByteString -> SimpleQuery #

Parse SimpleQuery from a ByteString.

parseQuery :: ByteString -> Query #

Split out the query string into a list of keys and values. A few importants points:

  • The result returned is still bytestrings, since we perform no character decoding here. Most likely, you will want to use UTF-8 decoding, but this is left to the user of the library.
  • Percent decoding errors are ignored. In particular, "%Q" will be output as "%Q".

renderSimpleQuery #

Arguments

:: Bool

prepend question mark?

-> SimpleQuery 
-> ByteString 

Convert SimpleQuery to ByteString.

renderQuery #

Arguments

:: Bool

prepend question mark?

-> Query 
-> ByteString 

Convert Query to ByteString.

renderQueryBuilder #

Arguments

:: Bool

prepend a question mark?

-> Query 
-> Builder 

Convert Query to a Builder.

parseQueryText :: ByteString -> QueryText #

Parse QueryText from a ByteString. See parseQuery for details.

queryToQueryText :: Query -> QueryText #

Convert Query to QueryText (leniently decoding the UTF-8).

renderQueryText #

Arguments

:: Bool

prepend a question mark?

-> QueryText 
-> Builder 

Convert QueryText to a Builder.

type QueryItem = (ByteString, Maybe ByteString) #

Query item

type QueryText = [(Text, Maybe Text)] #

Like Query, but with Text instead of ByteString (UTF8-encoded).

type SimpleQueryItem = (ByteString, ByteString) #

Simplified Query item type without support for parameter-less items.

type SimpleQuery = [SimpleQueryItem] #

Simplified Query type without support for parameter-less items.

data EscapeItem #

For some URIs characters must not be URI encoded, eg + or : in q=a+language:haskell+created:2009-01-01..2009-02-01&sort=stars The character list unreservedPI instead of unreservedQS would solve this. But we explicitly decide what part to encode. This is mandatory when searching for +: q=%2B+language:haskell.

Constructors

QE ByteString 
QN ByteString 

type PartialEscapeQuery = [PartialEscapeQueryItem] #

Query with some chars that should not be escaped.

General form: a=b&c=d:e+f&g=h

statusIsServerError :: Status -> Bool #

Server Error class

statusIsClientError :: Status -> Bool #

Client Error class

statusIsRedirection :: Status -> Bool #

Redirection class

statusIsSuccessful :: Status -> Bool #

Successful class

statusIsInformational :: Status -> Bool #

Informational class

networkAuthenticationRequired511 :: Status #

Network Authentication Required 511 (RFC 6585)

status511 :: Status #

Network Authentication Required 511 (RFC 6585)

httpVersionNotSupported505 :: Status #

HTTP Version Not Supported 505

status505 :: Status #

HTTP Version Not Supported 505

gatewayTimeout504 :: Status #

Gateway Timeout 504

status504 :: Status #

Gateway Timeout 504

serviceUnavailable503 :: Status #

Service Unavailable 503

status503 :: Status #

Service Unavailable 503

badGateway502 :: Status #

Bad Gateway 502

status502 :: Status #

Bad Gateway 502

notImplemented501 :: Status #

Not Implemented 501

status501 :: Status #

Not Implemented 501

internalServerError500 :: Status #

Internal Server Error 500

status500 :: Status #

Internal Server Error 500

requestHeaderFieldsTooLarge431 :: Status #

Request Header Fields Too Large 431 (RFC 6585)

status431 :: Status #

Request Header Fields Too Large 431 (RFC 6585)

tooManyRequests429 :: Status #

Too Many Requests 429 (RFC 6585)

status429 :: Status #

Too Many Requests 429 (RFC 6585)

preconditionRequired428 :: Status #

Precondition Required 428 (RFC 6585)

status428 :: Status #

Precondition Required 428 (RFC 6585)

unprocessableEntity422 :: Status #

Unprocessable Entity 422 (RFC 4918)

status422 :: Status #

Unprocessable Entity 422 (RFC 4918)

imATeapot418 :: Status #

I'm a teapot 418

status418 :: Status #

I'm a teapot 418

expectationFailed417 :: Status #

Expectation Failed 417

status417 :: Status #

Expectation Failed 417

requestedRangeNotSatisfiable416 :: Status #

Requested Range Not Satisfiable 416

status416 :: Status #

Requested Range Not Satisfiable 416

unsupportedMediaType415 :: Status #

Unsupported Media Type 415

status415 :: Status #

Unsupported Media Type 415

requestURITooLong414 :: Status #

Request-URI Too Long 414

status414 :: Status #

Request-URI Too Long 414

requestEntityTooLarge413 :: Status #

Request Entity Too Large 413

status413 :: Status #

Request Entity Too Large 413

preconditionFailed412 :: Status #

Precondition Failed 412

status412 :: Status #

Precondition Failed 412

lengthRequired411 :: Status #

Length Required 411

status411 :: Status #

Length Required 411

gone410 :: Status #

Gone 410

status410 :: Status #

Gone 410

conflict409 :: Status #

Conflict 409

status409 :: Status #

Conflict 409

requestTimeout408 :: Status #

Request Timeout 408

status408 :: Status #

Request Timeout 408

proxyAuthenticationRequired407 :: Status #

Proxy Authentication Required 407

status407 :: Status #

Proxy Authentication Required 407

notAcceptable406 :: Status #

Not Acceptable 406

status406 :: Status #

Not Acceptable 406

methodNotAllowed405 :: Status #

Method Not Allowed 405

status405 :: Status #

Method Not Allowed 405

notFound404 :: Status #

Not Found 404

status404 :: Status #

Not Found 404

forbidden403 :: Status #

Forbidden 403

status403 :: Status #

Forbidden 403

paymentRequired402 :: Status #

Payment Required 402

status402 :: Status #

Payment Required 402

unauthorized401 :: Status #

Unauthorized 401

status401 :: Status #

Unauthorized 401

badRequest400 :: Status #

Bad Request 400

status400 :: Status #

Bad Request 400

permanentRedirect308 :: Status #

Permanent Redirect 308

status308 :: Status #

Permanent Redirect 308

temporaryRedirect307 :: Status #

Temporary Redirect 307

status307 :: Status #

Temporary Redirect 307

useProxy305 :: Status #

Use Proxy 305

status305 :: Status #

Use Proxy 305

notModified304 :: Status #

Not Modified 304

status304 :: Status #

Not Modified 304

seeOther303 :: Status #

See Other 303

status303 :: Status #

See Other 303

found302 :: Status #

Found 302

status302 :: Status #

Found 302

movedPermanently301 :: Status #

Moved Permanently 301

status301 :: Status #

Moved Permanently 301

multipleChoices300 :: Status #

Multiple Choices 300

status300 :: Status #

Multiple Choices 300

partialContent206 :: Status #

Partial Content 206

status206 :: Status #

Partial Content 206

resetContent205 :: Status #

Reset Content 205

status205 :: Status #

Reset Content 205

noContent204 :: Status #

No Content 204

status204 :: Status #

No Content 204

nonAuthoritative203 :: Status #

Non-Authoritative Information 203

status203 :: Status #

Non-Authoritative Information 203

accepted202 :: Status #

Accepted 202

status202 :: Status #

Accepted 202

created201 :: Status #

Created 201

status201 :: Status #

Created 201

ok200 :: Status #

OK 200

status200 :: Status #

OK 200

switchingProtocols101 :: Status #

Switching Protocols 101

status101 :: Status #

Switching Protocols 101

continue100 :: Status #

Continue 100

status100 :: Status #

Continue 100

mkStatus :: Int -> ByteString -> Status #

Create a Status from status code and message.

data Status #

HTTP Status.

Only the statusCode is used for comparisons.

Please use mkStatus to create status codes from code and message, or the Enum instance or the status code constants (like ok200). There might be additional record members in the future.

Note that the Show instance is only for debugging.

Constructors

Status 
Instances
Bounded Status 
Instance details

Defined in Network.HTTP.Types.Status

Enum Status 
Instance details

Defined in Network.HTTP.Types.Status

Eq Status 
Instance details

Defined in Network.HTTP.Types.Status

Methods

(==) :: Status -> Status -> Bool #

(/=) :: Status -> Status -> Bool #

Ord Status 
Instance details

Defined in Network.HTTP.Types.Status

Show Status 
Instance details

Defined in Network.HTTP.Types.Status

renderStdMethod :: StdMethod -> Method #

Convert a StdMethod to a ByteString.

renderMethod :: Either ByteString StdMethod -> Method #

Convert an algebraic method to a ByteString.

parseMethod :: Method -> Either ByteString StdMethod #

Convert a method ByteString to a StdMethod if possible.

methodPatch :: Method #

HTTP Method constants.

methodOptions :: Method #

HTTP Method constants.

methodConnect :: Method #

HTTP Method constants.

methodTrace :: Method #

HTTP Method constants.

methodDelete :: Method #

HTTP Method constants.

methodPut :: Method #

HTTP Method constants.

methodHead :: Method #

HTTP Method constants.

methodPost :: Method #

HTTP Method constants.

methodGet :: Method #

HTTP Method constants.

type Method = ByteString #

HTTP method (flat string type).

data StdMethod #

HTTP standard method (as defined by RFC 2616, and PATCH which is defined by RFC 5789).

Constructors

GET 
POST 
HEAD 
PUT 
DELETE 
TRACE 
CONNECT 
OPTIONS 
PATCH 
Instances
Bounded StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Enum StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Eq StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Ord StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Read StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Show StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Ix StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

ReflectMethod PATCH 
Instance details

Defined in Servant.API.Verbs

ReflectMethod OPTIONS 
Instance details

Defined in Servant.API.Verbs

ReflectMethod CONNECT 
Instance details

Defined in Servant.API.Verbs

ReflectMethod TRACE 
Instance details

Defined in Servant.API.Verbs

ReflectMethod DELETE 
Instance details

Defined in Servant.API.Verbs

ReflectMethod PUT 
Instance details

Defined in Servant.API.Verbs

ReflectMethod HEAD 
Instance details

Defined in Servant.API.Verbs

ReflectMethod POST 
Instance details

Defined in Servant.API.Verbs

ReflectMethod GET 
Instance details

Defined in Servant.API.Verbs

parseByteRanges :: ByteString -> Maybe ByteRanges #

Parse the value of a Range header into a ByteRanges.

>>> parseByteRanges "error"
Nothing
>>> parseByteRanges "bytes=0-499"
Just [ByteRangeFromTo 0 499]
>>> parseByteRanges "bytes=500-999"
Just [ByteRangeFromTo 500 999]
>>> parseByteRanges "bytes=-500"
Just [ByteRangeSuffix 500]
>>> parseByteRanges "bytes=9500-"
Just [ByteRangeFrom 9500]
>>> parseByteRanges "bytes=0-0,-1"
Just [ByteRangeFromTo 0 0,ByteRangeSuffix 1]
>>> parseByteRanges "bytes=500-600,601-999"
Just [ByteRangeFromTo 500 600,ByteRangeFromTo 601 999]
>>> parseByteRanges "bytes=500-700,601-999"
Just [ByteRangeFromTo 500 700,ByteRangeFromTo 601 999]

type HeaderName = CI ByteString #

Header name

type RequestHeaders = [Header] #

Request Headers

type ResponseHeaders = [Header] #

Response Headers

data ByteRange #

RFC 2616 Byte range (individual).

Negative indices are not allowed!

Instances
Eq ByteRange 
Instance details

Defined in Network.HTTP.Types.Header

Data ByteRange 
Instance details

Defined in Network.HTTP.Types.Header

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ByteRange -> c ByteRange #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ByteRange #

toConstr :: ByteRange -> Constr #

dataTypeOf :: ByteRange -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ByteRange) #

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

gmapT :: (forall b. Data b => b -> b) -> ByteRange -> ByteRange #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ByteRange -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ByteRange -> r #

gmapQ :: (forall d. Data d => d -> u) -> ByteRange -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ByteRange -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ByteRange -> m ByteRange #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteRange -> m ByteRange #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteRange -> m ByteRange #

Ord ByteRange 
Instance details

Defined in Network.HTTP.Types.Header

Show ByteRange 
Instance details

Defined in Network.HTTP.Types.Header

type ByteRanges = [ByteRange] #

RFC 2616 Byte ranges (set).

label' :: (MonadIO m, MonadMetrics m, Show a) => Text -> a -> m () #

Set the Label to the Shown value of whatever you pass in.

  • Since v0.1.0.0

label :: (MonadIO m, MonadMetrics m) => Text -> Text -> m () #

Set the Label to the given Text value.

  • Since v0.1.0.0

timed :: (MonadIO m, MonadMetrics m, MonadMask m) => Text -> m a -> m a #

Record the time of executing the given action in seconds. Defers to timed'.

  • Since v0.1.0.0

timedList :: (MonadIO m, MonadMetrics m, MonadMask m) => Resolution -> [Text] -> m a -> m a #

Record the time taken to perform the action, under several names at once. The number is stored in a Distribution and is converted to the specified Resolution.

This is useful to store the same durations data sectioned by different criteria, e.g.:

timedList Seconds ["request.byUser." <> userName, "request.byType." <> requestType] $ do
    ...

So you will have "request.byUser.someuser" storing duration distribution for requests of user "someuser" of any type; and "request.byType.sometype" storing duration distribution for requests of type "sometype" from any user.

timed' :: (MonadIO m, MonadMetrics m, MonadMask m) => Resolution -> Text -> m a -> m a #

Record the time taken to perform the named action. The number is stored in a Distribution and is converted to the specified Resolution.

  • Since v0.1.0.0

gauge :: (MonadIO m, MonadMetrics m) => Text -> Int -> m () #

A type specialized version of gauge' to avoid ambiguous types.

  • Since v0.1.0.0

gauge' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m () #

Set the value of the named Gauge.

  • Since v0.1.0.0

distribution :: (MonadIO m, MonadMetrics m) => Text -> Double -> m () #

Add the value to the named Distribution.

  • Since v0.1.0.0

counter :: (MonadIO m, MonadMetrics m) => Text -> Int -> m () #

A type specialized version of counter' to avoid ambiguous type errors.

  • Since v0.1.0.0

counter' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m () #

Adds the value to the named Counter.

  • Since v0.1.0.0

increment :: (MonadIO m, MonadMetrics m) => Text -> m () #

Increment the named counter by 1.

  • Since v0.1.0.0

class Monad m => MonadMetrics (m :: * -> *) where #

A type can be an instance of MonadMetrics if it can provide a Metrics somehow. Commonly, this will be implemented as a ReaderT where some field in the environment is the Metrics data.

  • Since v0.1.0.0

Minimal complete definition

getMetrics

Methods

getMetrics :: m Metrics #

Instances
(Has ModMetrics α, Monad μ, MonadReader α μ) => MonadMetrics μ # 
Instance details

Defined in Magicbane.Has

Methods

getMetrics :: μ Metrics #

(MonadMetrics m, MonadTrans t, Monad (t m)) => MonadMetrics (t m) 
Instance details

Defined in Control.Monad.Metrics

Methods

getMetrics :: t m Metrics #

Monad m => MonadMetrics (ReaderT Metrics m) 
Instance details

Defined in Control.Monad.Metrics

metricsStore :: Lens' Metrics Store #

A lens into the Store provided by the Metrics.

  • Since v0.1.0.0

metricsLabels :: Lens' Metrics (IORef (HashMap Text Label)) #

A lens into the Labels provided by the Metrics.

  • Since v0.1.0.0

metricsGauges :: Lens' Metrics (IORef (HashMap Text Gauge)) #

A lens into the Gauges provided by the Metrics.

  • Since v0.1.0.0

metricsCounters :: Lens' Metrics (IORef (HashMap Text Counter)) #

A lens into the Counters provided by the Metrics.

  • Since v0.1.0.0

data Metrics #

A container for metrics used by the MonadMetrics class.

  • Since v0.1.0.0
Instances
Monad m => MonadMetrics (ReaderT Metrics m) 
Instance details

Defined in Control.Monad.Metrics

throwError :: MonadError e m => e -> m a #

Is used within a monadic computation to begin exception processing.

normalizePathSegments :: String -> String #

Path segment normalization; cf. RFC3986 section 6.2.2.3

normalizeEscape :: String -> String #

Encoding normalization; cf. RFC3986 section 6.2.2.2

normalizeCase :: String -> String #

Case normalization; cf. RFC3986 section 6.2.2.1 NOTE: authority case normalization is not performed

relativeFrom :: URI -> URI -> URI #

Returns a new URI which represents the relative location of the first URI with respect to the second URI. Thus, the values supplied are expected to be absolute URIs, and the result returned may be a relative URI.

Example:

"http://example.com/Root/sub1/name2#frag"
  `relativeFrom` "http://example.com/Root/sub2/name2#frag"
  == "../sub1/name2#frag"

There is no single correct implementation of this function, but any acceptable implementation must satisfy the following:

(uabs `relativeFrom` ubase) `relativeTo` ubase == uabs

For any valid absolute URI. (cf. http://lists.w3.org/Archives/Public/uri/2003Jan/0008.html http://lists.w3.org/Archives/Public/uri/2003Jan/0005.html)

pathSegments :: URI -> [String] #

Returns the segments of the path component. E.g., pathSegments $ parseURI "http://example.org/foo/bar/baz" == ["foo", "bar", "baz"]

relativeTo :: URI -> URI -> URI #

Returns a new URI which represents the value of the first URI interpreted as relative to the second URI.

Algorithm from RFC3986 [3], section 5.2

nonStrictRelativeTo :: URI -> URI -> URI #

Returns a new URI which represents the value of the first URI interpreted as relative to the second URI. For example:

"foo" `relativeTo` "http://bar.org/" = "http://bar.org/foo"
"http:foo" `nonStrictRelativeTo` "http://bar.org/" = "http://bar.org/foo"

Algorithm from RFC3986 [3], section 5.2.2

unEscapeString :: String -> String #

Turns all instances of escaped characters in the string back into literal characters.

escapeURIString #

Arguments

:: (Char -> Bool)

a predicate which returns False if the character should be escaped

-> String

the string to process

-> String

the resulting URI string

Can be used to make a string valid for use in a URI.

escapeURIChar :: (Char -> Bool) -> Char -> String #

Escape character if supplied predicate is not satisfied, otherwise return character as singleton string.

isUnescapedInURIComponent :: Char -> Bool #

Returns True if the character is allowed unescaped in a URI component.

>>> escapeURIString isUnescapedInURIComponent "http://haskell.org:80?some_param=true&other_param=їґ"
"http%3A%2F%2Fhaskell.org%3A80%3Fsome_param%3Dtrue%26other_param%3D%D1%97%D2%91"

isUnescapedInURI :: Char -> Bool #

Returns True if the character is allowed unescaped in a URI.

>>> escapeURIString isUnescapedInURI "http://haskell.org:80?some_param=true&other_param=їґ"
"http://haskell.org:80?some_param=true&other_param=%D1%97%D2%91"

isAllowedInURI :: Char -> Bool #

Returns True if the character is allowed in a URI.

uriToString :: (String -> String) -> URI -> ShowS #

Turn a URI into a string.

Uses a supplied function to map the userinfo part of the URI.

The Show instance for URI uses a mapping that hides any password that may be present in the URI. Use this function with argument id to preserve the password in the formatted output.

isUnreserved :: Char -> Bool #

Returns True if the character is an "unreserved" character in a URI. These characters do not need to be escaped in a URI. The only characters allowed in a URI are either "reserved", "unreserved", or an escape sequence (% followed by two hex digits).

isReserved :: Char -> Bool #

Returns True if the character is a "reserved" character in a URI. To include a literal instance of one of these characters in a component of a URI, it must be escaped.

isIPv4address :: String -> Bool #

Test if string contains a valid IPv4 address

isIPv6address :: String -> Bool #

Test if string contains a valid IPv6 address

isAbsoluteURI :: String -> Bool #

Test if string contains a valid absolute URI (an absolute URI without a fragment identifier).

isRelativeReference :: String -> Bool #

Test if string contains a valid relative URI (a relative URI with optional fragment identifier).

isURIReference :: String -> Bool #

Test if string contains a valid URI reference (an absolute or relative URI with optional fragment identifier).

isURI :: String -> Bool #

Test if string contains a valid URI (an absolute URI with optional fragment identifier).

parseAbsoluteURI :: String -> Maybe URI #

Parse an absolute URI to a URI value. Returns Nothing if the string is not a valid absolute URI. (an absolute URI without a fragment identifier).

parseRelativeReference :: String -> Maybe URI #

Parse a relative URI to a URI value. Returns Nothing if the string is not a valid relative URI. (a relative URI with optional fragment identifier).

parseURIReference :: String -> Maybe URI #

Parse a URI reference to a URI value. Returns Nothing if the string is not a valid URI reference. (an absolute or relative URI with optional fragment identifier).

parseURI :: String -> Maybe URI #

Turn a string containing a URI into a URI. Returns Nothing if the string is not a valid URI; (an absolute URI with optional fragment identifier).

NOTE: this is different from the previous network.URI, whose parseURI function works like parseURIReference in this module.

nullURI :: URI #

Blank URI

data URIAuth #

Type for authority value within a URI

Constructors

URIAuth 

Fields

Instances
Eq URIAuth 
Instance details

Defined in Network.URI

Methods

(==) :: URIAuth -> URIAuth -> Bool #

(/=) :: URIAuth -> URIAuth -> Bool #

Data URIAuth 
Instance details

Defined in Network.URI

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> URIAuth -> c URIAuth #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c URIAuth #

toConstr :: URIAuth -> Constr #

dataTypeOf :: URIAuth -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c URIAuth) #

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

gmapT :: (forall b. Data b => b -> b) -> URIAuth -> URIAuth #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> URIAuth -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> URIAuth -> r #

gmapQ :: (forall d. Data d => d -> u) -> URIAuth -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> URIAuth -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> URIAuth -> m URIAuth #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> URIAuth -> m URIAuth #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> URIAuth -> m URIAuth #

Ord URIAuth 
Instance details

Defined in Network.URI

Show URIAuth 
Instance details

Defined in Network.URI

NFData URIAuth 
Instance details

Defined in Network.URI

Methods

rnf :: URIAuth -> () #

rQ :: QuasiQuoter #

A variant of r that interprets the "|~]" sequence as "|]", "|~~]" as "|~]" and, in general, "|~^n]" as "|~^(n-1)]" for n >= 1.

Usage:

    ghci> [rQ||~]|~]|]
    "|]|]"
    ghci> [rQ||~~]|]
    "|~]"
    ghci> [rQ||~~~~]|]
    "|~~~]"

r :: QuasiQuoter #

A quasiquoter for raw string literals - that is, string literals that don't recognise the standard escape sequences (such as '\n'). Basically, they make your code more readable by freeing you from the responsibility to escape backslashes. They are useful when working with regular expressions, DOS/Windows paths and markup languages (such as XML).

Don't forget the LANGUAGE QuasiQuotes pragma if you're using this module in your code.

Usage:

    ghci> :set -XQuasiQuotes
    ghci> import Text.RawString.QQ
    ghci> let s = [r|\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}|]
    ghci> s
    "\\w+@[a-zA-Z_]+?\\.[a-zA-Z]{2,3}"
    ghci> [r|C:\Windows\SYSTEM|] ++ [r|\user32.dll|]
    "C:\\Windows\\SYSTEM\\user32.dll"

Multiline raw string literals are also supported:

    multiline :: String
    multiline = [r|<HTML>
    <HEAD>
    <TITLE>Auto-generated html formated source</TITLE>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
    </HEAD>
    <BODY LINK="800080" BGCOLOR="#ffffff">
    <P> </P>
    <PRE>|]

Caveat: since the "|]" character sequence is used to terminate the quasiquotation, you can't use it inside the raw string literal. Use rQ if you want to embed that character sequence inside the raw string.

For more on raw strings, see e.g. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2053.html

For more on quasiquotation, see http://www.haskell.org/haskellwiki/Quasiquotation

throwRefineOtherException #

Arguments

:: Monad m 
=> TypeRep

The TypeRep of the Predicate. This can usually be given by using typeOf.

-> Doc Void

A Doc Void encoding a custom error message to be pretty-printed.

-> RefineT m a 

A handler for a RefineException.

throwRefineOtherException is useful for defining what behaviour validate should have in the event of a predicate failure.

catchRefine :: Monad m => RefineT m a -> (RefineException -> RefineT m a) -> RefineT m a #

A handler function to handle previous RefineExceptions and return to normal execution. A common idiom is:

 do { action1; action2; action3 } `catchRefine' handler

where the action functions can call throwRefine. Note that handler and the do-block must have the same return type.

throwRefine :: Monad m => RefineException -> RefineT m a #

One can use throwRefine inside of a monadic context to begin processing a RefineException.

runRefineM :: RefineM a -> Either RefineException a #

Run a monadic action of type RefineM a, yielding an Either RefineException a.

This is just defined as runIdentity . runRefineT.

refineM :: Either RefineException a -> RefineM a #

Constructs a computation in the RefineM monad. (The inverse of runRefineM).

mapRefineT :: (m (Either RefineException a) -> n (Either RefineException b)) -> RefineT m a -> RefineT n b #

Map the unwrapped computation using the given function.

runRefineT (mapRefineT f m) = f (runRefineT m)

runRefineT :: RefineT m a -> m (Either RefineException a) #

The inverse of RefineT.

rightOr :: Refined r x -> Refined (Or l r) x #

This function helps type inference. It is equivalent to the following:

instance Weaken r (Or l r)

leftOr :: Refined l x -> Refined (Or l r) x #

This function helps type inference. It is equivalent to the following:

instance Weaken l (Or l r)

andRight :: Refined (And l r) x -> Refined r x #

This function helps type inference. It is equivalent to the following:

instance Weaken (And l r) r

andLeft :: Refined (And l r) x -> Refined l x #

This function helps type inference. It is equivalent to the following:

instance Weaken (And l r) l

unrefine :: Refined p x -> x #

Extracts the refined value.

refineTH :: (Predicate p x, Lift x) => x -> Q (TExp (Refined p x)) #

Constructs a Refined value at compile-time using -XTemplateHaskell.

For example:

>>> $$(refineTH 23) :: Refined Positive Int
Refined 23

Here's an example of an invalid value:

>>> $$(refineTH 0) :: Refined Positive Int
<interactive>:6:4:
    Value is not greater than 0
    In the Template Haskell splice $$(refineTH 0)
    In the expression: $$(refineTH 0) :: Refined Positive Int
    In an equation for ‘it’:
        it = $$(refineTH 0) :: Refined Positive Int

If it's not evident, the example above indicates a compile-time failure, which means that the checking was done at compile-time, thus introducing a zero runtime overhead compared to a plain value construction.

unsafeRefine :: Predicate p x => x -> Refined p x #

Constructs a Refined value at run-time, calling error if the value does not satisfy the predicate.

WARNING: this function is not total!

refineError :: (Predicate p x, MonadError RefineException m) => x -> m (Refined p x) #

Constructs a Refined value at run-time, calling throwError if the value does not satisfy the predicate.

refineFail :: (Predicate p x, MonadFail m) => x -> m (Refined p x) #

Constructs a Refined value at run-time, calling fail if the value does not satisfy the predicate.

refineThrow :: (Predicate p x, MonadThrow m) => x -> m (Refined p x) #

Constructs a Refined value at run-time, calling throwM if the value does not satisfy the predicate.

refine :: Predicate p x => x -> Either RefineException (Refined p x) #

A smart constructor of a Refined value. Checks the input value at runtime.

data Refined p x #

A refinement type, which wraps a value of type x, ensuring that it satisfies a type-level predicate p.

The only ways that this library provides to construct a value of type Refined are with the 'refine-' family of functions, because the use of the newtype constructor gets around the checking of the predicate. This restriction on the user makes unrefine safe.

If you would really like to construct a Refined value without checking the predicate, use unsafeCoerce.

Instances
Foldable (Refined p) 
Instance details

Defined in Refined

Methods

fold :: Monoid m => Refined p m -> m #

foldMap :: Monoid m => (a -> m) -> Refined p a -> m #

foldr :: (a -> b -> b) -> b -> Refined p a -> b #

foldr' :: (a -> b -> b) -> b -> Refined p a -> b #

foldl :: (b -> a -> b) -> b -> Refined p a -> b #

foldl' :: (b -> a -> b) -> b -> Refined p a -> b #

foldr1 :: (a -> a -> a) -> Refined p a -> a #

foldl1 :: (a -> a -> a) -> Refined p a -> a #

toList :: Refined p a -> [a] #

null :: Refined p a -> Bool #

length :: Refined p a -> Int #

elem :: Eq a => a -> Refined p a -> Bool #

maximum :: Ord a => Refined p a -> a #

minimum :: Ord a => Refined p a -> a #

sum :: Num a => Refined p a -> a #

product :: Num a => Refined p a -> a #

Eq x => Eq (Refined p x) 
Instance details

Defined in Refined

Methods

(==) :: Refined p x -> Refined p x -> Bool #

(/=) :: Refined p x -> Refined p x -> Bool #

Ord x => Ord (Refined p x) 
Instance details

Defined in Refined

Methods

compare :: Refined p x -> Refined p x -> Ordering #

(<) :: Refined p x -> Refined p x -> Bool #

(<=) :: Refined p x -> Refined p x -> Bool #

(>) :: Refined p x -> Refined p x -> Bool #

(>=) :: Refined p x -> Refined p x -> Bool #

max :: Refined p x -> Refined p x -> Refined p x #

min :: Refined p x -> Refined p x -> Refined p x #

(Read x, Predicate p x) => Read (Refined p x) 
Instance details

Defined in Refined

Show x => Show (Refined p x) 
Instance details

Defined in Refined

Methods

showsPrec :: Int -> Refined p x -> ShowS #

show :: Refined p x -> String #

showList :: [Refined p x] -> ShowS #

Lift x => Lift (Refined p x) 
Instance details

Defined in Refined

Methods

lift :: Refined p x -> Q Exp #

ToJSON α => ToJSON (Refined ρ α) # 
Instance details

Defined in Magicbane.Validation

Methods

toJSON :: Refined ρ α -> Value #

toEncoding :: Refined ρ α -> Encoding #

toJSONList :: [Refined ρ α] -> Value #

toEncodingList :: [Refined ρ α] -> Encoding #

(FromJSON α, Predicate ρ α) => FromJSON (Refined ρ α) # 
Instance details

Defined in Magicbane.Validation

Methods

parseJSON :: Value -> Parser (Refined ρ α) #

parseJSONList :: Value -> Parser [Refined ρ α] #

class Typeable p => Predicate p x where #

A typeclass which defines a runtime interpretation of a type-level predicate p for type x.

Minimal complete definition

validate

Methods

validate :: Monad m => p -> x -> RefineT m () #

Check the value x according to the predicate p, producing an error string if the value does not satisfy.

Instances
(IsList t, Ord (Item t)) => Predicate Ascending t 
Instance details

Defined in Refined

Methods

validate :: Monad m => Ascending -> t -> RefineT m () #

(IsList t, Ord (Item t)) => Predicate Descending t 
Instance details

Defined in Refined

Methods

validate :: Monad m => Descending -> t -> RefineT m () #

(Predicate p x, Typeable p) => Predicate (Not p) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => Not p -> x -> RefineT m () #

(Ord x, Num x, KnownNat n) => Predicate (LessThan n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => LessThan n -> x -> RefineT m () #

(Ord x, Num x, KnownNat n) => Predicate (GreaterThan n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => GreaterThan n -> x -> RefineT m () #

(Ord x, Num x, KnownNat n) => Predicate (From n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => From n -> x -> RefineT m () #

(Ord x, Num x, KnownNat n) => Predicate (To n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => To n -> x -> RefineT m () #

(Eq x, Num x, KnownNat n) => Predicate (EqualTo n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => EqualTo n -> x -> RefineT m () #

(Eq x, Num x, KnownNat n) => Predicate (NotEqualTo n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => NotEqualTo n -> x -> RefineT m () #

(Foldable t, KnownNat n) => Predicate (SizeLessThan n) (t a) 
Instance details

Defined in Refined

Methods

validate :: Monad m => SizeLessThan n -> t a -> RefineT m () #

(Foldable t, KnownNat n) => Predicate (SizeGreaterThan n) (t a) 
Instance details

Defined in Refined

Methods

validate :: Monad m => SizeGreaterThan n -> t a -> RefineT m () #

(Foldable t, KnownNat n) => Predicate (SizeEqualTo n) (t a) 
Instance details

Defined in Refined

Methods

validate :: Monad m => SizeEqualTo n -> t a -> RefineT m () #

(Predicate l x, Predicate r x, Typeable l, Typeable r) => Predicate (And l r) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => And l r -> x -> RefineT m () #

(Predicate l x, Predicate r x, Typeable l, Typeable r) => Predicate (Or l r) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => Or l r -> x -> RefineT m () #

(Ord x, Num x, KnownNat mn, KnownNat mx, mn <= mx) => Predicate (FromTo mn mx) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => FromTo mn mx -> x -> RefineT m () #

data Not p #

The negation of a predicate.

Instances
(Predicate p x, Typeable p) => Predicate (Not p) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => Not p -> x -> RefineT m () #

data And l r #

The conjunction of two predicates.

Instances
(Predicate l x, Predicate r x, Typeable l, Typeable r) => Predicate (And l r) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => And l r -> x -> RefineT m () #

type (&&) = And infixr 3 #

The conjunction of two predicates.

data Or l r #

The disjunction of two predicates.

Instances
(Predicate l x, Predicate r x, Typeable l, Typeable r) => Predicate (Or l r) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => Or l r -> x -> RefineT m () #

type (||) = Or infixr 2 #

The disjunction of two predicates.

data SizeLessThan (n :: Nat) #

A Predicate ensuring that the Foldable has a length which is less than the specified type-level number.

Instances
(Foldable t, KnownNat n) => Predicate (SizeLessThan n) (t a) 
Instance details

Defined in Refined

Methods

validate :: Monad m => SizeLessThan n -> t a -> RefineT m () #

data SizeGreaterThan (n :: Nat) #

A Predicate ensuring that the Foldable has a length which is greater than the specified type-level number.

Instances
(Foldable t, KnownNat n) => Predicate (SizeGreaterThan n) (t a) 
Instance details

Defined in Refined

Methods

validate :: Monad m => SizeGreaterThan n -> t a -> RefineT m () #

data SizeEqualTo (n :: Nat) #

A Predicate ensuring that the Foldable has a length which is equal to the specified type-level number.

Instances
(Foldable t, KnownNat n) => Predicate (SizeEqualTo n) (t a) 
Instance details

Defined in Refined

Methods

validate :: Monad m => SizeEqualTo n -> t a -> RefineT m () #

data Ascending #

A Predicate ensuring that the IsList contains elements in a strictly ascending order.

Instances
(IsList t, Ord (Item t)) => Predicate Ascending t 
Instance details

Defined in Refined

Methods

validate :: Monad m => Ascending -> t -> RefineT m () #

data Descending #

A Predicate ensuring that the IsList contains elements in a strictly descending order.

Instances
(IsList t, Ord (Item t)) => Predicate Descending t 
Instance details

Defined in Refined

Methods

validate :: Monad m => Descending -> t -> RefineT m () #

data LessThan (n :: Nat) #

A Predicate ensuring that the value is less than the specified type-level number.

Instances
(Ord x, Num x, KnownNat n) => Predicate (LessThan n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => LessThan n -> x -> RefineT m () #

n <= m => Weaken (LessThan n) (To m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (LessThan n) x -> Refined (To m) x #

n <= m => Weaken (LessThan n) (LessThan m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (LessThan n) x -> Refined (LessThan m) x #

data GreaterThan (n :: Nat) #

A Predicate ensuring that the value is greater than the specified type-level number.

Instances
(Ord x, Num x, KnownNat n) => Predicate (GreaterThan n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => GreaterThan n -> x -> RefineT m () #

m <= n => Weaken (GreaterThan n) (GreaterThan m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (GreaterThan n) x -> Refined (GreaterThan m) x #

m <= n => Weaken (GreaterThan n) (From m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (GreaterThan n) x -> Refined (From m) x #

data From (n :: Nat) #

A Predicate ensuring that the value is greater than or equal to the specified type-level number.

Instances
(Ord x, Num x, KnownNat n) => Predicate (From n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => From n -> x -> RefineT m () #

m <= n => Weaken (GreaterThan n) (From m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (GreaterThan n) x -> Refined (From m) x #

m <= n => Weaken (From n) (From m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (From n) x -> Refined (From m) x #

p <= n => Weaken (FromTo n m) (From p) 
Instance details

Defined in Refined

Methods

weaken :: Refined (FromTo n m) x -> Refined (From p) x #

data To (n :: Nat) #

A Predicate ensuring that the value is less than or equal to the specified type-level number.

Instances
(Ord x, Num x, KnownNat n) => Predicate (To n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => To n -> x -> RefineT m () #

n <= m => Weaken (LessThan n) (To m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (LessThan n) x -> Refined (To m) x #

n <= m => Weaken (To n) (To m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (To n) x -> Refined (To m) x #

m <= q => Weaken (FromTo n m) (To q) 
Instance details

Defined in Refined

Methods

weaken :: Refined (FromTo n m) x -> Refined (To q) x #

data FromTo (mn :: Nat) (mx :: Nat) #

A Predicate ensuring that the value is within an inclusive range.

Instances
(Ord x, Num x, KnownNat mn, KnownNat mx, mn <= mx) => Predicate (FromTo mn mx) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => FromTo mn mx -> x -> RefineT m () #

m <= q => Weaken (FromTo n m) (To q) 
Instance details

Defined in Refined

Methods

weaken :: Refined (FromTo n m) x -> Refined (To q) x #

p <= n => Weaken (FromTo n m) (From p) 
Instance details

Defined in Refined

Methods

weaken :: Refined (FromTo n m) x -> Refined (From p) x #

(p <= n, m <= q) => Weaken (FromTo n m) (FromTo p q) 
Instance details

Defined in Refined

Methods

weaken :: Refined (FromTo n m) x -> Refined (FromTo p q) x #

data EqualTo (n :: Nat) #

A Predicate ensuring that the value is equal to the specified type-level number n.

Instances
(Eq x, Num x, KnownNat n) => Predicate (EqualTo n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => EqualTo n -> x -> RefineT m () #

data NotEqualTo (n :: Nat) #

A Predicate ensuring that the value is not equal to the specified type-level number n.

Instances
(Eq x, Num x, KnownNat n) => Predicate (NotEqualTo n) x 
Instance details

Defined in Refined

Methods

validate :: Monad m => NotEqualTo n -> x -> RefineT m () #

type Positive = GreaterThan 0 #

A Predicate ensuring that the value is greater than zero.

type NonPositive = To 0 #

A Predicate ensuring that the value is less than or equal to zero.

type Negative = LessThan 0 #

A Predicate ensuring that the value is less than zero.

type NonNegative = From 0 #

A Predicate ensuring that the value is greater than or equal to zero.

type ZeroToOne = FromTo 0 1 #

An inclusive range of values from zero to one.

type NonZero = NotEqualTo 0 #

A Predicate ensuring that the value is not equal to zero.

type NonEmpty = SizeGreaterThan 0 #

A Predicate ensuring that the Foldable is non-empty.

class Weaken from to where #

A typeclass containing "safe" conversions between refined predicates where the target is weaker than the source: that is, all values that satisfy the first predicate will be guarunteed to satisy the second.

Take care: writing an instance declaration for your custom predicates is the same as an assertion that weaken is safe to use:

instance Weaken Pred1 Pred2

For most of the instances, explicit type annotations for the result value's type might be required.

Methods

weaken :: Refined from x -> Refined to x #

Instances
n <= m => Weaken (LessThan n) (To m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (LessThan n) x -> Refined (To m) x #

n <= m => Weaken (LessThan n) (LessThan m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (LessThan n) x -> Refined (LessThan m) x #

m <= n => Weaken (GreaterThan n) (GreaterThan m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (GreaterThan n) x -> Refined (GreaterThan m) x #

m <= n => Weaken (GreaterThan n) (From m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (GreaterThan n) x -> Refined (From m) x #

m <= n => Weaken (From n) (From m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (From n) x -> Refined (From m) x #

n <= m => Weaken (To n) (To m) 
Instance details

Defined in Refined

Methods

weaken :: Refined (To n) x -> Refined (To m) x #

m <= q => Weaken (FromTo n m) (To q) 
Instance details

Defined in Refined

Methods

weaken :: Refined (FromTo n m) x -> Refined (To q) x #

p <= n => Weaken (FromTo n m) (From p) 
Instance details

Defined in Refined

Methods

weaken :: Refined (FromTo n m) x -> Refined (From p) x #

(p <= n, m <= q) => Weaken (FromTo n m) (FromTo p q) 
Instance details

Defined in Refined

Methods

weaken :: Refined (FromTo n m) x -> Refined (FromTo p q) x #

data RefineException #

An exception encoding the way in which a Predicate failed.

Constructors

RefineNotException !TypeRep

A RefineException for failures involving the Not predicate.

RefineAndException !TypeRep !(These RefineException RefineException)

A RefineException for failures involving the And predicate.

RefineOrException !TypeRep !RefineException !RefineException

A RefineException for failures involving the Or predicate.

RefineOtherException !TypeRep !(Doc Void)

A RefineException for failures involving all other predicates.

Instances
Show RefineException 
Instance details

Defined in Refined

Generic RefineException 
Instance details

Defined in Refined

Associated Types

type Rep RefineException :: * -> * #

Exception RefineException

Encode a RefineException for use with Control.Exception.

Instance details

Defined in Refined

Pretty RefineException

Pretty-print a RefineException.

Instance details

Defined in Refined

Monad m => MonadError RefineException (RefineT m) 
Instance details

Defined in Refined

type Rep RefineException 
Instance details

Defined in Refined

type Rep RefineException = D1 (MetaData "RefineException" "Refined" "refined-0.2.3.0-8E6FQzqJKx98HoFZMJznOu" False) ((C1 (MetaCons "RefineNotException" PrefixI True) (S1 (MetaSel (Just "_RefineException_typeRep") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 TypeRep)) :+: C1 (MetaCons "RefineAndException" PrefixI True) (S1 (MetaSel (Just "_RefineException_typeRep") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 TypeRep) :*: S1 (MetaSel (Just "_RefineException_andChild") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (These RefineException RefineException)))) :+: (C1 (MetaCons "RefineOrException" PrefixI True) (S1 (MetaSel (Just "_RefineException_typeRep") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 TypeRep) :*: (S1 (MetaSel (Just "_RefineException_orLChild") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 RefineException) :*: S1 (MetaSel (Just "_RefineException_orRChild") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 RefineException))) :+: C1 (MetaCons "RefineOtherException" PrefixI True) (S1 (MetaSel (Just "_RefineException_typeRep") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 TypeRep) :*: S1 (MetaSel (Just "_RefineException_message") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Doc Void)))))

data RefineT (m :: * -> *) a #

A monad transformer that adds RefineExceptions to other monads.

The pure and return functions yield computations that produce the given value, while >>= sequences two subcomputations, exiting on the first RefineException.

Instances
MonadTrans RefineT 
Instance details

Defined in Refined

Methods

lift :: Monad m => m a -> RefineT m a #

Monad m => MonadError RefineException (RefineT m) 
Instance details

Defined in Refined

Monad m => Monad (RefineT m) 
Instance details

Defined in Refined

Methods

(>>=) :: RefineT m a -> (a -> RefineT m b) -> RefineT m b #

(>>) :: RefineT m a -> RefineT m b -> RefineT m b #

return :: a -> RefineT m a #

fail :: String -> RefineT m a #

Functor m => Functor (RefineT m) 
Instance details

Defined in Refined

Methods

fmap :: (a -> b) -> RefineT m a -> RefineT m b #

(<$) :: a -> RefineT m b -> RefineT m a #

MonadFix m => MonadFix (RefineT m) 
Instance details

Defined in Refined

Methods

mfix :: (a -> RefineT m a) -> RefineT m a #

Monad m => Applicative (RefineT m) 
Instance details

Defined in Refined

Methods

pure :: a -> RefineT m a #

(<*>) :: RefineT m (a -> b) -> RefineT m a -> RefineT m b #

liftA2 :: (a -> b -> c) -> RefineT m a -> RefineT m b -> RefineT m c #

(*>) :: RefineT m a -> RefineT m b -> RefineT m b #

(<*) :: RefineT m a -> RefineT m b -> RefineT m a #

Generic1 (RefineT m :: * -> *) 
Instance details

Defined in Refined

Associated Types

type Rep1 (RefineT m) :: k -> * #

Methods

from1 :: RefineT m a -> Rep1 (RefineT m) a #

to1 :: Rep1 (RefineT m) a -> RefineT m a #

Generic (RefineT m a) 
Instance details

Defined in Refined

Associated Types

type Rep (RefineT m a) :: * -> * #

Methods

from :: RefineT m a -> Rep (RefineT m a) x #

to :: Rep (RefineT m a) x -> RefineT m a #

type Rep1 (RefineT m :: * -> *) 
Instance details

Defined in Refined

type Rep1 (RefineT m :: * -> *) = D1 (MetaData "RefineT" "Refined" "refined-0.2.3.0-8E6FQzqJKx98HoFZMJznOu" True) (C1 (MetaCons "RefineT" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 (ExceptT RefineException m))))
type Rep (RefineT m a) 
Instance details

Defined in Refined

type Rep (RefineT m a) = D1 (MetaData "RefineT" "Refined" "refined-0.2.3.0-8E6FQzqJKx98HoFZMJznOu" True) (C1 (MetaCons "RefineT" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ExceptT RefineException m a))))

type RefineM a = RefineT Identity a #

RefineM a is equivalent to RefineT Identity a for any type a.

newChan :: MonadIO m => m (Chan a) #

Lifted newChan.

Since: unliftio-0.1.0.0

writeChan :: MonadIO m => Chan a -> a -> m () #

Lifted writeChan.

Since: unliftio-0.1.0.0

readChan :: MonadIO m => Chan a -> m a #

Lifted readChan.

Since: unliftio-0.1.0.0

dupChan :: MonadIO m => Chan a -> m (Chan a) #

Lifted dupChan.

Since: unliftio-0.1.0.0

getChanContents :: MonadIO m => Chan a -> m [a] #

Lifted getChanContents.

Since: unliftio-0.1.0.0

writeList2Chan :: MonadIO m => Chan a -> [a] -> m () #

Lifted writeList2Chan.

Since: unliftio-0.1.0.0

data StringException #

Exception type thrown by throwString.

Note that the second field of the data constructor depends on GHC/base version. For base 4.9 and GHC 8.0 and later, the second field is a call stack. Previous versions of GHC and base do not support call stacks, and the field is simply unit (provided to make pattern matching across GHC versions easier).

Since: unliftio-0.1.0.0

data AsyncExceptionWrapper where #

Wrap up a synchronous exception to be treated as an asynchronous exception.

This is intended to be created via toAsyncException.

Since: unliftio-0.1.0.0

data SyncExceptionWrapper where #

Wrap up an asynchronous exception to be treated as a synchronous exception.

This is intended to be created via toSyncException.

Since: unliftio-0.1.0.0

catch :: (MonadUnliftIO m, Exception e) => m a -> (e -> m a) -> m a #

Unlifted catch, but will not catch asynchronous exceptions.

Since: unliftio-0.1.0.0

catchIO :: MonadUnliftIO m => m a -> (IOException -> m a) -> m a #

catch specialized to only catching IOExceptions.

Since: unliftio-0.1.0.0

catchAny :: MonadUnliftIO m => m a -> (SomeException -> m a) -> m a #

catch specialized to catch all synchronous exception.

Since: unliftio-0.1.0.0

catchDeep :: (MonadUnliftIO m, Exception e, NFData a) => m a -> (e -> m a) -> m a #

Same as catch, but fully force evaluation of the result value to find all impure exceptions.

Since: unliftio-0.1.0.0

catchAnyDeep :: (NFData a, MonadUnliftIO m) => m a -> (SomeException -> m a) -> m a #

catchDeep specialized to catch all synchronous exception.

Since: unliftio-0.1.0.0

catchJust :: (MonadUnliftIO m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a #

catchJust is like catch but it takes an extra argument which is an exception predicate, a function which selects which type of exceptions we're interested in.

Since: unliftio-0.1.0.0

handle :: (MonadUnliftIO m, Exception e) => (e -> m a) -> m a -> m a #

Flipped version of catch.

Since: unliftio-0.1.0.0

handleIO :: MonadUnliftIO m => (IOException -> m a) -> m a -> m a #

handle specialized to only catching IOExceptions.

Since: unliftio-0.1.0.0

handleAny :: MonadUnliftIO m => (SomeException -> m a) -> m a -> m a #

Flipped version of catchAny.

Since: unliftio-0.1.0.0

handleDeep :: (MonadUnliftIO m, Exception e, NFData a) => (e -> m a) -> m a -> m a #

Flipped version of catchDeep.

Since: unliftio-0.1.0.0

handleAnyDeep :: (MonadUnliftIO m, NFData a) => (SomeException -> m a) -> m a -> m a #

Flipped version of catchAnyDeep.

Since: unliftio-0.1.0.0

handleJust :: (MonadUnliftIO m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a #

Flipped catchJust.

Since: unliftio-0.1.0.0

try :: (MonadUnliftIO m, Exception e) => m a -> m (Either e a) #

Unlifted try, but will not catch asynchronous exceptions.

Since: unliftio-0.1.0.0

tryIO :: MonadUnliftIO m => m a -> m (Either IOException a) #

try specialized to only catching IOExceptions.

Since: unliftio-0.1.0.0

tryAny :: MonadUnliftIO m => m a -> m (Either SomeException a) #

try specialized to catch all synchronous exceptions.

Since: unliftio-0.1.0.0

tryDeep :: (MonadUnliftIO m, Exception e, NFData a) => m a -> m (Either e a) #

Same as try, but fully force evaluation of the result value to find all impure exceptions.

Since: unliftio-0.1.0.0

tryAnyDeep :: (MonadUnliftIO m, NFData a) => m a -> m (Either SomeException a) #

tryDeep specialized to catch all synchronous exceptions.

Since: unliftio-0.1.0.0

tryJust :: (MonadUnliftIO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a) #

A variant of try that takes an exception predicate to select which exceptions are caught.

Since: unliftio-0.1.0.0

pureTry :: a -> Either SomeException a #

Evaluate the value to WHNF and catch any synchronous exceptions.

The expression may still have bottom values within it; you may instead want to use pureTryDeep.

Since: unliftio-0.2.2.0

pureTryDeep :: NFData a => a -> Either SomeException a #

Evaluate the value to NF and catch any synchronous exceptions.

Since: unliftio-0.2.2.0

catches :: MonadUnliftIO m => m a -> [Handler m a] -> m a #

Same as upstream catches, but will not catch asynchronous exceptions.

Since: unliftio-0.1.0.0

catchesDeep :: (MonadUnliftIO m, NFData a) => m a -> [Handler m a] -> m a #

Same as catches, but fully force evaluation of the result value to find all impure exceptions.

Since: unliftio-0.1.0.0

evaluate :: MonadIO m => a -> m a #

Lifted version of evaluate.

Since: unliftio-0.1.0.0

evaluateDeep :: (MonadIO m, NFData a) => a -> m a #

Deeply evaluate a value using evaluate and NFData.

Since: unliftio-0.1.0.0

bracket :: MonadUnliftIO m => m a -> (a -> m b) -> (a -> m c) -> m c #

Async safe version of bracket.

Since: unliftio-0.1.0.0

bracket_ :: MonadUnliftIO m => m a -> m b -> m c -> m c #

Async safe version of bracket_.

Since: unliftio-0.1.0.0

bracketOnError :: MonadUnliftIO m => m a -> (a -> m b) -> (a -> m c) -> m c #

Async safe version of bracketOnError.

Since: unliftio-0.1.0.0

bracketOnError_ :: MonadUnliftIO m => m a -> m b -> m c -> m c #

A variant of bracketOnError where the return value from the first computation is not required.

Since: unliftio-0.1.0.0

finally :: MonadUnliftIO m => m a -> m b -> m a #

Async safe version of finally.

Since: unliftio-0.1.0.0

withException :: (MonadUnliftIO m, Exception e) => m a -> (e -> m b) -> m a #

Like onException, but provides the handler the thrown exception.

Since: unliftio-0.1.0.0

onException :: MonadUnliftIO m => m a -> m b -> m a #

Async safe version of onException.

Since: unliftio-0.1.0.0

throwIO :: (MonadIO m, Exception e) => e -> m a #

Synchronously throw the given exception.

Since: unliftio-0.1.0.0

toSyncException :: Exception e => e -> SomeException #

Convert an exception into a synchronous exception.

For synchronous exceptions, this is the same as toException. For asynchronous exceptions, this will wrap up the exception with SyncExceptionWrapper.

Since: unliftio-0.1.0.0

toAsyncException :: Exception e => e -> SomeException #

Convert an exception into an asynchronous exception.

For asynchronous exceptions, this is the same as toException. For synchronous exceptions, this will wrap up the exception with AsyncExceptionWrapper.

Since: unliftio-0.1.0.0

isSyncException :: Exception e => e -> Bool #

Check if the given exception is synchronous.

Since: unliftio-0.1.0.0

isAsyncException :: Exception e => e -> Bool #

Check if the given exception is asynchronous.

Since: unliftio-0.1.0.0

mask :: MonadUnliftIO m => ((forall a. m a -> m a) -> m b) -> m b #

Unlifted version of mask.

Since: unliftio-0.1.0.0

uninterruptibleMask :: MonadUnliftIO m => ((forall a. m a -> m a) -> m b) -> m b #

Unlifted version of uninterruptibleMask.

Since: unliftio-0.1.0.0

mask_ :: MonadUnliftIO m => m a -> m a #

Unlifted version of mask_.

Since: unliftio-0.1.0.0

uninterruptibleMask_ :: MonadUnliftIO m => m a -> m a #

Unlifted version of uninterruptibleMask_.

Since: unliftio-0.1.0.0

throwString :: (MonadIO m, HasCallStack) => String -> m a #

A convenience function for throwing a user error. This is useful for cases where it would be too high a burden to define your own exception type.

This throws an exception of type StringException. When GHC supports it (base 4.9 and GHC 8.0 and onward), it includes a call stack.

Since: unliftio-0.1.0.0

stringException :: HasCallStack -> String -> StringException #

Smart constructor for a StringException that deals with the call stack.

Since: unliftio-0.1.0.0

throwTo :: (Exception e, MonadIO m) => ThreadId -> e -> m () #

Throw an asynchronous exception to another thread.

Synchronously typed exceptions will be wrapped into an AsyncExceptionWrapper, see https://github.com/fpco/safe-exceptions#determining-sync-vs-async.

It's usually a better idea to use the UnliftIO.Async module, see https://github.com/fpco/safe-exceptions#quickstart.

Since: unliftio-0.1.0.0

impureThrow :: Exception e => e -> a #

Generate a pure value which, when forced, will synchronously throw the given exception.

Generally it's better to avoid using this function and instead use throwIO, see https://github.com/fpco/safe-exceptions#quickstart.

Since: unliftio-0.1.0.0

fromEither :: (Exception e, MonadIO m) => Either e a -> m a #

Unwrap an Either value, throwing its Left value as a runtime exception via throwIO if present.

Since: unliftio-0.1.0.0

fromEitherIO :: (Exception e, MonadIO m) => IO (Either e a) -> m a #

Same as fromEither, but works on an IO-wrapped Either.

Since: unliftio-0.1.0.0

fromEitherM :: (Exception e, MonadIO m) => m (Either e a) -> m a #

Same as fromEither, but works on an m-wrapped Either.

Since: unliftio-0.1.0.0

newEmptyMVar :: MonadIO m => m (MVar a) #

Lifted newEmptyMVar.

Since: unliftio-0.1.0.0

newMVar :: MonadIO m => a -> m (MVar a) #

Lifted newMVar.

Since: unliftio-0.1.0.0

takeMVar :: MonadIO m => MVar a -> m a #

Lifted takeMVar.

Since: unliftio-0.1.0.0

putMVar :: MonadIO m => MVar a -> a -> m () #

Lifted putMVar.

Since: unliftio-0.1.0.0

readMVar :: MonadIO m => MVar a -> m a #

Lifted readMVar.

Since: unliftio-0.1.0.0

swapMVar :: MonadIO m => MVar a -> a -> m a #

Lifted swapMVar.

Since: unliftio-0.1.0.0

tryTakeMVar :: MonadIO m => MVar a -> m (Maybe a) #

Lifted tryTakeMVar.

Since: unliftio-0.1.0.0

tryPutMVar :: MonadIO m => MVar a -> a -> m Bool #

Lifted tryPutMVar.

Since: unliftio-0.1.0.0

isEmptyMVar :: MonadIO m => MVar a -> m Bool #

Lifted isEmptyMVar.

Since: unliftio-0.1.0.0

tryReadMVar :: MonadIO m => MVar a -> m (Maybe a) #

Lifted tryReadMVar.

Since: unliftio-0.1.0.0

withMVar :: MonadUnliftIO m => MVar a -> (a -> m b) -> m b #

Unlifted withMVar.

Since: unliftio-0.1.0.0

withMVarMasked :: MonadUnliftIO m => MVar a -> (a -> m b) -> m b #

Unlifted withMVarMasked.

Since: unliftio-0.1.0.0

modifyMVar_ :: MonadUnliftIO m => MVar a -> (a -> m a) -> m () #

Unlifted modifyMVar_.

Since: unliftio-0.1.0.0

modifyMVar :: MonadUnliftIO m => MVar a -> (a -> m (a, b)) -> m b #

Unlifted modifyMVar.

Since: unliftio-0.1.0.0

modifyMVarMasked_ :: MonadUnliftIO m => MVar a -> (a -> m a) -> m () #

Unlifted modifyMVarMasked_.

Since: unliftio-0.1.0.0

modifyMVarMasked :: MonadUnliftIO m => MVar a -> (a -> m (a, b)) -> m b #

Unlifted modifyMVarMasked.

Since: unliftio-0.1.0.0

mkWeakMVar :: MonadUnliftIO m => MVar a -> m () -> m (Weak (MVar a)) #

Unlifted mkWeakMVar.

Since: unliftio-0.1.0.0

data RIO env a #

The Reader+IO monad. This is different from a ReaderT because:

  • It's not a transformer, it hardcodes IO for simpler usage and error messages.
  • Instances of typeclasses like MonadLogger are implemented using classes defined on the environment, instead of using an underlying monad.
Instances
MonadReader env (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

ask :: RIO env env #

local :: (env -> env) -> RIO env a -> RIO env a #

reader :: (env -> a) -> RIO env a #

HasStateRef s env => MonadState s (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

get :: RIO env s #

put :: s -> RIO env () #

state :: (s -> (a, s)) -> RIO env a #

(Monoid w, HasWriteRef w env) => MonadWriter w (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

writer :: (a, w) -> RIO env a #

tell :: w -> RIO env () #

listen :: RIO env a -> RIO env (a, w) #

pass :: RIO env (a, w -> w) -> RIO env a #

Monad (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

(>>=) :: RIO env a -> (a -> RIO env b) -> RIO env b #

(>>) :: RIO env a -> RIO env b -> RIO env b #

return :: a -> RIO env a #

fail :: String -> RIO env a #

Functor (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

fmap :: (a -> b) -> RIO env a -> RIO env b #

(<$) :: a -> RIO env b -> RIO env a #

Applicative (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

pure :: a -> RIO env a #

(<*>) :: RIO env (a -> b) -> RIO env a -> RIO env b #

liftA2 :: (a -> b -> c) -> RIO env a -> RIO env b -> RIO env c #

(*>) :: RIO env a -> RIO env b -> RIO env b #

(<*) :: RIO env a -> RIO env b -> RIO env a #

MonadIO (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

liftIO :: IO a -> RIO env a #

MonadUnliftIO (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

askUnliftIO :: RIO env (UnliftIO (RIO env)) #

withRunInIO :: ((forall a. RIO env a -> IO a) -> IO b) -> RIO env b #

PrimMonad (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Associated Types

type PrimState (RIO env) :: * #

Methods

primitive :: (State# (PrimState (RIO env)) -> (#State# (PrimState (RIO env)), a#)) -> RIO env a #

MonadThrow (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

throwM :: Exception e => e -> RIO env a #

type PrimState (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

type PrimState (RIO env) = PrimState IO
type StM (RIO env) a 
Instance details

Defined in RIO.Orphans

type StM (RIO env) a = a

myThreadId :: MonadIO m => m ThreadId #

Lifted version of myThreadId.

Since: unliftio-0.1.1.0

threadDelay :: MonadIO m => Int -> m () #

Lifted version of threadDelay.

Since: unliftio-0.1.1.0

threadWaitRead :: MonadIO m => Fd -> m () #

Lifted version of threadWaitRead.

Since: unliftio-0.1.1.0

threadWaitWrite :: MonadIO m => Fd -> m () #

Lifted version of threadWaitWrite.

Since: unliftio-0.1.1.0

isCurrentThreadBound :: MonadIO m => m Bool #

Lifted version of isCurrentThreadBound.

Since: unliftio-0.1.1.0

allFieldLinks' :: (HasLink (ToServantApi routes), GenericServant routes (AsLink a), ToServant routes (AsLink a) ~ MkLink (ToServantApi routes) a) => (Link -> a) -> routes (AsLink a) #

More general version of allFieldLinks.

Since: servant-0.14.1

allFieldLinks :: (HasLink (ToServantApi routes), GenericServant routes (AsLink Link), ToServant routes (AsLink Link) ~ MkLink (ToServantApi routes) Link) => routes (AsLink Link) #

Get all links as a record.

Since: servant-0.14.1

fieldLink' :: (IsElem endpoint (ToServantApi routes), HasLink endpoint, GenericServant routes AsApi) => (Link -> a) -> (routes AsApi -> endpoint) -> MkLink endpoint a #

More general version of fieldLink

Since: servant-0.14.1

fieldLink :: (IsElem endpoint (ToServantApi routes), HasLink endpoint, GenericServant routes AsApi) => (routes AsApi -> endpoint) -> MkLink endpoint Link #

Given an API record field, create a link for that route. Only the field's type is used.

data Record route = Record
    { _get :: route :- Capture "id" Int :> Get '[JSON] String
    , _put :: route :- ReqBody '[JSON] Int :> Put '[JSON] Bool
    }
  deriving (Generic)

getLink :: Int -> Link
getLink = fieldLink _get

Since: servant-0.14.1

allLinks' :: HasLink api => (Link -> a) -> Proxy api -> MkLink api a #

More general allLinks. See safeLink'.

allLinks :: HasLink api => Proxy api -> MkLink api Link #

Create all links in an API.

Note that the api type must be restricted to the endpoints that have valid links to them.

>>> type API = "foo" :> Capture "name" Text :> Get '[JSON] Text :<|> "bar" :> Capture "name" Int :> Get '[JSON] Double
>>> let fooLink :<|> barLink = allLinks (Proxy :: Proxy API)
>>> :t fooLink
fooLink :: Text -> Link
>>> :t barLink
barLink :: Int -> Link

Note: nested APIs don't work well with this approach

>>> :kind! MkLink (Capture "nest" Char :> (Capture "x" Int :> Get '[JSON] Int :<|> Capture "y" Double :> Get '[JSON] Double)) Link
MkLink (Capture "nest" Char :> (Capture "x" Int :> Get '[JSON] Int :<|> Capture "y" Double :> Get '[JSON] Double)) Link :: *
= Char -> (Int -> Link) :<|> (Double -> Link)

safeLink' #

Arguments

:: (IsElem endpoint api, HasLink endpoint) 
=> (Link -> a) 
-> Proxy api

The whole API that this endpoint is a part of

-> Proxy endpoint

The API endpoint you would like to point to

-> MkLink endpoint a 

More general safeLink.

safeLink #

Arguments

:: (IsElem endpoint api, HasLink endpoint) 
=> Proxy api

The whole API that this endpoint is a part of

-> Proxy endpoint

The API endpoint you would like to point to

-> MkLink endpoint Link 

Create a valid (by construction) relative URI with query params.

This function will only typecheck if endpoint is part of the API api

linkURI' :: LinkArrayElementStyle -> Link -> URI #

Configurable linkURI.

>>> type API = "sum" :> QueryParams "x" Int :> Get '[JSON] Int
>>> linkURI' LinkArrayElementBracket $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
sum?x[]=1&x[]=2&x[]=3
>>> linkURI' LinkArrayElementPlain $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
sum?x=1&x=2&x=3

linkURI :: Link -> URI #

Transform Link into URI.

>>> type API = "something" :> Get '[JSON] Int
>>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API)
something
>>> type API = "sum" :> QueryParams "x" Int :> Get '[JSON] Int
>>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
sum?x[]=1&x[]=2&x[]=3
>>> type API = "foo/bar" :> Get '[JSON] Int
>>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API)
foo%2Fbar
>>> type SomeRoute = "abc" :> Capture "email" String :> Put '[JSON] ()
>>> let someRoute = Proxy :: Proxy SomeRoute
>>> safeLink someRoute someRoute "test@example.com"
Link {_segments = ["abc","test%40example.com"], _queryParams = []}
>>> linkURI $ safeLink someRoute someRoute "test@example.com"
abc/test%40example.com

data Link #

A safe link datatype. The only way of constructing a Link is using safeLink, which means any Link is guaranteed to be part of the mentioned API.

data Param #

Query parameter.

Instances
Show Param 
Instance details

Defined in Servant.Links

Methods

showsPrec :: Int -> Param -> ShowS #

show :: Param -> String #

showList :: [Param] -> ShowS #

data LinkArrayElementStyle #

How to encode array query elements.

Constructors

LinkArrayElementBracket
foo[]=1&foo[]=2
LinkArrayElementPlain
foo=1&foo=2
Instances
Bounded LinkArrayElementStyle 
Instance details

Defined in Servant.Links

Enum LinkArrayElementStyle 
Instance details

Defined in Servant.Links

Eq LinkArrayElementStyle 
Instance details

Defined in Servant.Links

Ord LinkArrayElementStyle 
Instance details

Defined in Servant.Links

Show LinkArrayElementStyle 
Instance details

Defined in Servant.Links

data AsLink a #

A type that specifies that an API record contains a set of links.

Since: servant-0.14.1

class HasLink (endpoint :: k) where #

Construct a toLink for an endpoint.

Minimal complete definition

toLink

Associated Types

type MkLink (endpoint :: k) a :: * #

Methods

toLink #

Arguments

:: (Link -> a) 
-> Proxy endpoint

The API endpoint you would like to point to

-> Link 
-> MkLink endpoint a 

data WithNamedContext (name :: Symbol) (subContext :: [*]) subApi #

WithNamedContext names a specific tagged context to use for the combinators in the API. (See also in servant-server, Servant.Server.Context.) For example:

type UseNamedContextAPI = WithNamedContext "myContext" '[String] (
    ReqBody '[JSON] Int :> Get '[JSON] Int)

Both the ReqBody and Get combinators will use the WithNamedContext with type tag "myContext" as their context.

Contexts are only relevant for servant-server.

For more information, see the tutorial.

Instances
HasLink sub => HasLink (WithNamedContext name context sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (WithNamedContext name context sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (WithNamedContext name context sub) -> Link -> MkLink (WithNamedContext name context sub) a #

(HasContextEntry context (NamedContext name subContext), HasServer subApi subContext) => HasServer (WithNamedContext name subContext subApi :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (WithNamedContext name subContext subApi) m :: * #

Methods

route :: Proxy (WithNamedContext name subContext subApi) -> Context context -> Delayed env (Server (WithNamedContext name subContext subApi)) -> Router env #

hoistServerWithContext :: Proxy (WithNamedContext name subContext subApi) -> Proxy context -> (forall x. m x -> n x) -> ServerT (WithNamedContext name subContext subApi) m -> ServerT (WithNamedContext name subContext subApi) n #

type MkLink (WithNamedContext name context sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (WithNamedContext name context sub :: *) a = MkLink sub a
type ServerT (WithNamedContext name subContext subApi :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (WithNamedContext name subContext subApi :: *) m = ServerT subApi m

type family Endpoints api :: [*] where ... #

Flatten API into a list of endpoints.

>>> Refl :: Endpoints SampleAPI :~: '["hello" :> Verb 'GET 200 '[JSON] Int, "bye" :> (Capture "name" String :> Verb 'POST 200 '[JSON, PlainText] Bool)]
Refl

Equations

Endpoints (a :<|> b) = AppendList (Endpoints a) (Endpoints b) 
Endpoints (e :> a) = MapSub e (Endpoints a) 
Endpoints a = a ': ([] :: [*]) 

type family IsElem' a s :: Constraint #

You may use this type family to tell the type checker that your custom type may be skipped as part of a link. This is useful for things like QueryParam that are optional in a URI and do not affect them if they are omitted.

>>> data CustomThing
>>> type instance IsElem' e (CustomThing :> s) = IsElem e s

Note that IsElem is called, which will mutually recurse back to IsElem' if it exhausts all other options again.

Once you have written a HasLink instance for CustomThing you are ready to go.

type family IsElem endpoint api :: Constraint where ... #

Closed type family, check if endpoint is within api. Uses IsElem' if it exhausts all other options.

>>> ok (Proxy :: Proxy (IsElem ("hello" :> Get '[JSON] Int) SampleAPI))
OK
>>> ok (Proxy :: Proxy (IsElem ("bye" :> Get '[JSON] Int) SampleAPI))
...
... Could not deduce...
...

An endpoint is considered within an api even if it is missing combinators that don't affect the URL:

>>> ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (Header "h" Bool :> Get '[JSON] Int)))
OK
>>> ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (ReqBody '[JSON] Bool :> Get '[JSON] Int)))
OK
  • N.B.:* IsElem a b can be seen as capturing the notion of whether the URL represented by a would match the URL represented by b, *not* whether a request represented by a matches the endpoints serving b (for the latter, use IsIn).

Equations

IsElem e (sa :<|> sb) = Or (IsElem e sa) (IsElem e sb) 
IsElem (e :> sa) (e :> sb) = IsElem sa sb 
IsElem sa (Header sym x :> sb) = IsElem sa sb 
IsElem sa (ReqBody y x :> sb) = IsElem sa sb 
IsElem (CaptureAll z y :> sa) (CaptureAll x y :> sb) = IsElem sa sb 
IsElem (Capture z y :> sa) (Capture x y :> sb) = IsElem sa sb 
IsElem sa (QueryParam x y :> sb) = IsElem sa sb 
IsElem sa (QueryParams x y :> sb) = IsElem sa sb 
IsElem sa (QueryFlag x :> sb) = IsElem sa sb 
IsElem (Verb m s ct typ) (Verb m s ct' typ) = IsSubList ct ct' 
IsElem e e = () 
IsElem e a = IsElem' e a 

type family IsSubAPI sub api :: Constraint where ... #

Check whether sub is a sub-API of api.

>>> ok (Proxy :: Proxy (IsSubAPI SampleAPI (SampleAPI :<|> Get '[JSON] Int)))
OK
>>> ok (Proxy :: Proxy (IsSubAPI (SampleAPI :<|> Get '[JSON] Int) SampleAPI))
...
... Could not deduce...
...

This uses IsElem for checking; thus the note there applies here.

Equations

IsSubAPI sub api = AllIsElem (Endpoints sub) api 

type family AllIsElem (xs :: [*]) api :: Constraint where ... #

Check that every element of xs is an endpoint of api (using IsElem).

Equations

AllIsElem ([] :: [*]) api = () 
AllIsElem (x ': xs) api = (IsElem x api, AllIsElem xs api) 

type family IsIn endpoint api :: Constraint where ... #

Closed type family, check if endpoint is exactly within api.

>>> ok (Proxy :: Proxy (IsIn ("hello" :> Get '[JSON] Int) SampleAPI))
OK

Unlike IsElem, this requires an *exact* match.

>>> ok (Proxy :: Proxy (IsIn (Get '[JSON] Int) (Header "h" Bool :> Get '[JSON] Int)))
...
... Could not deduce...
...

Equations

IsIn e (sa :<|> sb) = Or (IsIn e sa) (IsIn e sb) 
IsIn (e :> sa) (e :> sb) = IsIn sa sb 
IsIn e e = () 

type family IsStrictSubAPI sub api :: Constraint where ... #

Check whether sub is a sub API of api.

Like IsSubAPI, but uses IsIn rather than IsElem.

Equations

IsStrictSubAPI sub api = AllIsIn (Endpoints sub) api 

type family AllIsIn (xs :: [*]) api :: Constraint where ... #

Check that every element of xs is an endpoint of api (using IsIn).

ok (Proxy :: Proxy (AllIsIn (Endpoints SampleAPI) SampleAPI)) OK

Equations

AllIsIn ([] :: [*]) api = () 
AllIsIn (x ': xs) api = (IsIn x api, AllIsIn xs api) 

type family MapSub (e :: k) (xs :: [*]) :: [*] where ... #

Apply (e :>) to every API in xs.

Equations

MapSub (e :: k) ([] :: [*]) = ([] :: [*]) 
MapSub (e :: k) (x ': xs) = (e :> x) ': MapSub e xs 

type family AppendList (xs :: [a]) (ys :: [a]) :: [a] where ... #

Append two type-level lists.

Equations

AppendList ([] :: [a]) (ys :: [a]) = ys 
AppendList (x ': xs :: [a]) (ys :: [a]) = x ': AppendList xs ys 

type family IsSubList (a :: [t]) (b :: [t]) :: Constraint where ... #

Equations

IsSubList ([] :: [t]) (b :: [t]) = () 
IsSubList (x ': xs :: [t]) (y :: [t]) = And (Elem x y) (IsSubList xs y) 

type Elem (e :: t) (es :: [t]) = ElemGo e es es #

Check that a value is an element of a list:

>>> ok (Proxy :: Proxy (Elem Bool '[Int, Bool]))
OK
>>> ok (Proxy :: Proxy (Elem String '[Int, Bool]))
...
... [Char]...'[Int, Bool...
...

type family ElemGo (e :: t) (es :: [t]) (orig :: t1) :: Constraint where ... #

Equations

ElemGo (x :: a) (x ': xs :: [a]) (orig :: t) = () 
ElemGo (y :: t1) (x ': xs :: [t1]) (orig :: t2) = ElemGo y xs orig 
ElemGo (x :: t2) ([] :: [t2]) (orig :: t1) = (TypeError ((ShowType x :<>: Text " expected in list ") :<>: ShowType orig) :: Constraint) 

data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [*]) a :: forall k1. k1 -> Nat -> [*] -> * -> * #

Verb is a general type for representing HTTP verbs (a.k.a. methods). For convenience, type synonyms for each verb with a 200 response code are provided, but you are free to define your own:

>>> type Post204 contentTypes a = Verb 'POST 204 contentTypes a
Instances
HasLink (Verb m s ct a :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Verb m s ct a) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (Verb m s ct a) -> Link -> MkLink (Verb m s ct a) a0 #

(AllCTRender ctypes a, ReflectMethod method, KnownNat status) => HasServer (Verb method status ctypes a :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Verb method status ctypes a) m :: * #

Methods

route :: Proxy (Verb method status ctypes a) -> Context context -> Delayed env (Server (Verb method status ctypes a)) -> Router env #

hoistServerWithContext :: Proxy (Verb method status ctypes a) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Verb method status ctypes a) m -> ServerT (Verb method status ctypes a) n #

(AllCTRender ctypes a, ReflectMethod method, KnownNat status, GetHeaders (Headers h a)) => HasServer (Verb method status ctypes (Headers h a) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Verb method status ctypes (Headers h a)) m :: * #

Methods

route :: Proxy (Verb method status ctypes (Headers h a)) -> Context context -> Delayed env (Server (Verb method status ctypes (Headers h a))) -> Router env #

hoistServerWithContext :: Proxy (Verb method status ctypes (Headers h a)) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Verb method status ctypes (Headers h a)) m -> ServerT (Verb method status ctypes (Headers h a)) n #

Generic (Verb method statusCode contentTypes a) 
Instance details

Defined in Servant.API.Verbs

Associated Types

type Rep (Verb method statusCode contentTypes a) :: * -> * #

Methods

from :: Verb method statusCode contentTypes a -> Rep (Verb method statusCode contentTypes a) x #

to :: Rep (Verb method statusCode contentTypes a) x -> Verb method statusCode contentTypes a #

type MkLink (Verb m s ct a :: *) r 
Instance details

Defined in Servant.Links

type MkLink (Verb m s ct a :: *) r = r
type ServerT (Verb method status ctypes (Headers h a) :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Verb method status ctypes (Headers h a) :: *) m = m (Headers h a)
type ServerT (Verb method status ctypes a :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Verb method status ctypes a :: *) m = m a
type Rep (Verb method statusCode contentTypes a) 
Instance details

Defined in Servant.API.Verbs

type Rep (Verb method statusCode contentTypes a) = D1 (MetaData "Verb" "Servant.API.Verbs" "servant-0.14.1-Kxp99gef9WABsGE0PQ92ss" False) (V1 :: * -> *)

type Get = Verb GET 200 #

GET with 200 status code.

type Post = Verb POST 200 #

POST with 200 status code.

type Put = Verb PUT 200 #

PUT with 200 status code.

type Delete = Verb DELETE 200 #

DELETE with 200 status code.

type Patch = Verb PATCH 200 #

PATCH with 200 status code.

type PostCreated = Verb POST 201 #

POST with 201 status code.

type GetAccepted = Verb GET 202 #

GET with 202 status code.

type PostAccepted = Verb POST 202 #

POST with 202 status code.

type DeleteAccepted = Verb DELETE 202 #

DELETE with 202 status code.

type PatchAccepted = Verb PATCH 202 #

PATCH with 202 status code.

type PutAccepted = Verb PUT 202 #

PUT with 202 status code.

type GetNonAuthoritative = Verb GET 203 #

GET with 203 status code.

type PostNonAuthoritative = Verb POST 203 #

POST with 203 status code.

type DeleteNonAuthoritative = Verb DELETE 203 #

DELETE with 203 status code.

type PatchNonAuthoritative = Verb PATCH 203 #

PATCH with 203 status code.

type PutNonAuthoritative = Verb PUT 203 #

PUT with 203 status code.

type GetNoContent = Verb GET 204 #

GET with 204 status code.

type PostNoContent = Verb POST 204 #

POST with 204 status code.

type DeleteNoContent = Verb DELETE 204 #

DELETE with 204 status code.

type PatchNoContent = Verb PATCH 204 #

PATCH with 204 status code.

type PutNoContent = Verb PUT 204 #

PUT with 204 status code.

type GetResetContent = Verb GET 205 #

GET with 205 status code.

type PostResetContent = Verb POST 205 #

POST with 205 status code.

type GetPartialContent = Verb GET 206 #

GET with 206 status code.

class ReflectMethod (a :: k) where #

Minimal complete definition

reflectMethod

Methods

reflectMethod :: Proxy a -> Method #

Instances
ReflectMethod PATCH 
Instance details

Defined in Servant.API.Verbs

ReflectMethod OPTIONS 
Instance details

Defined in Servant.API.Verbs

ReflectMethod CONNECT 
Instance details

Defined in Servant.API.Verbs

ReflectMethod TRACE 
Instance details

Defined in Servant.API.Verbs

ReflectMethod DELETE 
Instance details

Defined in Servant.API.Verbs

ReflectMethod PUT 
Instance details

Defined in Servant.API.Verbs

ReflectMethod HEAD 
Instance details

Defined in Servant.API.Verbs

ReflectMethod POST 
Instance details

Defined in Servant.API.Verbs

ReflectMethod GET 
Instance details

Defined in Servant.API.Verbs

data (path :: k) :> a :: forall k. k -> * -> * infixr 4 #

The contained API (second argument) can be found under ("/" ++ path) (path being the first argument).

Example:

>>> -- GET /hello/world
>>> -- returning a JSON encoded World value
>>> type MyApi = "hello" :> "world" :> Get '[JSON] World
Instances
HasLink sub => HasLink (HttpVersion :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (HttpVersion :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (HttpVersion :> sub) -> Link -> MkLink (HttpVersion :> sub) a #

HasLink sub => HasLink (ReqBody' mods ct a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (ReqBody' mods ct a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (ReqBody' mods ct a :> sub) -> Link -> MkLink (ReqBody' mods ct a :> sub) a0 #

HasLink sub => HasLink (RemoteHost :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (RemoteHost :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (RemoteHost :> sub) -> Link -> MkLink (RemoteHost :> sub) a #

(KnownSymbol sym, ToHttpApiData v, HasLink sub, SBoolI (FoldRequired mods)) => HasLink (QueryParam' mods sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryParam' mods sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryParam' mods sym v :> sub) -> Link -> MkLink (QueryParam' mods sym v :> sub) a #

(KnownSymbol sym, ToHttpApiData v, HasLink sub) => HasLink (QueryParams sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryParams sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryParams sym v :> sub) -> Link -> MkLink (QueryParams sym v :> sub) a #

(KnownSymbol sym, HasLink sub) => HasLink (QueryFlag sym :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryFlag sym :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryFlag sym :> sub) -> Link -> MkLink (QueryFlag sym :> sub) a #

HasLink sub => HasLink (Header' mods sym a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Header' mods sym a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (Header' mods sym a :> sub) -> Link -> MkLink (Header' mods sym a :> sub) a0 #

HasLink sub => HasLink (IsSecure :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (IsSecure :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (IsSecure :> sub) -> Link -> MkLink (IsSecure :> sub) a #

HasLink sub => HasLink (AuthProtect tag :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (AuthProtect tag :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (AuthProtect tag :> sub) -> Link -> MkLink (AuthProtect tag :> sub) a #

HasLink sub => HasLink (Summary s :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Summary s :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Summary s :> sub) -> Link -> MkLink (Summary s :> sub) a #

HasLink sub => HasLink (Description s :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Description s :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Description s :> sub) -> Link -> MkLink (Description s :> sub) a #

(ToHttpApiData v, HasLink sub) => HasLink (Capture' mods sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Capture' mods sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Capture' mods sym v :> sub) -> Link -> MkLink (Capture' mods sym v :> sub) a #

(ToHttpApiData v, HasLink sub) => HasLink (CaptureAll sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (CaptureAll sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (CaptureAll sym v :> sub) -> Link -> MkLink (CaptureAll sym v :> sub) a #

HasLink sub => HasLink (BasicAuth realm a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (BasicAuth realm a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (BasicAuth realm a :> sub) -> Link -> MkLink (BasicAuth realm a :> sub) a0 #

HasLink sub => HasLink (Vault :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Vault :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Vault :> sub) -> Link -> MkLink (Vault :> sub) a #

(KnownSymbol sym, HasLink sub) => HasLink (sym :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (sym :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (sym :> sub) -> Link -> MkLink (sym :> sub) a #

(TypeError (HasServerArrowKindError arr) :: Constraint) => HasServer (arr :> api :: *) context

This instance catches mistakes when there are non-saturated type applications on LHS of :>.

>>> serve (Proxy :: Proxy (Capture "foo" :> Get '[JSON] Int)) (error "...")
...
...Expected something of kind Symbol or *, got: k -> l on the LHS of ':>'.
...Maybe you haven't applied enough arguments to
...Capture' '[] "foo"
...
>>> undefined :: Server (Capture "foo" :> Get '[JSON] Int)
...
...Expected something of kind Symbol or *, got: k -> l on the LHS of ':>'.
...Maybe you haven't applied enough arguments to
...Capture' '[] "foo"
...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (arr :> api) m :: * #

Methods

route :: Proxy (arr :> api) -> Context context -> Delayed env (Server (arr :> api)) -> Router env #

hoistServerWithContext :: Proxy (arr :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (arr :> api) m -> ServerT (arr :> api) n #

HasServer api context => HasServer (HttpVersion :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (HttpVersion :> api) m :: * #

Methods

route :: Proxy (HttpVersion :> api) -> Context context -> Delayed env (Server (HttpVersion :> api)) -> Router env #

hoistServerWithContext :: Proxy (HttpVersion :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (HttpVersion :> api) m -> ServerT (HttpVersion :> api) n #

(AllCTUnrender list a, HasServer api context, SBoolI (FoldLenient mods)) => HasServer (ReqBody' mods list a :> api :: *) context

If you use ReqBody in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by ReqBody. The Content-Type header is inspected, and the list provided is used to attempt deserialization. If the request does not have a Content-Type header, it is treated as application/octet-stream (as specified in RFC7231. This lets servant worry about extracting it from the request and turning it into a value of the type you specify.

All it asks is for a FromJSON instance.

Example:

type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book

server :: Server MyApi
server = postBook
  where postBook :: Book -> Handler Book
        postBook book = ...insert into your db...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (ReqBody' mods list a :> api) m :: * #

Methods

route :: Proxy (ReqBody' mods list a :> api) -> Context context -> Delayed env (Server (ReqBody' mods list a :> api)) -> Router env #

hoistServerWithContext :: Proxy (ReqBody' mods list a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (ReqBody' mods list a :> api) m -> ServerT (ReqBody' mods list a :> api) n #

HasServer api context => HasServer (RemoteHost :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (RemoteHost :> api) m :: * #

Methods

route :: Proxy (RemoteHost :> api) -> Context context -> Delayed env (Server (RemoteHost :> api)) -> Router env #

hoistServerWithContext :: Proxy (RemoteHost :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (RemoteHost :> api) m -> ServerT (RemoteHost :> api) n #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (QueryParam' mods sym a :> api :: *) context

If you use QueryParam "author" Text in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type Maybe Text.

This lets servant worry about looking it up in the query string and turning it into a value of the type you specify, enclosed in Maybe, because it may not be there and servant would then hand you Nothing.

You can control how it'll be converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "books" :> QueryParam "author" Text :> Get '[JSON] [Book]

server :: Server MyApi
server = getBooksBy
  where getBooksBy :: Maybe Text -> Handler [Book]
        getBooksBy Nothing       = ...return all books...
        getBooksBy (Just author) = ...return books by the given author...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParam' mods sym a :> api) m :: * #

Methods

route :: Proxy (QueryParam' mods sym a :> api) -> Context context -> Delayed env (Server (QueryParam' mods sym a :> api)) -> Router env #

hoistServerWithContext :: Proxy (QueryParam' mods sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryParam' mods sym a :> api) m -> ServerT (QueryParam' mods sym a :> api) n #

(KnownSymbol sym, FromHttpApiData a, HasServer api context) => HasServer (QueryParams sym a :> api :: *) context

If you use QueryParams "authors" Text in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type [Text].

This lets servant worry about looking up 0 or more values in the query string associated to authors and turning each of them into a value of the type you specify.

You can control how the individual values are converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "books" :> QueryParams "authors" Text :> Get '[JSON] [Book]

server :: Server MyApi
server = getBooksBy
  where getBooksBy :: [Text] -> Handler [Book]
        getBooksBy authors = ...return all books by these authors...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParams sym a :> api) m :: * #

Methods

route :: Proxy (QueryParams sym a :> api) -> Context context -> Delayed env (Server (QueryParams sym a :> api)) -> Router env #

hoistServerWithContext :: Proxy (QueryParams sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryParams sym a :> api) m -> ServerT (QueryParams sym a :> api) n #

(KnownSymbol sym, HasServer api context) => HasServer (QueryFlag sym :> api :: *) context

If you use QueryFlag "published" in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type Bool.

Example:

type MyApi = "books" :> QueryFlag "published" :> Get '[JSON] [Book]

server :: Server MyApi
server = getBooks
  where getBooks :: Bool -> Handler [Book]
        getBooks onlyPublished = ...return all books, or only the ones that are already published, depending on the argument...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryFlag sym :> api) m :: * #

Methods

route :: Proxy (QueryFlag sym :> api) -> Context context -> Delayed env (Server (QueryFlag sym :> api)) -> Router env #

hoistServerWithContext :: Proxy (QueryFlag sym :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryFlag sym :> api) m -> ServerT (QueryFlag sym :> api) n #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (Header' mods sym a :> api :: *) context

If you use Header in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by Header. This lets servant worry about extracting it from the request and turning it into a value of the type you specify.

All it asks is for a FromHttpApiData instance.

Example:

newtype Referer = Referer Text
  deriving (Eq, Show, FromHttpApiData)

           -- GET /view-my-referer
type MyApi = "view-my-referer" :> Header "Referer" Referer :> Get '[JSON] Referer

server :: Server MyApi
server = viewReferer
  where viewReferer :: Referer -> Handler referer
        viewReferer referer = return referer
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Header' mods sym a :> api) m :: * #

Methods

route :: Proxy (Header' mods sym a :> api) -> Context context -> Delayed env (Server (Header' mods sym a :> api)) -> Router env #

hoistServerWithContext :: Proxy (Header' mods sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Header' mods sym a :> api) m -> ServerT (Header' mods sym a :> api) n #

HasServer api context => HasServer (IsSecure :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (IsSecure :> api) m :: * #

Methods

route :: Proxy (IsSecure :> api) -> Context context -> Delayed env (Server (IsSecure :> api)) -> Router env #

hoistServerWithContext :: Proxy (IsSecure :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (IsSecure :> api) m -> ServerT (IsSecure :> api) n #

HasServer api ctx => HasServer (Summary desc :> api :: *) ctx

Ignore Summary in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Summary desc :> api) m :: * #

Methods

route :: Proxy (Summary desc :> api) -> Context ctx -> Delayed env (Server (Summary desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Summary desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Summary desc :> api) m -> ServerT (Summary desc :> api) n #

HasServer api ctx => HasServer (Description desc :> api :: *) ctx

Ignore Description in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Description desc :> api) m :: * #

Methods

route :: Proxy (Description desc :> api) -> Context ctx -> Delayed env (Server (Description desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Description desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Description desc :> api) m -> ServerT (Description desc :> api) n #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (Capture' mods capture a :> api :: *) context

If you use Capture in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by the Capture. This lets servant worry about getting it from the URL and turning it into a value of the type you specify.

You can control how it'll be converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book

server :: Server MyApi
server = getBook
  where getBook :: Text -> Handler Book
        getBook isbn = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Capture' mods capture a :> api) m :: * #

Methods

route :: Proxy (Capture' mods capture a :> api) -> Context context -> Delayed env (Server (Capture' mods capture a :> api)) -> Router env #

hoistServerWithContext :: Proxy (Capture' mods capture a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Capture' mods capture a :> api) m -> ServerT (Capture' mods capture a :> api) n #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (CaptureAll capture a :> api :: *) context

If you use CaptureAll in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of a list of the type specified by the CaptureAll. This lets servant worry about getting values from the URL and turning them into values of the type you specify.

You can control how they'll be converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "src" :> CaptureAll "segments" Text :> Get '[JSON] SourceFile

server :: Server MyApi
server = getSourceFile
  where getSourceFile :: [Text] -> Handler Book
        getSourceFile pathSegments = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (CaptureAll capture a :> api) m :: * #

Methods

route :: Proxy (CaptureAll capture a :> api) -> Context context -> Delayed env (Server (CaptureAll capture a :> api)) -> Router env #

hoistServerWithContext :: Proxy (CaptureAll capture a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (CaptureAll capture a :> api) m -> ServerT (CaptureAll capture a :> api) n #

(KnownSymbol realm, HasServer api context, HasContextEntry context (BasicAuthCheck usr)) => HasServer (BasicAuth realm usr :> api :: *) context

Basic Authentication

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (BasicAuth realm usr :> api) m :: * #

Methods

route :: Proxy (BasicAuth realm usr :> api) -> Context context -> Delayed env (Server (BasicAuth realm usr :> api)) -> Router env #

hoistServerWithContext :: Proxy (BasicAuth realm usr :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (BasicAuth realm usr :> api) m -> ServerT (BasicAuth realm usr :> api) n #

HasServer api context => HasServer (Vault :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Vault :> api) m :: * #

Methods

route :: Proxy (Vault :> api) -> Context context -> Delayed env (Server (Vault :> api)) -> Router env #

hoistServerWithContext :: Proxy (Vault :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Vault :> api) m -> ServerT (Vault :> api) n #

(KnownSymbol path, HasServer api context) => HasServer (path :> api :: *) context

Make sure the incoming request starts with "/path", strip it and pass the rest of the request path to api.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (path :> api) m :: * #

Methods

route :: Proxy (path :> api) -> Context context -> Delayed env (Server (path :> api)) -> Router env #

hoistServerWithContext :: Proxy (path :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (path :> api) m -> ServerT (path :> api) n #

type MkLink (HttpVersion :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (HttpVersion :> sub :: *) a = MkLink sub a
type MkLink (ReqBody' mods ct a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (ReqBody' mods ct a :> sub :: *) r = MkLink sub r
type MkLink (RemoteHost :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (RemoteHost :> sub :: *) a = MkLink sub a
type MkLink (QueryParam' mods sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryParam' mods sym v :> sub :: *) a = If (FoldRequired mods) v (Maybe v) -> MkLink sub a
type MkLink (QueryParams sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryParams sym v :> sub :: *) a = [v] -> MkLink sub a
type MkLink (QueryFlag sym :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryFlag sym :> sub :: *) a = Bool -> MkLink sub a
type MkLink (Header' mods sym a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (Header' mods sym a :> sub :: *) r = MkLink sub r
type MkLink (IsSecure :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (IsSecure :> sub :: *) a = MkLink sub a
type MkLink (AuthProtect tag :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (AuthProtect tag :> sub :: *) a = MkLink sub a
type MkLink (Summary s :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Summary s :> sub :: *) a = MkLink sub a
type MkLink (Description s :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Description s :> sub :: *) a = MkLink sub a
type MkLink (Capture' mods sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Capture' mods sym v :> sub :: *) a = v -> MkLink sub a
type MkLink (CaptureAll sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (CaptureAll sym v :> sub :: *) a = [v] -> MkLink sub a
type MkLink (BasicAuth realm a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (BasicAuth realm a :> sub :: *) r = MkLink sub r
type MkLink (Vault :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Vault :> sub :: *) a = MkLink sub a
type MkLink (sym :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (sym :> sub :: *) a = MkLink sub a
type ServerT (arr :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (arr :> api :: *) m = (TypeError (HasServerArrowKindError arr) :: *)
type ServerT (HttpVersion :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (HttpVersion :> api :: *) m = HttpVersion -> ServerT api m
type ServerT (ReqBody' mods list a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (ReqBody' mods list a :> api :: *) m = If (FoldLenient mods) (Either String a) a -> ServerT api m
type ServerT (RemoteHost :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (RemoteHost :> api :: *) m = SockAddr -> ServerT api m
type ServerT (QueryParam' mods sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryParam' mods sym a :> api :: *) m = RequestArgument mods a -> ServerT api m
type ServerT (QueryParams sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryParams sym a :> api :: *) m = [a] -> ServerT api m
type ServerT (QueryFlag sym :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryFlag sym :> api :: *) m = Bool -> ServerT api m
type ServerT (Header' mods sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Header' mods sym a :> api :: *) m = RequestArgument mods a -> ServerT api m
type ServerT (IsSecure :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (IsSecure :> api :: *) m = IsSecure -> ServerT api m
type ServerT (Summary desc :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Summary desc :> api :: *) m = ServerT api m
type ServerT (Description desc :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Description desc :> api :: *) m = ServerT api m
type ServerT (Capture' mods capture a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Capture' mods capture a :> api :: *) m = a -> ServerT api m
type ServerT (CaptureAll capture a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (CaptureAll capture a :> api :: *) m = [a] -> ServerT api m
type ServerT (BasicAuth realm usr :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (BasicAuth realm usr :> api :: *) m = usr -> ServerT api m
type ServerT (Vault :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Vault :> api :: *) m = Vault -> ServerT api m
type ServerT (path :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (path :> api :: *) m = ServerT api m

data Stream (method :: k1) (status :: Nat) framing contentType a :: forall k1. k1 -> Nat -> * -> * -> * -> * #

A Stream endpoint for a given method emits a stream of encoded values at a given Content-Type, delimited by a framing strategy. Stream endpoints always return response code 200 on success. Type synonyms are provided for standard methods.

Instances
HasLink (Stream m status fr ct a :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Stream m status fr ct a) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (Stream m status fr ct a) -> Link -> MkLink (Stream m status fr ct a) a0 #

(MimeRender ctype a, ReflectMethod method, KnownNat status, FramingRender framing ctype, ToStreamGenerator b a) => HasServer (Stream method status framing ctype b :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Stream method status framing ctype b) m :: * #

Methods

route :: Proxy (Stream method status framing ctype b) -> Context context -> Delayed env (Server (Stream method status framing ctype b)) -> Router env #

hoistServerWithContext :: Proxy (Stream method status framing ctype b) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Stream method status framing ctype b) m -> ServerT (Stream method status framing ctype b) n #

(MimeRender ctype a, ReflectMethod method, KnownNat status, FramingRender framing ctype, ToStreamGenerator b a, GetHeaders (Headers h b)) => HasServer (Stream method status framing ctype (Headers h b) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Stream method status framing ctype (Headers h b)) m :: * #

Methods

route :: Proxy (Stream method status framing ctype (Headers h b)) -> Context context -> Delayed env (Server (Stream method status framing ctype (Headers h b))) -> Router env #

hoistServerWithContext :: Proxy (Stream method status framing ctype (Headers h b)) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Stream method status framing ctype (Headers h b)) m -> ServerT (Stream method status framing ctype (Headers h b)) n #

Generic (Stream method status framing contentType a) 
Instance details

Defined in Servant.API.Stream

Associated Types

type Rep (Stream method status framing contentType a) :: * -> * #

Methods

from :: Stream method status framing contentType a -> Rep (Stream method status framing contentType a) x #

to :: Rep (Stream method status framing contentType a) x -> Stream method status framing contentType a #

type MkLink (Stream m status fr ct a :: *) r 
Instance details

Defined in Servant.Links

type MkLink (Stream m status fr ct a :: *) r = r
type ServerT (Stream method status framing ctype (Headers h b) :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Stream method status framing ctype (Headers h b) :: *) m = m (Headers h b)
type ServerT (Stream method status framing ctype b :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Stream method status framing ctype b :: *) m = m b
type Rep (Stream method status framing contentType a) 
Instance details

Defined in Servant.API.Stream

type Rep (Stream method status framing contentType a) = D1 (MetaData "Stream" "Servant.API.Stream" "servant-0.14.1-Kxp99gef9WABsGE0PQ92ss" False) (V1 :: * -> *)

type StreamGet = Stream GET 200 #

type StreamPost = Stream POST 200 #

newtype StreamGenerator a #

Stream endpoints may be implemented as producing a StreamGenerator -- a function that itself takes two emit functions -- the first to be used on the first value the stream emits, and the second to be used on all subsequent values (to allow interspersed framing strategies such as comma separation).

Constructors

StreamGenerator 

Fields

Instances
ToStreamGenerator (StreamGenerator a) a 
Instance details

Defined in Servant.API.Stream

class ToStreamGenerator a b | a -> b where #

ToStreamGenerator is intended to be implemented for types such as Conduit, Pipe, etc. By implementing this class, all such streaming abstractions can be used directly as endpoints.

Minimal complete definition

toStreamGenerator

Instances
ToStreamGenerator (StreamGenerator a) a 
Instance details

Defined in Servant.API.Stream

newtype ResultStream a #

Clients reading from streaming endpoints can be implemented as producing a ResultStream that captures the setup, takedown, and incremental logic for a read, being an IO continuation that takes a producer of Just either values or errors that terminates with a Nothing.

Constructors

ResultStream (forall b. (IO (Maybe (Either String a)) -> IO b) -> IO b) 
Instances
BuildFromStream a (ResultStream a) 
Instance details

Defined in Servant.API.Stream

class BuildFromStream a b where #

BuildFromStream is intended to be implemented for types such as Conduit, Pipe, etc. By implementing this class, all such streaming abstractions can be used directly on the client side for talking to streaming endpoints.

Minimal complete definition

buildFromStream

Methods

buildFromStream :: ResultStream a -> b #

Instances
BuildFromStream a (ResultStream a) 
Instance details

Defined in Servant.API.Stream

class FramingRender (strategy :: k) (a :: k1) where #

The FramingRender class provides the logic for emitting a framing strategy. The strategy emits a header, followed by boundary-delimited data, and finally a termination character. For many strategies, some of these will just be empty bytestrings.

Minimal complete definition

header, boundary, trailer

Methods

header :: Proxy strategy -> Proxy a -> ByteString #

boundary :: Proxy strategy -> Proxy a -> BoundaryStrategy #

trailer :: Proxy strategy -> Proxy a -> ByteString #

data BoundaryStrategy #

The bracketing strategy generates things to precede and follow the content, as with netstrings. The intersperse strategy inserts seperators between things, as with newline framing. Finally, the general strategy performs an arbitrary rewrite on the content, to allow escaping rules and such.

data ByteStringParser a #

A type of parser that can never fail, and has different parsing strategies (incremental, or EOF) depending if more input can be sent. The incremental parser should return Nothing if it would like to be sent a longer ByteString. If it returns a value, it also returns the remainder following that value.

class FramingUnrender (strategy :: k) (a :: k1) where #

The FramingUnrender class provides the logic for parsing a framing strategy. The outer ByteStringParser strips the header from a stream of bytes, and yields a parser that can handle the remainder, stepwise. Each frame may be a ByteString, or a String indicating the error state for that frame. Such states are per-frame, so that protocols that can resume after errors are able to do so. Eventually this returns an empty ByteString to indicate termination.

Minimal complete definition

unrenderFrames

data NoFraming #

A framing strategy that does not do any framing at all, it just passes the input data This will be used most of the time with binary data, such as files

data NewlineFraming #

A simple framing strategy that has no header or termination, and inserts a newline character between each frame. This assumes that it is used with a Content-Type that encodes without newlines (e.g. JSON).

noHeader :: AddHeader h v orig new => orig -> new #

Deliberately do not add a header to a value.

>>> let example1 = noHeader "hi" :: Headers '[Header "someheader" Int] String
>>> getHeaders example1
[]

addHeader :: AddHeader h v orig new => v -> orig -> new #

addHeader adds a header to a response. Note that it changes the type of the value in the following ways:

  1. A simple value is wrapped in "Headers '[hdr]":
>>> let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
>>> getHeaders example1
[("someheader","5")]
  1. A value that already has a header has its new header *prepended* to the existing list:
>>> let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
>>> let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] String
>>> getHeaders example2
[("1st","true"),("someheader","5")]

Note that while in your handlers type annotations are not required, since the type can be inferred from the API type, in other cases you may find yourself needing to add annotations.

data Headers (ls :: [*]) a #

Response Header objects. You should never need to construct one directly. Instead, use addOptionalHeader.

Constructors

Headers 

Fields

Instances
(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': (fst ': rest)) a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header h v ': (fst ': rest)) a

Functor (Headers ls) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

fmap :: (a -> b) -> Headers ls a -> Headers ls b #

(<$) :: a -> Headers ls b -> Headers ls a #

(AllCTRender ctypes a, ReflectMethod method, KnownNat status, GetHeaders (Headers h a)) => HasServer (Verb method status ctypes (Headers h a) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Verb method status ctypes (Headers h a)) m :: * #

Methods

route :: Proxy (Verb method status ctypes (Headers h a)) -> Context context -> Delayed env (Server (Verb method status ctypes (Headers h a))) -> Router env #

hoistServerWithContext :: Proxy (Verb method status ctypes (Headers h a)) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Verb method status ctypes (Headers h a)) m -> ServerT (Verb method status ctypes (Headers h a)) n #

(MimeRender ctype a, ReflectMethod method, KnownNat status, FramingRender framing ctype, ToStreamGenerator b a, GetHeaders (Headers h b)) => HasServer (Stream method status framing ctype (Headers h b) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Stream method status framing ctype (Headers h b)) m :: * #

Methods

route :: Proxy (Stream method status framing ctype (Headers h b)) -> Context context -> Delayed env (Server (Stream method status framing ctype (Headers h b))) -> Router env #

hoistServerWithContext :: Proxy (Stream method status framing ctype (Headers h b)) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Stream method status framing ctype (Headers h b)) m -> ServerT (Stream method status framing ctype (Headers h b)) n #

GetHeaders' hs => GetHeaders (Headers hs a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders :: Headers hs a -> [Header] #

type ServerT (Verb method status ctypes (Headers h a) :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Verb method status ctypes (Headers h a) :: *) m = m (Headers h a)
type ServerT (Stream method status framing ctype (Headers h b) :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Stream method status framing ctype (Headers h b) :: *) m = m (Headers h b)

data ResponseHeader (sym :: Symbol) a #

Instances
Functor (ResponseHeader sym) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

fmap :: (a -> b) -> ResponseHeader sym a -> ResponseHeader sym b #

(<$) :: a -> ResponseHeader sym b -> ResponseHeader sym a #

Eq a => Eq (ResponseHeader sym a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

(==) :: ResponseHeader sym a -> ResponseHeader sym a -> Bool #

(/=) :: ResponseHeader sym a -> ResponseHeader sym a -> Bool #

Show a => Show (ResponseHeader sym a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

showsPrec :: Int -> ResponseHeader sym a -> ShowS #

show :: ResponseHeader sym a -> String #

showList :: [ResponseHeader sym a] -> ShowS #

data HList (a :: [*]) where #

Constructors

HNil :: HList ([] :: [*]) 
HCons :: HList (Header h x ': xs) 
Instances
GetHeadersFromHList hs => GetHeaders (HList hs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders :: HList hs -> [Header] #

class BuildHeadersTo (hs :: [*]) where #

Minimal complete definition

buildHeadersTo

Methods

buildHeadersTo :: [Header] -> HList hs #

Note: if there are multiple occurences of a header in the argument, the values are interspersed with commas before deserialization (see RFC2616 Sec 4.2)

Instances
BuildHeadersTo ([] :: [*]) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

buildHeadersTo :: [Header] -> HList [] #

(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo (Header h v ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

buildHeadersTo :: [Header0] -> HList (Header h v ': xs) #

class GetHeaders ls where #

Minimal complete definition

getHeaders

Methods

getHeaders :: ls -> [Header] #

Instances
GetHeadersFromHList hs => GetHeaders (HList hs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders :: HList hs -> [Header] #

GetHeaders' hs => GetHeaders (Headers hs a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders :: Headers hs a -> [Header] #

class AddHeader (h :: Symbol) v orig new | h v orig -> new, new -> h, new -> v, new -> orig #

Minimal complete definition

addOptionalHeader

Instances
(KnownSymbol h, ToHttpApiData v, new ~ Headers (Header h v ': ([] :: [*])) a) => AddHeader h v a new 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> a -> new

(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': (fst ': rest)) a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header h v ': (fst ': rest)) a

type ReqBody = ReqBody' (Required ': (Strict ': ([] :: [*]))) #

Extract the request body as a value of type a.

Example:

>>> -- POST /books
>>> type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book

data ReqBody' (mods :: [*]) (contentTypes :: [*]) a #

Note: ReqBody' is always Required.

Instances
HasLink sub => HasLink (ReqBody' mods ct a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (ReqBody' mods ct a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (ReqBody' mods ct a :> sub) -> Link -> MkLink (ReqBody' mods ct a :> sub) a0 #

(AllCTUnrender list a, HasServer api context, SBoolI (FoldLenient mods)) => HasServer (ReqBody' mods list a :> api :: *) context

If you use ReqBody in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by ReqBody. The Content-Type header is inspected, and the list provided is used to attempt deserialization. If the request does not have a Content-Type header, it is treated as application/octet-stream (as specified in RFC7231. This lets servant worry about extracting it from the request and turning it into a value of the type you specify.

All it asks is for a FromJSON instance.

Example:

type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book

server :: Server MyApi
server = postBook
  where postBook :: Book -> Handler Book
        postBook book = ...insert into your db...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (ReqBody' mods list a :> api) m :: * #

Methods

route :: Proxy (ReqBody' mods list a :> api) -> Context context -> Delayed env (Server (ReqBody' mods list a :> api)) -> Router env #

hoistServerWithContext :: Proxy (ReqBody' mods list a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (ReqBody' mods list a :> api) m -> ServerT (ReqBody' mods list a :> api) n #

type MkLink (ReqBody' mods ct a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (ReqBody' mods ct a :> sub :: *) r = MkLink sub r
type ServerT (ReqBody' mods list a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (ReqBody' mods list a :> api :: *) m = If (FoldLenient mods) (Either String a) a -> ServerT api m

data RemoteHost #

Provides access to the host or IP address from which the HTTP request was sent.

Instances
HasLink sub => HasLink (RemoteHost :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (RemoteHost :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (RemoteHost :> sub) -> Link -> MkLink (RemoteHost :> sub) a #

HasServer api context => HasServer (RemoteHost :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (RemoteHost :> api) m :: * #

Methods

route :: Proxy (RemoteHost :> api) -> Context context -> Delayed env (Server (RemoteHost :> api)) -> Router env #

hoistServerWithContext :: Proxy (RemoteHost :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (RemoteHost :> api) m -> ServerT (RemoteHost :> api) n #

type MkLink (RemoteHost :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (RemoteHost :> sub :: *) a = MkLink sub a
type ServerT (RemoteHost :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (RemoteHost :> api :: *) m = SockAddr -> ServerT api m

data Raw #

Endpoint for plugging in your own Wai Applications.

The given Application will get the request as received by the server, potentially with a modified (stripped) pathInfo if the Application is being routed with :>.

In addition to just letting you plug in your existing WAI Applications, this can also be used with serveDirectory to serve static files stored in a particular directory on your filesystem

Instances
HasLink Raw 
Instance details

Defined in Servant.Links

Associated Types

type MkLink Raw a :: * #

Methods

toLink :: (Link -> a) -> Proxy Raw -> Link -> MkLink Raw a #

HasServer Raw context

Just pass the request to the underlying application and serve its response.

Example:

type MyApi = "images" :> Raw

server :: Server MyApi
server = serveDirectory "/var/www/images"
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT Raw m :: * #

Methods

route :: Proxy Raw -> Context context -> Delayed env (Server Raw) -> Router env #

hoistServerWithContext :: Proxy Raw -> Proxy context -> (forall x. m x -> n x) -> ServerT Raw m -> ServerT Raw n #

type MkLink Raw a 
Instance details

Defined in Servant.Links

type MkLink Raw a = a
type ServerT Raw m 
Instance details

Defined in Servant.Server.Internal

type QueryParam = QueryParam' (Optional ': (Strict ': ([] :: [*]))) #

Lookup the value associated to the sym query string parameter and try to extract it as a value of type a.

Example:

>>> -- /books?author=<author name>
>>> type MyApi = "books" :> QueryParam "author" Text :> Get '[JSON] [Book]

data QueryParam' (mods :: [*]) (sym :: Symbol) a #

QueryParam which can be Required, Lenient, or modified otherwise.

Instances
(KnownSymbol sym, ToHttpApiData v, HasLink sub, SBoolI (FoldRequired mods)) => HasLink (QueryParam' mods sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryParam' mods sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryParam' mods sym v :> sub) -> Link -> MkLink (QueryParam' mods sym v :> sub) a #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (QueryParam' mods sym a :> api :: *) context

If you use QueryParam "author" Text in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type Maybe Text.

This lets servant worry about looking it up in the query string and turning it into a value of the type you specify, enclosed in Maybe, because it may not be there and servant would then hand you Nothing.

You can control how it'll be converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "books" :> QueryParam "author" Text :> Get '[JSON] [Book]

server :: Server MyApi
server = getBooksBy
  where getBooksBy :: Maybe Text -> Handler [Book]
        getBooksBy Nothing       = ...return all books...
        getBooksBy (Just author) = ...return books by the given author...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParam' mods sym a :> api) m :: * #

Methods

route :: Proxy (QueryParam' mods sym a :> api) -> Context context -> Delayed env (Server (QueryParam' mods sym a :> api)) -> Router env #

hoistServerWithContext :: Proxy (QueryParam' mods sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryParam' mods sym a :> api) m -> ServerT (QueryParam' mods sym a :> api) n #

type MkLink (QueryParam' mods sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryParam' mods sym v :> sub :: *) a = If (FoldRequired mods) v (Maybe v) -> MkLink sub a
type ServerT (QueryParam' mods sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryParam' mods sym a :> api :: *) m = RequestArgument mods a -> ServerT api m

data QueryParams (sym :: Symbol) a #

Lookup the values associated to the sym query string parameter and try to extract it as a value of type [a]. This is typically meant to support query string parameters of the form param[]=val1&param[]=val2 and so on. Note that servant doesn't actually require the []s and will fetch the values just fine with param=val1&param=val2, too.

Example:

>>> -- /books?authors[]=<author1>&authors[]=<author2>&...
>>> type MyApi = "books" :> QueryParams "authors" Text :> Get '[JSON] [Book]
Instances
(KnownSymbol sym, ToHttpApiData v, HasLink sub) => HasLink (QueryParams sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryParams sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryParams sym v :> sub) -> Link -> MkLink (QueryParams sym v :> sub) a #

(KnownSymbol sym, FromHttpApiData a, HasServer api context) => HasServer (QueryParams sym a :> api :: *) context

If you use QueryParams "authors" Text in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type [Text].

This lets servant worry about looking up 0 or more values in the query string associated to authors and turning each of them into a value of the type you specify.

You can control how the individual values are converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "books" :> QueryParams "authors" Text :> Get '[JSON] [Book]

server :: Server MyApi
server = getBooksBy
  where getBooksBy :: [Text] -> Handler [Book]
        getBooksBy authors = ...return all books by these authors...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParams sym a :> api) m :: * #

Methods

route :: Proxy (QueryParams sym a :> api) -> Context context -> Delayed env (Server (QueryParams sym a :> api)) -> Router env #

hoistServerWithContext :: Proxy (QueryParams sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryParams sym a :> api) m -> ServerT (QueryParams sym a :> api) n #

type MkLink (QueryParams sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryParams sym v :> sub :: *) a = [v] -> MkLink sub a
type ServerT (QueryParams sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryParams sym a :> api :: *) m = [a] -> ServerT api m

data QueryFlag (sym :: Symbol) #

Lookup a potentially value-less query string parameter with boolean semantics. If the param sym is there without any value, or if it's there with value "true" or "1", it's interpreted as True. Otherwise, it's interpreted as False.

Example:

>>> -- /books?published
>>> type MyApi = "books" :> QueryFlag "published" :> Get '[JSON] [Book]
Instances
(KnownSymbol sym, HasLink sub) => HasLink (QueryFlag sym :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryFlag sym :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryFlag sym :> sub) -> Link -> MkLink (QueryFlag sym :> sub) a #

(KnownSymbol sym, HasServer api context) => HasServer (QueryFlag sym :> api :: *) context

If you use QueryFlag "published" in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type Bool.

Example:

type MyApi = "books" :> QueryFlag "published" :> Get '[JSON] [Book]

server :: Server MyApi
server = getBooks
  where getBooks :: Bool -> Handler [Book]
        getBooks onlyPublished = ...return all books, or only the ones that are already published, depending on the argument...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryFlag sym :> api) m :: * #

Methods

route :: Proxy (QueryFlag sym :> api) -> Context context -> Delayed env (Server (QueryFlag sym :> api)) -> Router env #

hoistServerWithContext :: Proxy (QueryFlag sym :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryFlag sym :> api) m -> ServerT (QueryFlag sym :> api) n #

type MkLink (QueryFlag sym :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryFlag sym :> sub :: *) a = Bool -> MkLink sub a
type ServerT (QueryFlag sym :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryFlag sym :> api :: *) m = Bool -> ServerT api m

type Header = (Header' (Optional ': (Strict ': ([] :: [*]))) :: Symbol -> k -> *) #

Extract the given header's value as a value of type a. I.e. header sent by client, parsed by server.

Example:

>>> newtype Referer = Referer Text deriving (Eq, Show)
>>> 
>>> -- GET /view-my-referer
>>> type MyApi = "view-my-referer" :> Header "from" Referer :> Get '[JSON] Referer

data Header' (mods :: [*]) (sym :: Symbol) (a :: k) :: forall k. [*] -> Symbol -> k -> * #

Instances
(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': (fst ': rest)) a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header h v ': (fst ': rest)) a

HasLink sub => HasLink (Header' mods sym a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Header' mods sym a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (Header' mods sym a :> sub) -> Link -> MkLink (Header' mods sym a :> sub) a0 #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (Header' mods sym a :> api :: *) context

If you use Header in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by Header. This lets servant worry about extracting it from the request and turning it into a value of the type you specify.

All it asks is for a FromHttpApiData instance.

Example:

newtype Referer = Referer Text
  deriving (Eq, Show, FromHttpApiData)

           -- GET /view-my-referer
type MyApi = "view-my-referer" :> Header "Referer" Referer :> Get '[JSON] Referer

server :: Server MyApi
server = viewReferer
  where viewReferer :: Referer -> Handler referer
        viewReferer referer = return referer
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Header' mods sym a :> api) m :: * #

Methods

route :: Proxy (Header' mods sym a :> api) -> Context context -> Delayed env (Server (Header' mods sym a :> api)) -> Router env #

hoistServerWithContext :: Proxy (Header' mods sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Header' mods sym a :> api) m -> ServerT (Header' mods sym a :> api) n #

(KnownSymbol h, ToHttpApiData x, GetHeadersFromHList xs) => GetHeadersFromHList (Header h x ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeadersFromHList :: HList (Header h x ': xs) -> [Header0]

(KnownSymbol h, GetHeadersFromHList rest, ToHttpApiData v) => GetHeaders' (Header h v ': rest) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders' :: Headers (Header h v ': rest) a -> [Header0]

(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo (Header h v ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

buildHeadersTo :: [Header0] -> HList (Header h v ': xs) #

type MkLink (Header' mods sym a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (Header' mods sym a :> sub :: *) r = MkLink sub r
type ServerT (Header' mods sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Header' mods sym a :> api :: *) m = RequestArgument mods a -> ServerT api m

data Required #

Required argument. Not wrapped.

data Optional #

Optional argument. Wrapped in Maybe.

Instances
(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': (fst ': rest)) a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header h v ': (fst ': rest)) a

(KnownSymbol h, ToHttpApiData x, GetHeadersFromHList xs) => GetHeadersFromHList (Header h x ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeadersFromHList :: HList (Header h x ': xs) -> [Header0]

(KnownSymbol h, GetHeadersFromHList rest, ToHttpApiData v) => GetHeaders' (Header h v ': rest) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders' :: Headers (Header h v ': rest) a -> [Header0]

(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo (Header h v ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

buildHeadersTo :: [Header0] -> HList (Header h v ': xs) #

data Lenient #

Leniently parsed argument, i.e. parsing never fail. Wrapped in Either Text.

data Strict #

Strictly parsed argument. Not wrapped.

Instances
(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': (fst ': rest)) a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header h v ': (fst ': rest)) a

(KnownSymbol h, ToHttpApiData x, GetHeadersFromHList xs) => GetHeadersFromHList (Header h x ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeadersFromHList :: HList (Header h x ': xs) -> [Header0]

(KnownSymbol h, GetHeadersFromHList rest, ToHttpApiData v) => GetHeaders' (Header h v ': rest) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders' :: Headers (Header h v ': rest) a -> [Header0]

(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo (Header h v ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

buildHeadersTo :: [Header0] -> HList (Header h v ': xs) #

data IsSecure #

Was this request made over an SSL connection?

Note that this value will not tell you if the client originally made this request over SSL, but rather whether the current connection is SSL. The distinction lies with reverse proxies. In many cases, the client will connect to a load balancer over SSL, but connect to the WAI handler without SSL. In such a case, the handlers would get NotSecure, but from a user perspective, there is a secure connection.

Constructors

Secure

the connection to the server is secure (HTTPS)

NotSecure

the connection to the server is not secure (HTTP)

Instances
Eq IsSecure 
Instance details

Defined in Servant.API.IsSecure

Ord IsSecure 
Instance details

Defined in Servant.API.IsSecure

Read IsSecure 
Instance details

Defined in Servant.API.IsSecure

Show IsSecure 
Instance details

Defined in Servant.API.IsSecure

Generic IsSecure 
Instance details

Defined in Servant.API.IsSecure

Associated Types

type Rep IsSecure :: * -> * #

Methods

from :: IsSecure -> Rep IsSecure x #

to :: Rep IsSecure x -> IsSecure #

HasLink sub => HasLink (IsSecure :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (IsSecure :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (IsSecure :> sub) -> Link -> MkLink (IsSecure :> sub) a #

HasServer api context => HasServer (IsSecure :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (IsSecure :> api) m :: * #

Methods

route :: Proxy (IsSecure :> api) -> Context context -> Delayed env (Server (IsSecure :> api)) -> Router env #

hoistServerWithContext :: Proxy (IsSecure :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (IsSecure :> api) m -> ServerT (IsSecure :> api) n #

type Rep IsSecure 
Instance details

Defined in Servant.API.IsSecure

type Rep IsSecure = D1 (MetaData "IsSecure" "Servant.API.IsSecure" "servant-0.14.1-Kxp99gef9WABsGE0PQ92ss" False) (C1 (MetaCons "Secure" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "NotSecure" PrefixI False) (U1 :: * -> *))
type MkLink (IsSecure :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (IsSecure :> sub :: *) a = MkLink sub a
type ServerT (IsSecure :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (IsSecure :> api :: *) m = IsSecure -> ServerT api m

data AuthProtect (tag :: k) :: forall k. k -> * #

A generalized Authentication combinator. Use this if you have a non-standard authentication technique.

NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE.

Instances
HasLink sub => HasLink (AuthProtect tag :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (AuthProtect tag :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (AuthProtect tag :> sub) -> Link -> MkLink (AuthProtect tag :> sub) a #

type MkLink (AuthProtect tag :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (AuthProtect tag :> sub :: *) a = MkLink sub a

data EmptyAPI #

An empty API: one which serves nothing. Morally speaking, this should be the unit of :<|>. Implementors of interpretations of API types should treat EmptyAPI as close to the unit as possible.

Constructors

EmptyAPI 
Instances
Bounded EmptyAPI 
Instance details

Defined in Servant.API.Empty

Enum EmptyAPI 
Instance details

Defined in Servant.API.Empty

Eq EmptyAPI 
Instance details

Defined in Servant.API.Empty

Show EmptyAPI 
Instance details

Defined in Servant.API.Empty

HasLink EmptyAPI 
Instance details

Defined in Servant.Links

Associated Types

type MkLink EmptyAPI a :: * #

Methods

toLink :: (Link -> a) -> Proxy EmptyAPI -> Link -> MkLink EmptyAPI a #

HasServer EmptyAPI context

The server for an EmptyAPI is emptyAPIServer.

type MyApi = "nothing" :> EmptyApi

server :: Server MyApi
server = emptyAPIServer
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT EmptyAPI m :: * #

Methods

route :: Proxy EmptyAPI -> Context context -> Delayed env (Server EmptyAPI) -> Router env #

hoistServerWithContext :: Proxy EmptyAPI -> Proxy context -> (forall x. m x -> n x) -> ServerT EmptyAPI m -> ServerT EmptyAPI n #

type MkLink EmptyAPI a 
Instance details

Defined in Servant.Links

type ServerT EmptyAPI m 
Instance details

Defined in Servant.Server.Internal

data Summary (sym :: Symbol) #

Add a short summary for (part of) API.

Example:

>>> type MyApi = Summary "Get book by ISBN." :> "books" :> Capture "isbn" Text :> Get '[JSON] Book
Instances
HasLink sub => HasLink (Summary s :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Summary s :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Summary s :> sub) -> Link -> MkLink (Summary s :> sub) a #

HasServer api ctx => HasServer (Summary desc :> api :: *) ctx

Ignore Summary in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Summary desc :> api) m :: * #

Methods

route :: Proxy (Summary desc :> api) -> Context ctx -> Delayed env (Server (Summary desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Summary desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Summary desc :> api) m -> ServerT (Summary desc :> api) n #

type MkLink (Summary s :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Summary s :> sub :: *) a = MkLink sub a
type ServerT (Summary desc :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Summary desc :> api :: *) m = ServerT api m

data Description (sym :: Symbol) #

Add more verbose description for (part of) API.

Example:

>>> :{
type MyApi = Description
 "This comment is visible in multiple Servant interpretations \
 \and can be really long if necessary. \
 \Haskell multiline support is not perfect \
 \but it's still very readable."
:> Get '[JSON] Book
:}
Instances
HasLink sub => HasLink (Description s :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Description s :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Description s :> sub) -> Link -> MkLink (Description s :> sub) a #

HasServer api ctx => HasServer (Description desc :> api :: *) ctx

Ignore Description in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Description desc :> api) m :: * #

Methods

route :: Proxy (Description desc :> api) -> Context ctx -> Delayed env (Server (Description desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Description desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Description desc :> api) m -> ServerT (Description desc :> api) n #

type MkLink (Description s :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Description s :> sub :: *) a = MkLink sub a
type ServerT (Description desc :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Description desc :> api :: *) m = ServerT api m

data JSON #

Instances
Accept JSON
application/json
Instance details

Defined in Servant.API.ContentTypes

ToJSON a => MimeRender JSON a

encode

Instance details

Defined in Servant.API.ContentTypes

Methods

mimeRender :: Proxy JSON -> a -> ByteString #

FromJSON a => MimeUnrender JSON a

eitherDecode

Instance details

Defined in Servant.API.ContentTypes

data PlainText #

Instances
Accept PlainText
text/plain;charset=utf-8
Instance details

Defined in Servant.API.ContentTypes

MimeRender PlainText String
BC.pack
Instance details

Defined in Servant.API.ContentTypes

MimeRender PlainText Text
fromStrict . TextS.encodeUtf8
Instance details

Defined in Servant.API.ContentTypes

MimeRender PlainText Text

encodeUtf8

Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText String
Right . BC.unpack
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText Text
left show . TextS.decodeUtf8' . toStrict
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText Text
left show . TextL.decodeUtf8'
Instance details

Defined in Servant.API.ContentTypes

data FormUrlEncoded #

Instances
Accept FormUrlEncoded
application/x-www-form-urlencoded
Instance details

Defined in Servant.API.ContentTypes

ToForm a => MimeRender FormUrlEncoded a

urlEncodeAsForm Note that the mimeUnrender p (mimeRender p x) == Right x law only holds if every element of x is non-null (i.e., not ("", ""))

Instance details

Defined in Servant.API.ContentTypes

FromForm a => MimeUnrender FormUrlEncoded a

urlDecodeAsForm Note that the mimeUnrender p (mimeRender p x) == Right x law only holds if every element of x is non-null (i.e., not ("", ""))

Instance details

Defined in Servant.API.ContentTypes

class Accept (ctype :: k) where #

Instances of Accept represent mimetypes. They are used for matching against the Accept HTTP header of the request, and for setting the Content-Type header of the response

Example:

>>> import Network.HTTP.Media ((//), (/:))
>>> data HTML
>>> :{
instance Accept HTML where
   contentType _ = "text" // "html" /: ("charset", "utf-8")
:}

Minimal complete definition

contentType | contentTypes

Instances
Accept JSON
application/json
Instance details

Defined in Servant.API.ContentTypes

Accept PlainText
text/plain;charset=utf-8
Instance details

Defined in Servant.API.ContentTypes

Accept FormUrlEncoded
application/x-www-form-urlencoded
Instance details

Defined in Servant.API.ContentTypes

Accept OctetStream
application/octet-stream
Instance details

Defined in Servant.API.ContentTypes

class Accept ctype => MimeRender (ctype :: k) a where #

Instantiate this class to register a way of serializing a type based on the Accept header.

Example:

data MyContentType

instance Accept MyContentType where
   contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")

instance Show a => MimeRender MyContentType a where
   mimeRender _ val = pack ("This is MINE! " ++ show val)

type MyAPI = "path" :> Get '[MyContentType] Int

Minimal complete definition

mimeRender

Methods

mimeRender :: Proxy ctype -> a -> ByteString #

Instances
ToJSON a => MimeRender JSON a

encode

Instance details

Defined in Servant.API.ContentTypes

Methods

mimeRender :: Proxy JSON -> a -> ByteString #

MimeRender PlainText String
BC.pack
Instance details

Defined in Servant.API.ContentTypes

MimeRender PlainText Text
fromStrict . TextS.encodeUtf8
Instance details

Defined in Servant.API.ContentTypes

MimeRender PlainText Text

encodeUtf8

Instance details

Defined in Servant.API.ContentTypes

ToForm a => MimeRender FormUrlEncoded a

urlEncodeAsForm Note that the mimeUnrender p (mimeRender p x) == Right x law only holds if every element of x is non-null (i.e., not ("", ""))

Instance details

Defined in Servant.API.ContentTypes

MimeRender OctetStream ByteString

fromStrict

Instance details

Defined in Servant.API.ContentTypes

MimeRender OctetStream ByteString
id
Instance details

Defined in Servant.API.ContentTypes

class Accept ctype => MimeUnrender (ctype :: k) a where #

Instantiate this class to register a way of deserializing a type based on the request's Content-Type header.

>>> import Network.HTTP.Media hiding (Accept)
>>> import qualified Data.ByteString.Lazy.Char8 as BSC
>>> data MyContentType = MyContentType String
>>> :{
instance Accept MyContentType where
   contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
:}
>>> :{
instance Read a => MimeUnrender MyContentType a where
   mimeUnrender _ bs = case BSC.take 12 bs of
     "MyContentType" -> return . read . BSC.unpack $ BSC.drop 12 bs
     _ -> Left "didn't start with the magic incantation"
:}
>>> type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int

Minimal complete definition

mimeUnrender | mimeUnrenderWithType

Methods

mimeUnrender :: Proxy ctype -> ByteString -> Either String a #

mimeUnrenderWithType :: Proxy ctype -> MediaType -> ByteString -> Either String a #

Variant which is given the actual MediaType provided by the other party.

In the most cases you don't want to branch based on the MediaType. See pr552 for a motivating example.

Instances
FromJSON a => MimeUnrender JSON a

eitherDecode

Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText String
Right . BC.unpack
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText Text
left show . TextS.decodeUtf8' . toStrict
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText Text
left show . TextL.decodeUtf8'
Instance details

Defined in Servant.API.ContentTypes

FromForm a => MimeUnrender FormUrlEncoded a

urlDecodeAsForm Note that the mimeUnrender p (mimeRender p x) == Right x law only holds if every element of x is non-null (i.e., not ("", ""))

Instance details

Defined in Servant.API.ContentTypes

MimeUnrender OctetStream ByteString
Right . toStrict
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender OctetStream ByteString
Right . id
Instance details

Defined in Servant.API.ContentTypes

data NoContent #

A type for responses without content-body.

Constructors

NoContent 
Instances
Eq NoContent 
Instance details

Defined in Servant.API.ContentTypes

Read NoContent 
Instance details

Defined in Servant.API.ContentTypes

Show NoContent 
Instance details

Defined in Servant.API.ContentTypes

Generic NoContent 
Instance details

Defined in Servant.API.ContentTypes

Associated Types

type Rep NoContent :: * -> * #

Accept ctyp => AllMimeRender (ctyp ': ([] :: [*])) NoContent 
Instance details

Defined in Servant.API.ContentTypes

Methods

allMimeRender :: Proxy (ctyp ': []) -> NoContent -> [(MediaType, ByteString)] #

AllMime (ctyp ': (ctyp' ': ctyps)) => AllMimeRender (ctyp ': (ctyp' ': ctyps)) NoContent 
Instance details

Defined in Servant.API.ContentTypes

Methods

allMimeRender :: Proxy (ctyp ': (ctyp' ': ctyps)) -> NoContent -> [(MediaType, ByteString)] #

type Rep NoContent 
Instance details

Defined in Servant.API.ContentTypes

type Rep NoContent = D1 (MetaData "NoContent" "Servant.API.ContentTypes" "servant-0.14.1-Kxp99gef9WABsGE0PQ92ss" False) (C1 (MetaCons "NoContent" PrefixI False) (U1 :: * -> *))

type Capture = Capture' ([] :: [*]) #

Capture a value from the request path under a certain type a.

Example:

>>> -- GET /books/:isbn
>>> type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book

data Capture' (mods :: [*]) (sym :: Symbol) a #

Capture which can be modified. For example with Description.

Instances
(ToHttpApiData v, HasLink sub) => HasLink (Capture' mods sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Capture' mods sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Capture' mods sym v :> sub) -> Link -> MkLink (Capture' mods sym v :> sub) a #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (Capture' mods capture a :> api :: *) context

If you use Capture in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by the Capture. This lets servant worry about getting it from the URL and turning it into a value of the type you specify.

You can control how it'll be converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book

server :: Server MyApi
server = getBook
  where getBook :: Text -> Handler Book
        getBook isbn = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Capture' mods capture a :> api) m :: * #

Methods

route :: Proxy (Capture' mods capture a :> api) -> Context context -> Delayed env (Server (Capture' mods capture a :> api)) -> Router env #

hoistServerWithContext :: Proxy (Capture' mods capture a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Capture' mods capture a :> api) m -> ServerT (Capture' mods capture a :> api) n #

type MkLink (Capture' mods sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Capture' mods sym v :> sub :: *) a = v -> MkLink sub a
type ServerT (Capture' mods capture a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Capture' mods capture a :> api :: *) m = a -> ServerT api m

data CaptureAll (sym :: Symbol) a #

Capture all remaining values from the request path under a certain type a.

Example:

>>> -- GET /src/*
>>> type MyAPI = "src" :> CaptureAll "segments" Text :> Get '[JSON] SourceFile
Instances
(ToHttpApiData v, HasLink sub) => HasLink (CaptureAll sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (CaptureAll sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (CaptureAll sym v :> sub) -> Link -> MkLink (CaptureAll sym v :> sub) a #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (CaptureAll capture a :> api :: *) context

If you use CaptureAll in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of a list of the type specified by the CaptureAll. This lets servant worry about getting values from the URL and turning them into values of the type you specify.

You can control how they'll be converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "src" :> CaptureAll "segments" Text :> Get '[JSON] SourceFile

server :: Server MyApi
server = getSourceFile
  where getSourceFile :: [Text] -> Handler Book
        getSourceFile pathSegments = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (CaptureAll capture a :> api) m :: * #

Methods

route :: Proxy (CaptureAll capture a :> api) -> Context context -> Delayed env (Server (CaptureAll capture a :> api)) -> Router env #

hoistServerWithContext :: Proxy (CaptureAll capture a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (CaptureAll capture a :> api) m -> ServerT (CaptureAll capture a :> api) n #

type MkLink (CaptureAll sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (CaptureAll sym v :> sub :: *) a = [v] -> MkLink sub a
type ServerT (CaptureAll capture a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (CaptureAll capture a :> api :: *) m = [a] -> ServerT api m

data BasicAuth (realm :: Symbol) userData #

Combinator for Basic Access Authentication.

  • IMPORTANT*: Only use Basic Auth over HTTPS! Credentials are not hashed or encrypted. Note also that because the same credentials are sent on every request, Basic Auth is not as secure as some alternatives. Further, the implementation in servant-server does not protect against some types of timing attacks.

In Basic Auth, username and password are base64-encoded and transmitted via the Authorization header. Handshakes are not required, making it relatively efficient.

Instances
HasLink sub => HasLink (BasicAuth realm a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (BasicAuth realm a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (BasicAuth realm a :> sub) -> Link -> MkLink (BasicAuth realm a :> sub) a0 #

(KnownSymbol realm, HasServer api context, HasContextEntry context (BasicAuthCheck usr)) => HasServer (BasicAuth realm usr :> api :: *) context

Basic Authentication

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (BasicAuth realm usr :> api) m :: * #

Methods

route :: Proxy (BasicAuth realm usr :> api) -> Context context -> Delayed env (Server (BasicAuth realm usr :> api)) -> Router env #

hoistServerWithContext :: Proxy (BasicAuth realm usr :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (BasicAuth realm usr :> api) m -> ServerT (BasicAuth realm usr :> api) n #

type MkLink (BasicAuth realm a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (BasicAuth realm a :> sub :: *) r = MkLink sub r
type ServerT (BasicAuth realm usr :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (BasicAuth realm usr :> api :: *) m = usr -> ServerT api m

data BasicAuthData #

A simple datatype to hold data required to decorate a request

data a :<|> b infixr 3 #

Union of two APIs, first takes precedence in case of overlap.

Example:

>>> :{
type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
       :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] () -- POST /books
:}

Constructors

a :<|> b infixr 3 
Instances
Functor ((:<|>) a) 
Instance details

Defined in Servant.API.Alternative

Methods

fmap :: (a0 -> b) -> (a :<|> a0) -> a :<|> b #

(<$) :: a0 -> (a :<|> b) -> a :<|> a0 #

Foldable ((:<|>) a) 
Instance details

Defined in Servant.API.Alternative

Methods

fold :: Monoid m => (a :<|> m) -> m #

foldMap :: Monoid m => (a0 -> m) -> (a :<|> a0) -> m #

foldr :: (a0 -> b -> b) -> b -> (a :<|> a0) -> b #

foldr' :: (a0 -> b -> b) -> b -> (a :<|> a0) -> b #

foldl :: (b -> a0 -> b) -> b -> (a :<|> a0) -> b #

foldl' :: (b -> a0 -> b) -> b -> (a :<|> a0) -> b #

foldr1 :: (a0 -> a0 -> a0) -> (a :<|> a0) -> a0 #

foldl1 :: (a0 -> a0 -> a0) -> (a :<|> a0) -> a0 #

toList :: (a :<|> a0) -> [a0] #

null :: (a :<|> a0) -> Bool #

length :: (a :<|> a0) -> Int #

elem :: Eq a0 => a0 -> (a :<|> a0) -> Bool #

maximum :: Ord a0 => (a :<|> a0) -> a0 #

minimum :: Ord a0 => (a :<|> a0) -> a0 #

sum :: Num a0 => (a :<|> a0) -> a0 #

product :: Num a0 => (a :<|> a0) -> a0 #

Traversable ((:<|>) a) 
Instance details

Defined in Servant.API.Alternative

Methods

traverse :: Applicative f => (a0 -> f b) -> (a :<|> a0) -> f (a :<|> b) #

sequenceA :: Applicative f => (a :<|> f a0) -> f (a :<|> a0) #

mapM :: Monad m => (a0 -> m b) -> (a :<|> a0) -> m (a :<|> b) #

sequence :: Monad m => (a :<|> m a0) -> m (a :<|> a0) #

(HasLink a, HasLink b) => HasLink (a :<|> b :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (a :<|> b) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (a :<|> b) -> Link -> MkLink (a :<|> b) a0 #

(HasServer a context, HasServer b context) => HasServer (a :<|> b :: *) context

A server for a :<|> b first tries to match the request against the route represented by a and if it fails tries b. You must provide a request handler for each route.

type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
        :<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books

server :: Server MyApi
server = listAllBooks :<|> postBook
  where listAllBooks = ...
        postBook book = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (a :<|> b) m :: * #

Methods

route :: Proxy (a :<|> b) -> Context context -> Delayed env (Server (a :<|> b)) -> Router env #

hoistServerWithContext :: Proxy (a :<|> b) -> Proxy context -> (forall x. m x -> n x) -> ServerT (a :<|> b) m -> ServerT (a :<|> b) n #

(Bounded a, Bounded b) => Bounded (a :<|> b) 
Instance details

Defined in Servant.API.Alternative

Methods

minBound :: a :<|> b #

maxBound :: a :<|> b #

(Eq a, Eq b) => Eq (a :<|> b) 
Instance details

Defined in Servant.API.Alternative

Methods

(==) :: (a :<|> b) -> (a :<|> b) -> Bool #

(/=) :: (a :<|> b) -> (a :<|> b) -> Bool #

(Show a, Show b) => Show (a :<|> b) 
Instance details

Defined in Servant.API.Alternative

Methods

showsPrec :: Int -> (a :<|> b) -> ShowS #

show :: (a :<|> b) -> String #

showList :: [a :<|> b] -> ShowS #

(Semigroup a, Semigroup b) => Semigroup (a :<|> b) 
Instance details

Defined in Servant.API.Alternative

Methods

(<>) :: (a :<|> b) -> (a :<|> b) -> a :<|> b #

sconcat :: NonEmpty (a :<|> b) -> a :<|> b #

stimes :: Integral b0 => b0 -> (a :<|> b) -> a :<|> b #

(Monoid a, Monoid b) => Monoid (a :<|> b) 
Instance details

Defined in Servant.API.Alternative

Methods

mempty :: a :<|> b #

mappend :: (a :<|> b) -> (a :<|> b) -> a :<|> b #

mconcat :: [a :<|> b] -> a :<|> b #

type MkLink (a :<|> b :: *) r 
Instance details

Defined in Servant.Links

type MkLink (a :<|> b :: *) r = MkLink a r :<|> MkLink b r
type ServerT (a :<|> b :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (a :<|> b :: *) m = ServerT a m :<|> ServerT b m

type Vault = Vault RealWorld #

A persistent store for values of arbitrary types.

This variant is the simplest and creates keys in the IO monad. See the module Data.Vault.ST if you want to use it with the ST monad instead.

class SBoolI (b :: Bool) where #

Minimal complete definition

sbool

Methods

sbool :: SBool b #

Instances
SBoolI False 
Instance details

Defined in Data.Singletons.Bool

Methods

sbool :: SBool False #

SBoolI True 
Instance details

Defined in Data.Singletons.Bool

Methods

sbool :: SBool True #

data SBool (b :: Bool) where #

Constructors

STrue :: SBool True 
SFalse :: SBool False 

serveDirectory :: FilePath -> ServerT Raw m #

Same as serveDirectoryFileServer. It used to be the only file serving function in servant pre-0.10 and will be kept around for a few versions, but is deprecated.

serveDirectoryWith :: StaticSettings -> ServerT Raw m #

Alias for staticApp. Lets you serve a directory with arbitrary StaticSettings. Useful when you want particular settings not covered by the four other variants. This is the most flexible method.

serveDirectoryWebApp :: FilePath -> ServerT Raw m #

Serve anything under the specified directory as a Raw endpoint.

type MyApi = "static" :> Raw

server :: Server MyApi
server = serveDirectoryWebApp "/var/www"

would capture any request to /static/<something> and look for <something> under /var/www.

It will do its best to guess the MIME type for that file, based on the extension, and send an appropriate Content-Type header if possible.

If your goal is to serve HTML, CSS and Javascript files that use the rest of the API as a webapp backend, you will most likely not want the static files to be hidden behind a /static/ prefix. In that case, remember to put the serveDirectoryWebApp handler in the last position, because servant will try to match the handlers in order.

Corresponds to the defaultWebAppSettings StaticSettings value.

layoutWithContext :: HasServer api context => Proxy api -> Context context -> Text #

Variant of layout that takes an additional Context.

layout :: HasServer api ([] :: [*]) => Proxy api -> Text #

The function layout produces a textual description of the internal router layout for debugging purposes. Note that the router layout is determined just by the API, not by the handlers.

Example:

For the following API

type API =
       "a" :> "d" :> Get '[JSON] NoContent
  :<|> "b" :> Capture "x" Int :> Get '[JSON] Bool
  :<|> "c" :> Put '[JSON] Bool
  :<|> "a" :> "e" :> Get '[JSON] Int
  :<|> "b" :> Capture "x" Int :> Put '[JSON] Bool
  :<|> Raw

we get the following output:

/
├─ a/
│  ├─ d/
│  │  └─•
│  └─ e/
│     └─•
├─ b/
│  └─ <capture>/
│     ├─•
│     ┆
│     └─•
├─ c/
│  └─•
┆
└─ <raw>

Explanation of symbols:

Normal lines reflect static branching via a table.
a/
Nodes reflect static path components.
─•
Leaves reflect endpoints.
<capture>/
This is a delayed capture of a path component.
<raw>
This is a part of the API we do not know anything about.
Dashed lines suggest a dynamic choice between the part above and below. If there is a success for fatal failure in the first part, that one takes precedence. If both parts fail, the "better" error code will be returned.

hoistServer :: HasServer api ([] :: [*]) => Proxy api -> (forall x. m x -> n x) -> ServerT api m -> ServerT api n #

Hoist server implementation.

Sometimes our cherished Handler monad isn't quite the type you'd like for your handlers. Maybe you want to thread some configuration in a Reader monad. Or have your types ensure that your handlers don't do any IO. Use hoistServer (a successor of now deprecated enter).

With hoistServer, you can provide a function, to convert any number of endpoints from one type constructor to another. For example

Note: Server Raw can also be entered. It will be retagged.

>>> import Control.Monad.Reader
>>> type ReaderAPI = "ep1" :> Get '[JSON] Int :<|> "ep2" :> Get '[JSON] String :<|> Raw :<|> EmptyAPI
>>> let readerApi = Proxy :: Proxy ReaderAPI
>>> let readerServer = return 1797 :<|> ask :<|> Tagged (error "raw server") :<|> emptyServer :: ServerT ReaderAPI (Reader String)
>>> let nt x = return (runReader x "hi")
>>> let mainServer = hoistServer readerApi nt readerServer :: Server ReaderAPI

serveWithContext :: HasServer api context => Proxy api -> Context context -> Server api -> Application #

serve :: HasServer api ([] :: [*]) => Proxy api -> Server api -> Application #

serve allows you to implement an API and produce a wai Application.

Example:

type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
        :<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books

server :: Server MyApi
server = listAllBooks :<|> postBook
  where listAllBooks = ...
        postBook book = ...

myApi :: Proxy MyApi
myApi = Proxy

app :: Application
app = serve myApi server

main :: IO ()
main = Network.Wai.Handler.Warp.run 8080 app

class HasServer (api :: k) (context :: [*]) where #

Minimal complete definition

route, hoistServerWithContext

Associated Types

type ServerT (api :: k) (m :: * -> *) :: * #

Methods

route :: Proxy api -> Context context -> Delayed env (Server api) -> Router env #

hoistServerWithContext :: Proxy api -> Proxy context -> (forall x. m x -> n x) -> ServerT api m -> ServerT api n #

Instances
HasServer Raw context

Just pass the request to the underlying application and serve its response.

Example:

type MyApi = "images" :> Raw

server :: Server MyApi
server = serveDirectory "/var/www/images"
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT Raw m :: * #

Methods

route :: Proxy Raw -> Context context -> Delayed env (Server Raw) -> Router env #

hoistServerWithContext :: Proxy Raw -> Proxy context -> (forall x. m x -> n x) -> ServerT Raw m -> ServerT Raw n #

HasServer EmptyAPI context

The server for an EmptyAPI is emptyAPIServer.

type MyApi = "nothing" :> EmptyApi

server :: Server MyApi
server = emptyAPIServer
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT EmptyAPI m :: * #

Methods

route :: Proxy EmptyAPI -> Context context -> Delayed env (Server EmptyAPI) -> Router env #

hoistServerWithContext :: Proxy EmptyAPI -> Proxy context -> (forall x. m x -> n x) -> ServerT EmptyAPI m -> ServerT EmptyAPI n #

(TypeError (HasServerArrowTypeError a b) :: Constraint) => HasServer (a -> b :: *) context

This instance prevents from accidentally using '->' instead of :>

>>> serve (Proxy :: Proxy (Capture "foo" Int -> Get '[JSON] Int)) (error "...")
...
...No instance HasServer (a -> b).
...Maybe you have used '->' instead of ':>' between
...Capture' '[] "foo" Int
...and
...Verb 'GET 200 '[JSON] Int
...
>>> undefined :: Server (Capture "foo" Int -> Get '[JSON] Int)
...
...No instance HasServer (a -> b).
...Maybe you have used '->' instead of ':>' between
...Capture' '[] "foo" Int
...and
...Verb 'GET 200 '[JSON] Int
...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (a -> b) m :: * #

Methods

route :: Proxy (a -> b) -> Context context -> Delayed env (Server (a -> b)) -> Router env #

hoistServerWithContext :: Proxy (a -> b) -> Proxy context -> (forall x. m x -> n x) -> ServerT (a -> b) m -> ServerT (a -> b) n #

(HasServer a context, HasServer b context) => HasServer (a :<|> b :: *) context

A server for a :<|> b first tries to match the request against the route represented by a and if it fails tries b. You must provide a request handler for each route.

type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
        :<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books

server :: Server MyApi
server = listAllBooks :<|> postBook
  where listAllBooks = ...
        postBook book = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (a :<|> b) m :: * #

Methods

route :: Proxy (a :<|> b) -> Context context -> Delayed env (Server (a :<|> b)) -> Router env #

hoistServerWithContext :: Proxy (a :<|> b) -> Proxy context -> (forall x. m x -> n x) -> ServerT (a :<|> b) m -> ServerT (a :<|> b) n #

(HasContextEntry context (NamedContext name subContext), HasServer subApi subContext) => HasServer (WithNamedContext name subContext subApi :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (WithNamedContext name subContext subApi) m :: * #

Methods

route :: Proxy (WithNamedContext name subContext subApi) -> Context context -> Delayed env (Server (WithNamedContext name subContext subApi)) -> Router env #

hoistServerWithContext :: Proxy (WithNamedContext name subContext subApi) -> Proxy context -> (forall x. m x -> n x) -> ServerT (WithNamedContext name subContext subApi) m -> ServerT (WithNamedContext name subContext subApi) n #

(TypeError (HasServerArrowKindError arr) :: Constraint) => HasServer (arr :> api :: *) context

This instance catches mistakes when there are non-saturated type applications on LHS of :>.

>>> serve (Proxy :: Proxy (Capture "foo" :> Get '[JSON] Int)) (error "...")
...
...Expected something of kind Symbol or *, got: k -> l on the LHS of ':>'.
...Maybe you haven't applied enough arguments to
...Capture' '[] "foo"
...
>>> undefined :: Server (Capture "foo" :> Get '[JSON] Int)
...
...Expected something of kind Symbol or *, got: k -> l on the LHS of ':>'.
...Maybe you haven't applied enough arguments to
...Capture' '[] "foo"
...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (arr :> api) m :: * #

Methods

route :: Proxy (arr :> api) -> Context context -> Delayed env (Server (arr :> api)) -> Router env #

hoistServerWithContext :: Proxy (arr :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (arr :> api) m -> ServerT (arr :> api) n #

HasServer api context => HasServer (HttpVersion :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (HttpVersion :> api) m :: * #

Methods

route :: Proxy (HttpVersion :> api) -> Context context -> Delayed env (Server (HttpVersion :> api)) -> Router env #

hoistServerWithContext :: Proxy (HttpVersion :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (HttpVersion :> api) m -> ServerT (HttpVersion :> api) n #

(AllCTUnrender list a, HasServer api context, SBoolI (FoldLenient mods)) => HasServer (ReqBody' mods list a :> api :: *) context

If you use ReqBody in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by ReqBody. The Content-Type header is inspected, and the list provided is used to attempt deserialization. If the request does not have a Content-Type header, it is treated as application/octet-stream (as specified in RFC7231. This lets servant worry about extracting it from the request and turning it into a value of the type you specify.

All it asks is for a FromJSON instance.

Example:

type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book

server :: Server MyApi
server = postBook
  where postBook :: Book -> Handler Book
        postBook book = ...insert into your db...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (ReqBody' mods list a :> api) m :: * #

Methods

route :: Proxy (ReqBody' mods list a :> api) -> Context context -> Delayed env (Server (ReqBody' mods list a :> api)) -> Router env #

hoistServerWithContext :: Proxy (ReqBody' mods list a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (ReqBody' mods list a :> api) m -> ServerT (ReqBody' mods list a :> api) n #

HasServer api context => HasServer (RemoteHost :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (RemoteHost :> api) m :: * #

Methods

route :: Proxy (RemoteHost :> api) -> Context context -> Delayed env (Server (RemoteHost :> api)) -> Router env #

hoistServerWithContext :: Proxy (RemoteHost :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (RemoteHost :> api) m -> ServerT (RemoteHost :> api) n #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (QueryParam' mods sym a :> api :: *) context

If you use QueryParam "author" Text in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type Maybe Text.

This lets servant worry about looking it up in the query string and turning it into a value of the type you specify, enclosed in Maybe, because it may not be there and servant would then hand you Nothing.

You can control how it'll be converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "books" :> QueryParam "author" Text :> Get '[JSON] [Book]

server :: Server MyApi
server = getBooksBy
  where getBooksBy :: Maybe Text -> Handler [Book]
        getBooksBy Nothing       = ...return all books...
        getBooksBy (Just author) = ...return books by the given author...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParam' mods sym a :> api) m :: * #

Methods

route :: Proxy (QueryParam' mods sym a :> api) -> Context context -> Delayed env (Server (QueryParam' mods sym a :> api)) -> Router env #

hoistServerWithContext :: Proxy (QueryParam' mods sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryParam' mods sym a :> api) m -> ServerT (QueryParam' mods sym a :> api) n #

(KnownSymbol sym, FromHttpApiData a, HasServer api context) => HasServer (QueryParams sym a :> api :: *) context

If you use QueryParams "authors" Text in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type [Text].

This lets servant worry about looking up 0 or more values in the query string associated to authors and turning each of them into a value of the type you specify.

You can control how the individual values are converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "books" :> QueryParams "authors" Text :> Get '[JSON] [Book]

server :: Server MyApi
server = getBooksBy
  where getBooksBy :: [Text] -> Handler [Book]
        getBooksBy authors = ...return all books by these authors...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParams sym a :> api) m :: * #

Methods

route :: Proxy (QueryParams sym a :> api) -> Context context -> Delayed env (Server (QueryParams sym a :> api)) -> Router env #

hoistServerWithContext :: Proxy (QueryParams sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryParams sym a :> api) m -> ServerT (QueryParams sym a :> api) n #

(KnownSymbol sym, HasServer api context) => HasServer (QueryFlag sym :> api :: *) context

If you use QueryFlag "published" in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type Bool.

Example:

type MyApi = "books" :> QueryFlag "published" :> Get '[JSON] [Book]

server :: Server MyApi
server = getBooks
  where getBooks :: Bool -> Handler [Book]
        getBooks onlyPublished = ...return all books, or only the ones that are already published, depending on the argument...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryFlag sym :> api) m :: * #

Methods

route :: Proxy (QueryFlag sym :> api) -> Context context -> Delayed env (Server (QueryFlag sym :> api)) -> Router env #

hoistServerWithContext :: Proxy (QueryFlag sym :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryFlag sym :> api) m -> ServerT (QueryFlag sym :> api) n #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (Header' mods sym a :> api :: *) context

If you use Header in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by Header. This lets servant worry about extracting it from the request and turning it into a value of the type you specify.

All it asks is for a FromHttpApiData instance.

Example:

newtype Referer = Referer Text
  deriving (Eq, Show, FromHttpApiData)

           -- GET /view-my-referer
type MyApi = "view-my-referer" :> Header "Referer" Referer :> Get '[JSON] Referer

server :: Server MyApi
server = viewReferer
  where viewReferer :: Referer -> Handler referer
        viewReferer referer = return referer
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Header' mods sym a :> api) m :: * #

Methods

route :: Proxy (Header' mods sym a :> api) -> Context context -> Delayed env (Server (Header' mods sym a :> api)) -> Router env #

hoistServerWithContext :: Proxy (Header' mods sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Header' mods sym a :> api) m -> ServerT (Header' mods sym a :> api) n #

HasServer api context => HasServer (IsSecure :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (IsSecure :> api) m :: * #

Methods

route :: Proxy (IsSecure :> api) -> Context context -> Delayed env (Server (IsSecure :> api)) -> Router env #

hoistServerWithContext :: Proxy (IsSecure :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (IsSecure :> api) m -> ServerT (IsSecure :> api) n #

HasServer api ctx => HasServer (Summary desc :> api :: *) ctx

Ignore Summary in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Summary desc :> api) m :: * #

Methods

route :: Proxy (Summary desc :> api) -> Context ctx -> Delayed env (Server (Summary desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Summary desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Summary desc :> api) m -> ServerT (Summary desc :> api) n #

HasServer api ctx => HasServer (Description desc :> api :: *) ctx

Ignore Description in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Description desc :> api) m :: * #

Methods

route :: Proxy (Description desc :> api) -> Context ctx -> Delayed env (Server (Description desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Description desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Description desc :> api) m -> ServerT (Description desc :> api) n #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (Capture' mods capture a :> api :: *) context

If you use Capture in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by the Capture. This lets servant worry about getting it from the URL and turning it into a value of the type you specify.

You can control how it'll be converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book

server :: Server MyApi
server = getBook
  where getBook :: Text -> Handler Book
        getBook isbn = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Capture' mods capture a :> api) m :: * #

Methods

route :: Proxy (Capture' mods capture a :> api) -> Context context -> Delayed env (Server (Capture' mods capture a :> api)) -> Router env #

hoistServerWithContext :: Proxy (Capture' mods capture a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Capture' mods capture a :> api) m -> ServerT (Capture' mods capture a :> api) n #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (CaptureAll capture a :> api :: *) context

If you use CaptureAll in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of a list of the type specified by the CaptureAll. This lets servant worry about getting values from the URL and turning them into values of the type you specify.

You can control how they'll be converted from Text to your type by simply providing an instance of FromHttpApiData for your type.

Example:

type MyApi = "src" :> CaptureAll "segments" Text :> Get '[JSON] SourceFile

server :: Server MyApi
server = getSourceFile
  where getSourceFile :: [Text] -> Handler Book
        getSourceFile pathSegments = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (CaptureAll capture a :> api) m :: * #

Methods

route :: Proxy (CaptureAll capture a :> api) -> Context context -> Delayed env (Server (CaptureAll capture a :> api)) -> Router env #

hoistServerWithContext :: Proxy (CaptureAll capture a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (CaptureAll capture a :> api) m -> ServerT (CaptureAll capture a :> api) n #

(KnownSymbol realm, HasServer api context, HasContextEntry context (BasicAuthCheck usr)) => HasServer (BasicAuth realm usr :> api :: *) context

Basic Authentication

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (BasicAuth realm usr :> api) m :: * #

Methods

route :: Proxy (BasicAuth realm usr :> api) -> Context context -> Delayed env (Server (BasicAuth realm usr :> api)) -> Router env #

hoistServerWithContext :: Proxy (BasicAuth realm usr :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (BasicAuth realm usr :> api) m -> ServerT (BasicAuth realm usr :> api) n #

HasServer api context => HasServer (Vault :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Vault :> api) m :: * #

Methods

route :: Proxy (Vault :> api) -> Context context -> Delayed env (Server (Vault :> api)) -> Router env #

hoistServerWithContext :: Proxy (Vault :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Vault :> api) m -> ServerT (Vault :> api) n #

(KnownSymbol path, HasServer api context) => HasServer (path :> api :: *) context

Make sure the incoming request starts with "/path", strip it and pass the rest of the request path to api.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (path :> api) m :: * #

Methods

route :: Proxy (path :> api) -> Context context -> Delayed env (Server (path :> api)) -> Router env #

hoistServerWithContext :: Proxy (path :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (path :> api) m -> ServerT (path :> api) n #

(AllCTRender ctypes a, ReflectMethod method, KnownNat status) => HasServer (Verb method status ctypes a :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Verb method status ctypes a) m :: * #

Methods

route :: Proxy (Verb method status ctypes a) -> Context context -> Delayed env (Server (Verb method status ctypes a)) -> Router env #

hoistServerWithContext :: Proxy (Verb method status ctypes a) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Verb method status ctypes a) m -> ServerT (Verb method status ctypes a) n #

(AllCTRender ctypes a, ReflectMethod method, KnownNat status, GetHeaders (Headers h a)) => HasServer (Verb method status ctypes (Headers h a) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Verb method status ctypes (Headers h a)) m :: * #

Methods

route :: Proxy (Verb method status ctypes (Headers h a)) -> Context context -> Delayed env (Server (Verb method status ctypes (Headers h a))) -> Router env #

hoistServerWithContext :: Proxy (Verb method status ctypes (Headers h a)) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Verb method status ctypes (Headers h a)) m -> ServerT (Verb method status ctypes (Headers h a)) n #

(MimeRender ctype a, ReflectMethod method, KnownNat status, FramingRender framing ctype, ToStreamGenerator b a) => HasServer (Stream method status framing ctype b :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Stream method status framing ctype b) m :: * #

Methods

route :: Proxy (Stream method status framing ctype b) -> Context context -> Delayed env (Server (Stream method status framing ctype b)) -> Router env #

hoistServerWithContext :: Proxy (Stream method status framing ctype b) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Stream method status framing ctype b) m -> ServerT (Stream method status framing ctype b) n #

(MimeRender ctype a, ReflectMethod method, KnownNat status, FramingRender framing ctype, ToStreamGenerator b a, GetHeaders (Headers h b)) => HasServer (Stream method status framing ctype (Headers h b) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Stream method status framing ctype (Headers h b)) m :: * #

Methods

route :: Proxy (Stream method status framing ctype (Headers h b)) -> Context context -> Delayed env (Server (Stream method status framing ctype (Headers h b))) -> Router env #

hoistServerWithContext :: Proxy (Stream method status framing ctype (Headers h b)) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Stream method status framing ctype (Headers h b)) m -> ServerT (Stream method status framing ctype (Headers h b)) n #

type Server (api :: k) = ServerT api Handler #

data BasicAuthResult usr #

servant-server's current implementation of basic authentication is not immune to certian kinds of timing attacks. Decoding payloads does not take a fixed amount of time.

The result of authentication/authorization

Instances
Functor BasicAuthResult 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Methods

fmap :: (a -> b) -> BasicAuthResult a -> BasicAuthResult b #

(<$) :: a -> BasicAuthResult b -> BasicAuthResult a #

Eq usr => Eq (BasicAuthResult usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Read usr => Read (BasicAuthResult usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Show usr => Show (BasicAuthResult usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Generic (BasicAuthResult usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Associated Types

type Rep (BasicAuthResult usr) :: * -> * #

Methods

from :: BasicAuthResult usr -> Rep (BasicAuthResult usr) x #

to :: Rep (BasicAuthResult usr) x -> BasicAuthResult usr #

type Rep (BasicAuthResult usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

type Rep (BasicAuthResult usr) = D1 (MetaData "BasicAuthResult" "Servant.Server.Internal.BasicAuth" "servant-server-0.14.1-8QeZlk3HyJYB7GKYC8rKfC" False) ((C1 (MetaCons "Unauthorized" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "BadPassword" PrefixI False) (U1 :: * -> *)) :+: (C1 (MetaCons "NoSuchUser" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "Authorized" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 usr))))

newtype BasicAuthCheck usr #

Datatype wrapping a function used to check authentication.

Instances
Functor BasicAuthCheck 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Methods

fmap :: (a -> b) -> BasicAuthCheck a -> BasicAuthCheck b #

(<$) :: a -> BasicAuthCheck b -> BasicAuthCheck a #

Generic (BasicAuthCheck usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Associated Types

type Rep (BasicAuthCheck usr) :: * -> * #

Methods

from :: BasicAuthCheck usr -> Rep (BasicAuthCheck usr) x #

to :: Rep (BasicAuthCheck usr) x -> BasicAuthCheck usr #

type Rep (BasicAuthCheck usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

type Rep (BasicAuthCheck usr) = D1 (MetaData "BasicAuthCheck" "Servant.Server.Internal.BasicAuth" "servant-server-0.14.1-8QeZlk3HyJYB7GKYC8rKfC" True) (C1 (MetaCons "BasicAuthCheck" PrefixI True) (S1 (MetaSel (Just "unBasicAuthCheck") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (BasicAuthData -> IO (BasicAuthResult usr)))))

tweakResponse :: (RouteResult Response -> RouteResult Response) -> Router env -> Router env #

Apply a transformation to the response of a Router.

err505 :: ServantErr #

err505 HTTP Version not supported

Example usage:

failingHandler :: Handler ()
failingHandler = throwError $ err505 { errBody = "I support HTTP/4.0 only." }

err504 :: ServantErr #

err504 Gateway Time-out

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err504 { errBody = "Backend foobar did not respond in 5 seconds." }

err503 :: ServantErr #

err503 Service Unavailable

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err503 { errBody = "We're rewriting in PHP." }

err502 :: ServantErr #

err502 Bad Gateway

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err502 { errBody = "Tried gateway foo, bar, and baz.  None responded." }

err501 :: ServantErr #

err501 Not Implemented

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err501 { errBody = "/v1/foo is not supported with quux in the request." }

err500 :: ServantErr #

err500 Internal Server Error

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err500 { errBody = "Exception in module A.B.C:55.  Have a great day!" }

err422 :: ServantErr #

err422 Unprocessable Entity

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err422 { errBody = "I understood your request, but can't process it." }

err418 :: ServantErr #

err418 Expectation Failed

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err418 { errBody = "Apologies, this is not a webserver but a teapot." }

err417 :: ServantErr #

err417 Expectation Failed

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err417 { errBody = "I found a quux in the request.  This isn't going to work." }

err416 :: ServantErr #

err416 Request range not satisfiable

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err416 { errBody = "Valid range is [0, 424242]." }

err415 :: ServantErr #

err415 Unsupported Media Type

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err415 { errBody = "Supported media types:  gif, png" }

err414 :: ServantErr #

err414 Request-URI Too Large

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err414 { errBody = "Maximum length is 64." }

err413 :: ServantErr #

err413 Request Entity Too Large

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err413 { errBody = "Request exceeded 64k." }

err412 :: ServantErr #

err412 Precondition Failed

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err412 { errBody = "Precondition fail: x < 42 && y > 57" }

err411 :: ServantErr #

err411 Length Required

Example:

failingHandler :: Handler ()
failingHandler = throwError err411

err410 :: ServantErr #

err410 Gone

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err410 { errBody = "I know it was here at some point, but.. I blame bad luck." }

err409 :: ServantErr #

err409 Conflict

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err409 { errBody = "Transaction conflicts with 59879cb56c7c159231eeacdd503d755f7e835f74" }

err407 :: ServantErr #

err407 Proxy Authentication Required

Example:

failingHandler :: Handler ()
failingHandler = throwError err407

err406 :: ServantErr #

err406 Not Acceptable

Example:

failingHandler :: Handler ()
failingHandler = throwError err406

err405 :: ServantErr #

err405 Method Not Allowed

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err405 { errBody = "Your account privileges does not allow for this.  Please pay $$$." }

err404 :: ServantErr #

err404 Not Found

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err404 { errBody = "(╯°□°)╯︵ ┻━┻)." }

err403 :: ServantErr #

err403 Forbidden

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err403 { errBody = "Please login first." }

err402 :: ServantErr #

err402 Payment Required

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err402 { errBody = "You have 0 credits. Please give me $$$." }

err401 :: ServantErr #

err401 Unauthorized

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err401 { errBody = "Your credentials are invalid." }

err400 :: ServantErr #

err400 Bad Request

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err400 { errBody = "Your request makes no sense to me." }

err307 :: ServantErr #

err307 Temporary Redirect

Example:

failingHandler :: Handler ()
failingHandler = throwError err307

err305 :: ServantErr #

err305 Use Proxy

Example:

failingHandler :: Handler ()
failingHandler = throwError err305

err304 :: ServantErr #

err304 Not Modified

Example:

failingHandler :: Handler ()
failingHandler = throwError err304

err303 :: ServantErr #

err303 See Other

Example:

failingHandler :: Handler ()
failingHandler = throwError err303

err302 :: ServantErr #

err302 Found

Example:

failingHandler :: Handler ()
failingHandler = throwError err302

err301 :: ServantErr #

err301 Moved Permanently

Example:

failingHandler :: Handler ()
failingHandler = throwError err301

err300 :: ServantErr #

err300 Multiple Choices

Example:

failingHandler :: Handler ()
failingHandler = throwError $ err300 { errBody = "I can't choose." }

descendIntoNamedContext :: HasContextEntry context (NamedContext name subContext) => Proxy name -> Context context -> Context subContext #

descendIntoNamedContext allows you to access NamedContexts. Usually you won't have to use it yourself but instead use a combinator like WithNamedContext.

This is how descendIntoNamedContext works:

>>> :set -XFlexibleContexts
>>> let subContext = True :. EmptyContext
>>> :type subContext
subContext :: Context '[Bool]
>>> let parentContext = False :. (NamedContext subContext :: NamedContext "subContext" '[Bool]) :. EmptyContext
>>> :type parentContext
parentContext :: Context '[Bool, NamedContext "subContext" '[Bool]]
>>> descendIntoNamedContext (Proxy :: Proxy "subContext") parentContext :: Context '[Bool]
True :. EmptyContext

data Context (contextTypes :: [*]) where #

Contexts are used to pass values to combinators. (They are not meant to be used to pass parameters to your handlers, i.e. they should not replace any custom ReaderT-monad-stack that you're using with hoistServer.) If you don't use combinators that require any context entries, you can just use serve as always.

If you are using combinators that require a non-empty Context you have to use serveWithContext and pass it a Context that contains all the values your combinators need. A Context is essentially a heterogenous list and accessing the elements is being done by type (see getContextEntry). The parameter of the type Context is a type-level list reflecting the types of the contained context entries. To create a Context with entries, use the operator (:.):

>>> :type True :. () :. EmptyContext
True :. () :. EmptyContext :: Context '[Bool, ()]

Constructors

EmptyContext :: Context ([] :: [*]) 
(:.) :: Context (x ': xs) infixr 5 
Instances
(Eq a, Eq (Context as)) => Eq (Context (a ': as)) 
Instance details

Defined in Servant.Server.Internal.Context

Methods

(==) :: Context (a ': as) -> Context (a ': as) -> Bool #

(/=) :: Context (a ': as) -> Context (a ': as) -> Bool #

Eq (Context ([] :: [*])) 
Instance details

Defined in Servant.Server.Internal.Context

Methods

(==) :: Context [] -> Context [] -> Bool #

(/=) :: Context [] -> Context [] -> Bool #

(Show a, Show (Context as)) => Show (Context (a ': as)) 
Instance details

Defined in Servant.Server.Internal.Context

Methods

showsPrec :: Int -> Context (a ': as) -> ShowS #

show :: Context (a ': as) -> String #

showList :: [Context (a ': as)] -> ShowS #

Show (Context ([] :: [*])) 
Instance details

Defined in Servant.Server.Internal.Context

Methods

showsPrec :: Int -> Context [] -> ShowS #

show :: Context [] -> String #

showList :: [Context []] -> ShowS #

class HasContextEntry (context :: [*]) val where #

This class is used to access context entries in Contexts. getContextEntry returns the first value where the type matches:

>>> getContextEntry (True :. False :. EmptyContext) :: Bool
True

If the Context does not contain an entry of the requested type, you'll get an error:

>>> getContextEntry (True :. False :. EmptyContext) :: String
...
...No instance for (HasContextEntry '[] [Char])
...

Minimal complete definition

getContextEntry

Methods

getContextEntry :: Context context -> val #

Instances
HasContextEntry xs val => HasContextEntry (notIt ': xs) val 
Instance details

Defined in Servant.Server.Internal.Context

Methods

getContextEntry :: Context (notIt ': xs) -> val #

HasContextEntry (val ': xs) val 
Instance details

Defined in Servant.Server.Internal.Context

Methods

getContextEntry :: Context (val ': xs) -> val #

data NamedContext (name :: Symbol) (subContext :: [*]) #

Normally context entries are accessed by their types. In case you need to have multiple values of the same type in your Context and need to access them, we provide NamedContext. You can think of it as sub-namespaces for Contexts.

Constructors

NamedContext (Context subContext) 

type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived #

The WAI application.

Note that, since WAI 3.0, this type is structured in continuation passing style to allow for proper safe resource handling. This was handled in the past via other means (e.g., ResourceT). As a demonstration:

app :: Application
app req respond = bracket_
    (putStrLn "Allocating scarce resource")
    (putStrLn "Cleaning up")
    (respond $ responseLBS status200 [] "Hello World")

newtype Tagged (s :: k) b :: forall k. k -> * -> * #

A Tagged s b value is a value b with an attached phantom type s. This can be used in place of the more traditional but less safe idiom of passing in an undefined value with the type, because unlike an (s -> b), a Tagged s b can't try to use the argument s as a real value.

Moreover, you don't have to rely on the compiler to inline away the extra argument, because the newtype is "free"

Tagged has kind k -> * -> * if the compiler supports PolyKinds, therefore there is an extra k showing in the instance haddocks that may cause confusion.

Constructors

Tagged 

Fields

Instances
ToJSON2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> Tagged a b -> Value #

liftToJSONList2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [Tagged a b] -> Value #

liftToEncoding2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> Tagged a b -> Encoding #

liftToEncodingList2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [Tagged a b] -> Encoding #

FromJSON2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (Tagged a b) #

liftParseJSONList2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [Tagged a b] #

Bitraversable (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Tagged a b -> f (Tagged c d) #

Bifoldable (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

bifold :: Monoid m => Tagged m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Tagged a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Tagged a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Tagged a b -> c #

Bifunctor (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

bimap :: (a -> b) -> (c -> d) -> Tagged a c -> Tagged b d #

first :: (a -> b) -> Tagged a c -> Tagged b c #

second :: (b -> c) -> Tagged a b -> Tagged a c #

Eq2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Tagged a c -> Tagged b d -> Bool #

Ord2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Tagged a c -> Tagged b d -> Ordering #

Read2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Tagged a b) #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Tagged a b] #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Tagged a b) #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Tagged a b] #

Show2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Tagged a b -> ShowS #

liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Tagged a b] -> ShowS #

Generic1 (Tagged s :: * -> *) 
Instance details

Defined in Data.Tagged

Associated Types

type Rep1 (Tagged s) :: k -> * #

Methods

from1 :: Tagged s a -> Rep1 (Tagged s) a #

to1 :: Rep1 (Tagged s) a -> Tagged s a #

Monad (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

(>>=) :: Tagged s a -> (a -> Tagged s b) -> Tagged s b #

(>>) :: Tagged s a -> Tagged s b -> Tagged s b #

return :: a -> Tagged s a #

fail :: String -> Tagged s a #

Functor (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

fmap :: (a -> b) -> Tagged s a -> Tagged s b #

(<$) :: a -> Tagged s b -> Tagged s a #

Applicative (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

pure :: a -> Tagged s a #

(<*>) :: Tagged s (a -> b) -> Tagged s a -> Tagged s b #

liftA2 :: (a -> b -> c) -> Tagged s a -> Tagged s b -> Tagged s c #

(*>) :: Tagged s a -> Tagged s b -> Tagged s b #

(<*) :: Tagged s a -> Tagged s b -> Tagged s a #

Foldable (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

fold :: Monoid m => Tagged s m -> m #

foldMap :: Monoid m => (a -> m) -> Tagged s a -> m #

foldr :: (a -> b -> b) -> b -> Tagged s a -> b #

foldr' :: (a -> b -> b) -> b -> Tagged s a -> b #

foldl :: (b -> a -> b) -> b -> Tagged s a -> b #

foldl' :: (b -> a -> b) -> b -> Tagged s a -> b #

foldr1 :: (a -> a -> a) -> Tagged s a -> a #

foldl1 :: (a -> a -> a) -> Tagged s a -> a #

toList :: Tagged s a -> [a] #

null :: Tagged s a -> Bool #

length :: Tagged s a -> Int #

elem :: Eq a => a -> Tagged s a -> Bool #

maximum :: Ord a => Tagged s a -> a #

minimum :: Ord a => Tagged s a -> a #

sum :: Num a => Tagged s a -> a #

product :: Num a => Tagged s a -> a #

Traversable (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

traverse :: Applicative f => (a -> f b) -> Tagged s a -> f (Tagged s b) #

sequenceA :: Applicative f => Tagged s (f a) -> f (Tagged s a) #

mapM :: Monad m => (a -> m b) -> Tagged s a -> m (Tagged s b) #

sequence :: Monad m => Tagged s (m a) -> m (Tagged s a) #

ToJSON1 (Tagged a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> Tagged a a0 -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [Tagged a a0] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> Tagged a a0 -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [Tagged a a0] -> Encoding #

FromJSON1 (Tagged a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (Tagged a a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [Tagged a a0] #

Eq1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftEq :: (a -> b -> Bool) -> Tagged s a -> Tagged s b -> Bool #

Ord1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftCompare :: (a -> b -> Ordering) -> Tagged s a -> Tagged s b -> Ordering #

Read1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Tagged s a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Tagged s a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Tagged s a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Tagged s a] #

Show1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Tagged s a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Tagged s a] -> ShowS #

Bounded b => Bounded (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

minBound :: Tagged s b #

maxBound :: Tagged s b #

Enum a => Enum (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

succ :: Tagged s a -> Tagged s a #

pred :: Tagged s a -> Tagged s a #

toEnum :: Int -> Tagged s a #

fromEnum :: Tagged s a -> Int #

enumFrom :: Tagged s a -> [Tagged s a] #

enumFromThen :: Tagged s a -> Tagged s a -> [Tagged s a] #

enumFromTo :: Tagged s a -> Tagged s a -> [Tagged s a] #

enumFromThenTo :: Tagged s a -> Tagged s a -> Tagged s a -> [Tagged s a] #

Eq b => Eq (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

(==) :: Tagged s b -> Tagged s b -> Bool #

(/=) :: Tagged s b -> Tagged s b -> Bool #

Floating a => Floating (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

pi :: Tagged s a #

exp :: Tagged s a -> Tagged s a #

log :: Tagged s a -> Tagged s a #

sqrt :: Tagged s a -> Tagged s a #

(**) :: Tagged s a -> Tagged s a -> Tagged s a #

logBase :: Tagged s a -> Tagged s a -> Tagged s a #

sin :: Tagged s a -> Tagged s a #

cos :: Tagged s a -> Tagged s a #

tan :: Tagged s a -> Tagged s a #

asin :: Tagged s a -> Tagged s a #

acos :: Tagged s a -> Tagged s a #

atan :: Tagged s a -> Tagged s a #

sinh :: Tagged s a -> Tagged s a #

cosh :: Tagged s a -> Tagged s a #

tanh :: Tagged s a -> Tagged s a #

asinh :: Tagged s a -> Tagged s a #

acosh :: Tagged s a -> Tagged s a #

atanh :: Tagged s a -> Tagged s a #

log1p :: Tagged s a -> Tagged s a #

expm1 :: Tagged s a -> Tagged s a #

log1pexp :: Tagged s a -> Tagged s a #

log1mexp :: Tagged s a -> Tagged s a #

Fractional a => Fractional (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

(/) :: Tagged s a -> Tagged s a -> Tagged s a #

recip :: Tagged s a -> Tagged s a #

fromRational :: Rational -> Tagged s a #

Integral a => Integral (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

quot :: Tagged s a -> Tagged s a -> Tagged s a #

rem :: Tagged s a -> Tagged s a -> Tagged s a #

div :: Tagged s a -> Tagged s a -> Tagged s a #

mod :: Tagged s a -> Tagged s a -> Tagged s a #

quotRem :: Tagged s a -> Tagged s a -> (Tagged s a, Tagged s a) #

divMod :: Tagged s a -> Tagged s a -> (Tagged s a, Tagged s a) #

toInteger :: Tagged s a -> Integer #

(Data s, Data b) => Data (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Tagged s b -> c (Tagged s b) #

gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Tagged s b) #

toConstr :: Tagged s b -> Constr #

dataTypeOf :: Tagged s b -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Tagged s b)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tagged s b)) #

gmapT :: (forall b0. Data b0 => b0 -> b0) -> Tagged s b -> Tagged s b #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tagged s b -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tagged s b -> r #

gmapQ :: (forall d. Data d => d -> u) -> Tagged s b -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Tagged s b -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) #

Num a => Num (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

(+) :: Tagged s a -> Tagged s a -> Tagged s a #

(-) :: Tagged s a -> Tagged s a -> Tagged s a #

(*) :: Tagged s a -> Tagged s a -> Tagged s a #

negate :: Tagged s a -> Tagged s a #

abs :: Tagged s a -> Tagged s a #

signum :: Tagged s a -> Tagged s a #

fromInteger :: Integer -> Tagged s a #

Ord b => Ord (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

compare :: Tagged s b -> Tagged s b -> Ordering #

(<) :: Tagged s b -> Tagged s b -> Bool #

(<=) :: Tagged s b -> Tagged s b -> Bool #

(>) :: Tagged s b -> Tagged s b -> Bool #

(>=) :: Tagged s b -> Tagged s b -> Bool #

max :: Tagged s b -> Tagged s b -> Tagged s b #

min :: Tagged s b -> Tagged s b -> Tagged s b #

Read b => Read (Tagged s b) 
Instance details

Defined in Data.Tagged

Real a => Real (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

toRational :: Tagged s a -> Rational #

RealFloat a => RealFloat (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

floatRadix :: Tagged s a -> Integer #

floatDigits :: Tagged s a -> Int #

floatRange :: Tagged s a -> (Int, Int) #

decodeFloat :: Tagged s a -> (Integer, Int) #

encodeFloat :: Integer -> Int -> Tagged s a #

exponent :: Tagged s a -> Int #

significand :: Tagged s a -> Tagged s a #

scaleFloat :: Int -> Tagged s a -> Tagged s a #

isNaN :: Tagged s a -> Bool #

isInfinite :: Tagged s a -> Bool #

isDenormalized :: Tagged s a -> Bool #

isNegativeZero :: Tagged s a -> Bool #

isIEEE :: Tagged s a -> Bool #

atan2 :: Tagged s a -> Tagged s a -> Tagged s a #

RealFrac a => RealFrac (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

properFraction :: Integral b => Tagged s a -> (b, Tagged s a) #

truncate :: Integral b => Tagged s a -> b #

round :: Integral b => Tagged s a -> b #

ceiling :: Integral b => Tagged s a -> b #

floor :: Integral b => Tagged s a -> b #

Show b => Show (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

showsPrec :: Int -> Tagged s b -> ShowS #

show :: Tagged s b -> String #

showList :: [Tagged s b] -> ShowS #

Ix b => Ix (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

range :: (Tagged s b, Tagged s b) -> [Tagged s b] #

index :: (Tagged s b, Tagged s b) -> Tagged s b -> Int #

unsafeIndex :: (Tagged s b, Tagged s b) -> Tagged s b -> Int

inRange :: (Tagged s b, Tagged s b) -> Tagged s b -> Bool #

rangeSize :: (Tagged s b, Tagged s b) -> Int #

unsafeRangeSize :: (Tagged s b, Tagged s b) -> Int

IsString a => IsString (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

fromString :: String -> Tagged s a #

Generic (Tagged s b) 
Instance details

Defined in Data.Tagged

Associated Types

type Rep (Tagged s b) :: * -> * #

Methods

from :: Tagged s b -> Rep (Tagged s b) x #

to :: Rep (Tagged s b) x -> Tagged s b #

Semigroup a => Semigroup (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

(<>) :: Tagged s a -> Tagged s a -> Tagged s a #

sconcat :: NonEmpty (Tagged s a) -> Tagged s a #

stimes :: Integral b => b -> Tagged s a -> Tagged s a #

(Semigroup a, Monoid a) => Monoid (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

mempty :: Tagged s a #

mappend :: Tagged s a -> Tagged s a -> Tagged s a #

mconcat :: [Tagged s a] -> Tagged s a #

ToJSON b => ToJSON (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Tagged a b -> Value #

toEncoding :: Tagged a b -> Encoding #

toJSONList :: [Tagged a b] -> Value #

toEncodingList :: [Tagged a b] -> Encoding #

ToJSONKey b => ToJSONKey (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

FromJSON b => FromJSON (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Tagged a b) #

parseJSONList :: Value -> Parser [Tagged a b] #

FromJSONKey b => FromJSONKey (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Storable a => Storable (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

sizeOf :: Tagged s a -> Int #

alignment :: Tagged s a -> Int #

peekElemOff :: Ptr (Tagged s a) -> Int -> IO (Tagged s a) #

pokeElemOff :: Ptr (Tagged s a) -> Int -> Tagged s a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Tagged s a) #

pokeByteOff :: Ptr b -> Int -> Tagged s a -> IO () #

peek :: Ptr (Tagged s a) -> IO (Tagged s a) #

poke :: Ptr (Tagged s a) -> Tagged s a -> IO () #

Bits a => Bits (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

(.&.) :: Tagged s a -> Tagged s a -> Tagged s a #

(.|.) :: Tagged s a -> Tagged s a -> Tagged s a #

xor :: Tagged s a -> Tagged s a -> Tagged s a #

complement :: Tagged s a -> Tagged s a #

shift :: Tagged s a -> Int -> Tagged s a #

rotate :: Tagged s a -> Int -> Tagged s a #

zeroBits :: Tagged s a #

bit :: Int -> Tagged s a #

setBit :: Tagged s a -> Int -> Tagged s a #

clearBit :: Tagged s a -> Int -> Tagged s a #

complementBit :: Tagged s a -> Int -> Tagged s a #

testBit :: Tagged s a -> Int -> Bool #

bitSizeMaybe :: Tagged s a -> Maybe Int #

bitSize :: Tagged s a -> Int #

isSigned :: Tagged s a -> Bool #

shiftL :: Tagged s a -> Int -> Tagged s a #

unsafeShiftL :: Tagged s a -> Int -> Tagged s a #

shiftR :: Tagged s a -> Int -> Tagged s a #

unsafeShiftR :: Tagged s a -> Int -> Tagged s a #

rotateL :: Tagged s a -> Int -> Tagged s a #

rotateR :: Tagged s a -> Int -> Tagged s a #

popCount :: Tagged s a -> Int #

FiniteBits a => FiniteBits (Tagged s a) 
Instance details

Defined in Data.Tagged

NFData b => NFData (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

rnf :: Tagged s b -> () #

type Rep1 (Tagged s :: * -> *) 
Instance details

Defined in Data.Tagged

type Rep1 (Tagged s :: * -> *) = D1 (MetaData "Tagged" "Data.Tagged" "tagged-0.8.6-8akQ1aZG2N2GFJpoB5eGXO" True) (C1 (MetaCons "Tagged" PrefixI True) (S1 (MetaSel (Just "unTagged") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))
type Rep (Tagged s b) 
Instance details

Defined in Data.Tagged

type Rep (Tagged s b) = D1 (MetaData "Tagged" "Data.Tagged" "tagged-0.8.6-8akQ1aZG2N2GFJpoB5eGXO" True) (C1 (MetaCons "Tagged" PrefixI True) (S1 (MetaSel (Just "unTagged") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 b)))

splitOn :: Eq a => [a] -> [a] -> [[a]] #

Split on the given sublist. Equivalent to split . dropDelims . onSublist. For example:

splitOn ".." "a..b...c....d.." == ["a","b",".c","","d",""]

In some parsing combinator frameworks this is also known as sepBy.

Note that this is the right inverse of the intercalate function from Data.List, that is,

intercalate x . splitOn x === id

splitOn x . intercalate x is the identity on certain lists, but it is tricky to state the precise conditions under which this holds. (For example, it is not enough to say that x does not occur in any elements of the input list. Working out why is left as an exercise for the reader.)

cs :: ConvertibleStrings a b => a -> b #

class ConvertibleStrings a b where #

Minimal complete definition

convertString

Methods

convertString :: a -> b #

Instances
ConvertibleStrings String String 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings String StrictByteString 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings String LazyByteString 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings String StrictText 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings String LazyText 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings StrictByteString String 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings StrictByteString StrictByteString 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings StrictByteString LazyByteString 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings StrictByteString StrictText 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings StrictByteString LazyText 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings LazyByteString String 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings LazyByteString StrictByteString 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings LazyByteString LazyByteString 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings LazyByteString StrictText 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings LazyByteString LazyText 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings StrictText String 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings StrictText StrictByteString 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings StrictText LazyByteString 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings StrictText StrictText 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings StrictText LazyText 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings LazyText String 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings LazyText StrictByteString 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings LazyText LazyByteString 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings LazyText StrictText 
Instance details

Defined in Data.String.Conversions

ConvertibleStrings LazyText LazyText 
Instance details

Defined in Data.String.Conversions

type ST = Text #

type LazyText = Text #

type LT = Text #

exceptToMaybeT :: Functor m => ExceptT e m a -> MaybeT m a #

Convert a ExceptT computation to MaybeT, discarding the value of any exception.

maybeToExceptT :: Functor m => e -> MaybeT m a -> ExceptT e m a #

Convert a MaybeT computation to ExceptT, with a default exception value.

mkWeakThreadId :: MonadIO m => ThreadId -> m (Weak ThreadId) #

Lifted version of mkWeakThreadId.

Since: unliftio-0.1.1.0

runInUnboundThread :: MonadUnliftIO m => m a -> m a #

Unlifted version of runInUnboundThread.

Since: unliftio-0.1.1.0

runInBoundThread :: MonadUnliftIO m => m a -> m a #

Unlifted version of runInBoundThread.

Since: unliftio-0.1.1.0

forkOS :: MonadUnliftIO m => m () -> m ThreadId #

Unflifted version of forkOS.

Since: unliftio-0.1.1.0

yield :: MonadIO m => m () #

Lifted version of yield.

Since: unliftio-0.1.1.0

threadCapability :: MonadIO m => ThreadId -> m (Int, Bool) #

Lifted version of threadCapability.

Since: unliftio-0.1.1.0

setNumCapabilities :: MonadIO m => Int -> m () #

Lifted version of setNumCapabilities.

Since: unliftio-0.1.1.0

getNumCapabilities :: MonadIO m => m Int #

Lifted version of getNumCapabilities.

Since: unliftio-0.1.1.0

forkOnWithUnmask :: MonadUnliftIO m => Int -> ((forall a. m a -> m a) -> m ()) -> m ThreadId #

Unlifted version of forkOnWithUnmask.

Since: unliftio-0.1.1.0

forkOn :: MonadUnliftIO m => Int -> m () -> m ThreadId #

Unlifted version of forkOn.

Since: unliftio-0.1.1.0

killThread :: MonadIO m => ThreadId -> m () #

Lifted version of killThread.

Since: unliftio-0.1.1.0

forkFinally :: MonadUnliftIO m => m a -> (Either SomeException a -> m ()) -> m ThreadId #

Unlifted version of forkFinally.

Since: unliftio-0.1.1.0

forkWithUnmask :: MonadUnliftIO m => ((forall a. m a -> m a) -> m ()) -> m ThreadId #

Unlifted version of forkIOWithUnmask.

Since: unliftio-0.1.1.0

forkIO :: MonadUnliftIO m => m () -> m ThreadId #

Unlifted version of forkIO.

Since: unliftio-0.1.1.0

type Middleware = Application -> Application #

Middleware is a component that sits between the server and application. It can do such tasks as GZIP encoding or response caching. What follows is the general definition of middleware, though a middleware author should feel free to modify this.

As an example of an alternate type for middleware, suppose you write a function to load up session information. The session information is simply a string map \[(String, String)\]. A logical type signature for this middleware might be:

 loadSession :: ([(String, String)] -> Application) -> Application

Here, instead of taking a standard Application as its first argument, the middleware takes a function which consumes the session information as well.

waiMain :: (WaiOptions -> IO ()) -> (WaiOptions -> IO ()) -> Application -> IO () #

metrics :: WaiMetrics -> Middleware #

Create a middleware to be added to a WAI-based webserver.

registerNamedWaiMetrics :: Text -> Store -> IO WaiMetrics #

Register in EKG a number of metrics related to web server activity with a namespace.

registerWaiMetrics :: Store -> IO WaiMetrics #

Register in EKG a number of metrics related to web server activity using empty namespace.

  • wai.request_count
  • wai.response_status_1xx
  • wai.response_status_2xx
  • wai.response_status_3xx
  • wai.response_status_4xx
  • wai.response_status_5xx
  • wai.latency_distribution

runMagicbaneHandler :: β -> RIO β α -> Handler α Source #

magicbaneApp :: forall β χ ψ. HasServer χ ψ => Proxy χ -> Context ψ -> β -> ServerT χ (RIO β) -> Application Source #

Constructs a WAI application from an API definition, a Servant context (used for auth mainly), the app context and the actual action handlers.

newLogger :: LogType -> Formatter -> IO (TimedFastLogger, ModLogger) Source #

Creates a logger module using a given formatting function. | Also returns the underlying TimedFastLogger for use outside of your Magicbane app (e.g. in some WAI middleware).

newtype ModMetrics Source #

Constructors

ModMetrics Metrics 

newMetricsWith :: Store -> IO ModMetrics Source #

Creates a metrics module with a particular Store. The Store should come from the backend you want to use for storing the metrics. For development, a simple backend that shows metrics on a web page is ekg-wai, reexported here.

type WithLink α = Headers '[Header "Link" [HTTPLink]] α Source #

type Host = Header "Host" Text Source #

hPutStrLn :: MonadIO μ => Handle -> String -> μ () Source #

mergeVal :: Value -> Value -> Value Source #

Merges two JSON objects recursively. When the values are not objects, just returns the left one.

writeForm :: (ConvertibleStrings α Text, ConvertibleStrings β Text, ConvertibleStrings ByteString γ) => [(α, β)] -> γ Source #

Encodes key-value data as application/x-www-form-urlencoded.

readForm :: (ConvertibleStrings Text α, ConvertibleStrings Text β, ConvertibleStrings γ ByteString) => γ -> Maybe [(α, β)] Source #

Decodes key-value data from application/x-www-form-urlencoded.

formList :: Form -> [(Text, Text)] Source #

Reads a Servant incoming form as a list of key-value pairs (for use in FromForm instances).

formToObject :: [(Text, Text)] -> Value Source #

Converts a flat key-value form with keys in typical nesting syntax (e.g. "one[two][three]") to an Aeson Value with nesting (for use in FromForm instances).

parseUri :: ConvertibleStrings α String => α -> URI Source #

Parses any string into a URI.

slugify :: Text -> Text Source #

Prepares text for inclusion in a URL.

>>> :set -XOverloadedStrings
>>> slugify "Hello & World!"
"hello-and-world"

errText :: ServantErr -> ByteString -> ServantErr Source #

Creates a simple text/plain ServantErr.

throwErrText :: MonadThrow μ => ServantErr -> ByteString -> μ α Source #

Creates and throws a simple text/plain ServantErr.

runHTTP :: ExceptT ε μ α -> μ (Either ε α) Source #

reqU :: MonadHTTP ψ μ => URI -> ExceptT Text μ Request Source #

Creates a request from a URI.

reqS :: (MonadHTTP ψ μ, ConvertibleStrings σ String) => σ -> ExceptT Text μ Request Source #

Creates a request from a string of any type, parsing it into a URI.

anyStatus :: MonadHTTP ψ μ => Request -> ExceptT Text μ Request Source #

Configures the request to not throw errors on error status codes.

postForm :: MonadHTTP ψ μ => [(Text, Text)] -> Request -> ExceptT Text μ Request Source #

Sets a x-www-form-urlencoded form as the request body (also sets the content-type).

postJson :: (MonadHTTP ψ μ, ToJSON α) => α -> Request -> ExceptT Text μ Request Source #

Sets a JSON value as the request body (via ToJSON; also sets the content-type).

performWithFn :: (MonadHTTP ψ μ, MonadCatch μ) => (ConduitM ι ByteString μ () -> ConduitT () Void μ ρ) -> Request -> ExceptT Text μ (Response ρ) Source #

Performs the request, using a given function to read the body. This is what all other performWith functions are based on.

performWithVoid :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> ExceptT Text μ (Response ()) Source #

Performs the request, ignoring the body.

performWithBytes :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> ExceptT Text μ (Response ByteString) Source #

Performs the request, reading the body into a lazy ByteString.

applyHeaders :: RequestHeaders -> Request -> Request Source #

Add headers to the request, preserving any existing headers not specified in the new set.

removeHeaders :: [HeaderName] -> Request -> Request Source #

Remove listed headers from the request.

askObj :: (Has β α, MonadReader α μ) => μ β Source #

Gets a value of any type from the context.

askOpt :: (Has β α, MonadReader α μ) => (β -> ψ) -> μ ψ Source #

Gets a thing from a value of any type from the context. (Useful for configuration fields.)

withEnvConfig :: FromEnv α => (α -> IO ()) -> IO () Source #

Reads an Envy configuration from the env variables and launches the given action if successful. (Does environment variable reading ever fail in practice? Probably not.)