HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

  • Packageservant-0.20.2
  • Exports103
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceModifiers.hs

Combinators

4 declarations

Type-level combinator for expressing subrouting: :>

Type-level combinator for alternative endpoints: :<|>

Type-level combinator for an empty API: EmptyAPI

datadata Lenient
#

Leniently parsed argument, i.e. parsing never fail. Wrapped in Either Text.

datadata Required
#

Required argument. Not wrapped.

datadata Strict
#

Strictly parsed argument. Not wrapped.

Type-level modifiers for QueryParam, Header and ReqBody.

Accessing information from the request

2 declarations

Capturing parts of the url path as parsed values: Capture and CaptureAll

Retrieving specific headers from the request

Retrieving the HTTP version of the request

Retrieving parameters from the query string of the URI: QueryParam

datadata QueryString
#

Extract the whole query string from a request. This is useful for query strings containing dynamic parameter names. For query strings with static parameter names, QueryParam is more suited.

Example:

Example2 expressions
-- /books?author=<author name>&year=<book year>type MyApi = "books" :> QueryString :> Get '[JSON] [Book]
datadata DeepQuery (sym :: Symbol) a
#

Extract an deep object from a query string.

Example:

Example2 expressions
-- /books?filter[author][name]=<author name>&filter[year]=<book year>type MyApi = "books" :> DeepQuery "filter" BookQuery :> Get '[JSON] [Book]

Retrieving the complete query string of the URI: QueryString

Documenting the fragment of the URI: Fragment

Accessing the request body as a JSON-encoded type: ReqBody

Retrieving the IP of the client

Is the request made through HTTPS?

Access the location for arbitrary data to be shared by applications and middleware

Access context entries in combinators in servant-server

Access a managed resource scoped to a single request

Actual endpoints, distinguished by HTTP method

40 declarations
datadata NoContentVerb (method :: k1)
#

NoContentVerb is a specific type to represent NoContent responses. It does not require either a list of content types (because there's no content) or a status code (because it should always be 204).

Instances4HasLink, Generic, Rep, MkLink
classclass ReflectMethod (a :: k) where
#

Methods

Instances9ReflectMethod, …
datadata StdMethod
#

HTTP standard method (as defined by RFC 2616, and PATCH which is defined by RFC 5789).

Instances19Bounded, Enum, Eq, Data, Ord, Read, …
datadata Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [Type]) a
#

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:

Example1 expression
type Post204 contentTypes a = Verb 'POST 204 contentTypes a
Instances5HasLink, Generic, AtMostOneFragment, Rep, MkLink
  • HasLink (Verb m s ct a)Defined in servant-0.20.2 · Servant.Links
  • Generic (Verb method statusCode contentTypes a)Defined in servant-0.20.2 · Servant.API.Verbs
  • AtMostOneFragment (Verb m s ct typ)Defined in servant-0.20.2 · Servant.API.TypeLevel
  • type Rep (Verb method statusCode contentTypes a) = D1 ('MetaData "Verb" "Servant.API.Verbs" "servant-0.20.2-kmMZib8zXn7e8NZPkSX15" 'False) V1Defined in servant-0.20.2 · Servant.API.Verbs
  • type MkLink (Verb m s ct a) r = rDefined in servant-0.20.2 · Servant.Links
datadata UVerb (method :: StdMethod) (contentTypes :: [Type]) (as :: [Type])
#

A variant of Verb that can have any of a number of response values and status codes.

FUTUREWORK: it would be nice to make Verb a special case of UVerb, and only write instances for HasServer etc. for the latter, getting them for the former for free. Something like:

type Verb method statusCode contentTypes a = UVerb method contentTypes [WithStatus statusCode a]

Backwards compatibility is tricky, though: this type alias would mean people would have to use respond instead of pure or return, so all old handlers would have to be rewritten.

Instances3HasLink, AtMostOneFragment, MkLink
classclass KnownStatus (StatusOf a) => HasStatus a where
#

Associated types

Instances3HasStatus
  • HasStatus NoContentDefined in servant-0.20.2 · Servant.API.UVerb

    If an API can respond with NoContent we assume that this will happen with the status code 204 No Content. If this needs to be overridden, WithStatus can be used.

  • KnownStatus n => HasStatus (WithStatus n a)Defined in servant-0.20.2 · Servant.API.UVerb

    an instance of this typeclass assigns a HTTP status code to a return type

    Example:

       data NotFoundError = NotFoundError String
    
       instance HasStatus NotFoundError where
         type StatusOf NotFoundError = 404
    

    You can also use the convience newtype wrapper WithStatus if you want to avoid writing a HasStatus instance manually. It also has the benefit of showing the status code in the type; which might aid in readability.

  • HasStatus a => HasStatus (Headers ls a)Defined in servant-0.20.2 · Servant.API.UVerb
typetype IsMember (a :: u) (as :: [u]) = (Unique as, CheckElemIsMember a as, UElem a as)
#
familytype family Statuses (as :: [Type]) :: [Nat]
#
Instances2Statuses
  • type Statuses '[] = '[]Defined in servant-0.20.2 · Servant.API.UVerb
  • type Statuses (a ': as) = StatusOf a ': Statuses asDefined in servant-0.20.2 · Servant.API.UVerb
familytype family Statuses (as :: [Type]) :: [Nat]
#
Instances2Statuses
  • type Statuses '[] = '[]Defined in servant-0.20.2 · Servant.API.UVerb
  • type Statuses (a ': as) = StatusOf a ': Statuses asDefined in servant-0.20.2 · Servant.API.UVerb
familytype family Unique (xs :: [k]) :: Constraint where
#

Check whether all values in a type-level list are distinct. This will throw a nice error if there are any duplicate elements in the list.

Equations

newtypenewtype WithStatus (k :: Nat) a
#

A simple newtype wrapper that pairs a type with its status code. It implements all the content types that Servant ships with by default.

Constructors

Instances12MimeRender, MimeUnrender, Eq, Show, HasStatus, StatusOf, …

Sub-APIs defined as records of routes

10 declarations
datadata AsApi
#

A type that specifies that an API record contains an API definition. Only useful at type-level.

Instances2GenericMode, :-
  • GenericMode AsApiDefined in servant-0.20.2 · Servant.API.Generic
  • type (:-) AsApi api = apiDefined in servant-0.20.2 · Servant.API.Generic
classclass GenericMode (mode :: k) where
#

A class with a type family that applies an appropriate type family to the api parameter. For example, AsApi will leave api untouched, while AsServerT m will produce ServerT api m.

Associated types

  • type family (:-) (mode :: k) api
Instances2GenericMode
familytype family (:-) (mode :: k) api
#
Instances2:-
  • type (:-) AsApi api = apiDefined in servant-0.20.2 · Servant.API.Generic
  • type (:-) (AsLink a) api = MkLink api aDefined in servant-0.20.2 · Servant.Links
typetype ToServant (routes :: k -> Type) (mode :: k) = GToServant (Rep (routes mode))
#

Turns a generic product type into a tree of :<|> combinators.

valuefromServant
  1. :: GenericServant routes mode
  2. => ToServant routes mode
  3. -> routes mode
#

Inverse of toServant.

This can be used to turn generated values such as client functions into records.

You may need to provide a type signature for the output type (your record type).

Streaming endpoints, distinguished by HTTP method

13 declarations
datadata Stream (method :: k1) (status :: Nat) framing contentType a
#

A Stream endpoint for a given method emits a stream of encoded values at a given Content-Type, delimited by a framing strategy. Type synonyms are provided for standard methods.

Instances4HasLink, Generic, Rep, MkLink
  • HasLink (Stream m status fr ct a)Defined in servant-0.20.2 · Servant.Links
  • Generic (Stream method status framing contentType a)Defined in servant-0.20.2 · Servant.API.Stream
  • type Rep (Stream method status framing contentType a) = D1 ('MetaData "Stream" "Servant.API.Stream" "servant-0.20.2-kmMZib8zXn7e8NZPkSX15" 'False) V1Defined in servant-0.20.2 · Servant.API.Stream
  • type MkLink (Stream m status fr ct a) r = rDefined in servant-0.20.2 · Servant.Links
classclass FramingRender (strategy :: k) where
#

The FramingRender class provides the logic for emitting a framing strategy. The strategy transforms a SourceT m a into SourceT m ByteString, therefore it can prepend, append and intercalate framing structure around chunks.

Note: as the Monad m is generic, this is pure transformation.

Methods

Instances3FramingRender
classclass FramingUnrender (strategy :: k) where
#

The FramingUnrender class provides the logic for parsing a framing strategy.

Methods

Instances3FramingUnrender
classclass FromSourceIO chunk a | a -> chunk where
#

FromSourceIO 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.

Methods

Instances1FromSourceIO
datadata NetstringFraming
#

The netstring framing strategy as defined by djb: http://cr.yp.to/proto/netstrings.txt

Any string of 8-bit bytes may be encoded as [len]":"[string]",". Here [string] is the string and [len] is a nonempty sequence of ASCII digits giving the length of [string] in decimal. The ASCII digits are 30 for 0, 31 for 1, and so on up through 39 for 9. Extra zeros at the front of [len] are prohibited: [len] begins with 30 exactly when [string] is empty.

For example, the string "hello world!" is encoded as 32 3a 68 65 6c 6c 6f 20 77 6f 72 6c 64 21 2c, i.e., "12:hello world!,". The empty string is encoded as "0:,".

Instances2FramingRender, FramingUnrender
datadata NewlineFraming
#

A simple framing strategy that has no header, and inserts a newline character after each frame. This assumes that it is used with a Content-Type that encodes without newlines (e.g. JSON).

Instances2FramingRender, FramingUnrender
datadata 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

Instances2FramingRender, FramingUnrender
  • FramingRender NoFramingDefined in servant-0.20.2 · Servant.API.Stream
  • FramingUnrender NoFramingDefined in servant-0.20.2 · Servant.API.Stream

    As NoFraming doesn't have frame separators, we take the chunks as given and try to convert them one by one.

    That works well when a is a ByteString.

typetype SourceIO = SourceT IO
#

Stream endpoints may be implemented as producing a SourceIO chunk.

Clients reading from streaming endpoints can be implemented as consuming a SourceIO chunk.

datadata StreamBody' (mods :: [Type]) framing contentType a
#
Instances4HasLink, Generic, Rep, MkLink
classclass ToSourceIO chunk a | a -> chunk where
#

ToSourceIO 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.

Methods

Instances3ToSourceIO

Authentication

0 declarations

Endpoints description

2 declarations
datadata Description (sym :: Symbol)
#

Add more verbose description for (part of) API.

Example:

Example1 expression
:{type MyApi = Description "This comment is visible in multiple Servant interpretations \ \and can be really long if necessary. \ \Haskell multiline String support is not perfect \ \but it's still very readable.":> Get '[JSON] Book:}
Instances2HasLink, MkLink
datadata Summary (sym :: Symbol)
#

Add a short summary for (part of) API.

Example:

Example1 expression
type MyApi = Summary "Get book by ISBN." :> "books" :> Capture "isbn" Text :> Get '[JSON] Book
Instances2HasLink, MkLink

Content Types

8 declarations
classclass 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:

Example3 expressions
import Network.HTTP.Media ((//), (/:))data HTML:{instance Accept HTML where   contentType _ = "text" // "html" /: ("charset", "utf-8"):}
Instances4Accept
  • Accept FormUrlEncodedDefined in servant-0.20.2 · Servant.API.ContentTypes
    application/x-www-form-urlencoded
  • Accept JSONDefined in servant-0.20.2 · Servant.API.ContentTypes
    application/json
  • Accept OctetStreamDefined in servant-0.20.2 · Servant.API.ContentTypes
    application/octet-stream
  • Accept PlainTextDefined in servant-0.20.2 · Servant.API.ContentTypes
    text/plain;charset=utf-8
datadata FormUrlEncoded
#
Instances5Accept, MimeRender, MimeUnrender
datadata JSON
#
Instances5Accept, MimeRender, MimeUnrender
classclass 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

Methods

Instances11MimeRender, …
classclass 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.

Example3 expressions
import Network.HTTP.Media hiding (Accept)import qualified Data.ByteString.Lazy.Char8 as BSCdata MyContentType = MyContentType String
Example1 expression
:{instance Accept MyContentType where   contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8"):}
Example1 expression
:{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":}
Example1 expression
type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int

Methods

Instances11MimeUnrender, …
datadata NoContent
#

A type for responses without content-body.

Instances10Eq, Read, Show, Generic, NFData, HasStatus, …
datadata OctetStream
#
Instances7Accept, MimeRender, MimeUnrender, …
datadata PlainText
#
Instances9Accept, MimeRender, MimeUnrender, …

Serializing and deserializing types based on Accept and Content-Type headers.

Response Headers

12 declarations
datadata ResponseHeader (sym :: Symbol) a
#
Instances4Functor, Eq, Show, NFData
classclass AddHeader (mods :: [Type]) (h :: Symbol) v orig new | mods h v orig -> new, new -> mods, new -> h, new -> v, new -> orig where
#
Instances4AddHeader
datadata Headers (ls :: [Type]) a
#

Response Header objects. You should never need to construct one directly. Instead, use addOptionalHeader.

Constructors

Instances6AddHeader, Functor, NFData, GetHeaders, HasStatus, StatusOf
valueaddHeader :: AddHeader '[Optional, Strict] 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]":

Example2 expressions
let example0 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;getHeaders example0[("someheader","5")]
  1. A value that already has a header has its new header *prepended* to the existing list:

Example3 expressions
let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] StringgetHeaders 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.

valuelookupResponseHeader
  1. :: HasResponseHeader h a headers
  2. => Headers headers r
  3. -> ResponseHeader h a
#

Look up a specific ResponseHeader, without having to know what position it is in the HList.

Example3 expressions
let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] Stringlet example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] StringlookupResponseHeader example2 :: ResponseHeader "someheader" IntHeader 5
Example1 expression
lookupResponseHeader example2 :: ResponseHeader "1st" BoolHeader True

Usage of this function relies on an explicit type annotation of the header to be looked up. This can be done with type annotations on the result, or with an explicit type application. In this example, the type of header value is determined by the type-inference, we only specify the name of the header:

Example2 expressions
:set -XTypeApplicationscase lookupResponseHeader @"1st" example2 of { Header b -> b ; _ -> False }True
valuenoHeader :: AddHeader '[Optional, Strict] h v orig new => orig -> new
#

Deliberately do not add a header to a value.

Example2 expressions
let example1 = noHeader "hi" :: Headers '[Header "someheader" Int] StringgetHeaders example1[]

Untyped endpoints

0 declarations

Plugging in a wai Network.Wai.Application, serving directories

FromHttpApiData and ToHttpApiData

2 declarations
classclass FromHttpApiData a where
#

Parse value from HTTP API data.

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

Methods

Instances53FromHttpApiData, …
classclass ToHttpApiData a where
#

Convert value to HTTP API data.

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

Methods

Instances53ToHttpApiData, …
  • ToHttpApiData SetCookieDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData

    Note: this instance works correctly for alphanumeric name and value

    Example2 expressions
    let Right c = parseUrlPiece "SESSID=r2t5uvjq435r4q7ib3vtdjq120" :: Either Text SetCookietoUrlPiece c"SESSID=r2t5uvjq435r4q7ib3vtdjq120"
    Example1 expression
    toHeader c"SESSID=r2t5uvjq435r4q7ib3vtdjq120"
  • ToHttpApiData IntegerDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData NaturalDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData StringDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData VoidDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData AllDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData AnyDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData VersionDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example1 expression
    toUrlPiece (Version [1, 2, 3] [])"1.2.3"
  • ToHttpApiData Int16Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData Int32Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData Int64Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData Int8Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData Word16Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData Word32Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData Word64Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData Word8Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData BoolDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData CharDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData DoubleDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData FloatDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData IntDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData OrderingDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData WordDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData LinkDefined in servant-0.20.2 · Servant.Links
  • ToHttpApiData TextDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData TextDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData DayDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example1 expression
    toUrlPiece (fromGregorian 2015 10 03)"2015-10-03"
  • ToHttpApiData MonthDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example2 expressions
    import Data.Time.Calendar.Month.Compat (Month (..))MkMonth 244822040-03
    Example1 expression
    toUrlPiece $ MkMonth 24482"2040-03"
  • ToHttpApiData QuarterDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example2 expressions
    import Data.Time.Calendar.Quarter.Compat (Quarter (..))MkQuarter 80402010-Q1
    Example1 expression
    toUrlPiece $ MkQuarter 8040"2010-q1"
  • ToHttpApiData QuarterOfYearDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example1 expression
    toUrlPiece Q4"q4"
  • ToHttpApiData DayOfWeekDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example1 expression
    toUrlPiece Monday"monday"
  • ToHttpApiData NominalDiffTimeDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData UTCTimeDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example1 expression
    toUrlPiece $ UTCTime (fromGregorian 2015 10 03) 864.5"2015-10-03T00:14:24.500Z"
  • ToHttpApiData LocalTimeDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example1 expression
    toUrlPiece $ LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 21.687)"2015-10-03T14:55:21.687"
  • ToHttpApiData TimeOfDayDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example1 expression
    toUrlPiece $ TimeOfDay 14 55 23.1"14:55:23.100"
  • ToHttpApiData ZonedTimeDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example1 expression
    toUrlPiece $ ZonedTime (LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 51.001)) utc"2015-10-03T14:55:51.001Z"
    Example1 expression
    toUrlPiece $ ZonedTime (LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 51.001)) (TimeZone 120 True "EET")"2015-10-03T14:55:51.001+02:00"
  • ToHttpApiData UUIDDefined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData ()Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example1 expression
    toUrlPiece ()"_"
  • ToHttpApiData a => ToHttpApiData (First a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (Last a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (Max a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (Min a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (Identity a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (First a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (Last a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (Dual a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (Product a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (Sum a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (Maybe a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example1 expression
    toUrlPiece (Just "Hello")"just Hello"
  • HasResolution a => ToHttpApiData (Fixed a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData

    Note: this instance is not polykinded

  • (ToHttpApiData a, ToHttpApiData b) => ToHttpApiData (Either a b)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
    Example2 expressions
    toUrlPiece (Left "err" :: Either String Int)"left err"toUrlPiece (Right 3 :: Either String Int)"right 3"
  • ToHttpApiData a => ToHttpApiData (Const a b)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData
  • ToHttpApiData a => ToHttpApiData (Tagged b a)Defined in http-api-data-0.6.1 · Web.Internal.HttpApiData

    Note: this instance is not polykinded

Classes and instances for types that can be converted to and from HTTP API data.

Experimental modules

0 declarations

General Authentication

Links

7 declarations
familytype family IsElem endpoint api :: Constraint where
#

Closed type family, check if endpoint is within api. Uses IsElem' if it exhausts all other options.

Example1 expression
ok (Proxy :: Proxy (IsElem ("hello" :> Get '[JSON] Int) SampleAPI))OK
Example1 expression
ok (Proxy :: Proxy (IsElem ("bye" :> Get '[JSON] Int) SampleAPI))...... Could not ......

An endpoint is considered within an api even if it is missing combinators that don't affect the URL:

Example1 expression
ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (Header "h" Bool :> Get '[JSON] Int)))OK
Example1 expression
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

familytype 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.

Example2 expressions
data CustomThingtype 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.

datadata 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

Instances12Eq, Data, Ord, Show, Generic, NFData, …

Type-safe internal URIs

Re-exports

3 declarations
familytype family If (cond :: Bool) (tru :: k) (fls :: k) :: k where
#

Type-level If. If True a b ==> a; If False a b ==> b

Equations

datadata SBool (b :: Bool) where
#

Constructors

Instances12EqP, GCompare, GEq, GNFData, GRead, GShow, …
  • EqP SBoolDefined in singleton-bool-0.1.8 · Data.Singletons.Bool
  • GCompare SBoolDefined in singleton-bool-0.1.8 · Data.Singletons.Bool
  • GEq SBoolDefined in singleton-bool-0.1.8 · Data.Singletons.Bool
    Example1 expression
    geq STrue STrueJust Refl
    Example1 expression
    geq STrue SFalseNothing
  • GNFData SBoolDefined in singleton-bool-0.1.8 · Data.Singletons.Bool
  • GRead SBoolDefined in singleton-bool-0.1.8 · Data.Singletons.Bool
    Example1 expression
    readsPrec 0 "Some STrue" :: [(Some SBool, String)][(Some STrue,"")]
    Example1 expression
    readsPrec 0 "Some SFalse" :: [(Some SBool, String)][(Some SFalse,"")]
    Example1 expression
    readsPrec 0 "Some Else" :: [(Some SBool, String)][]
  • GShow SBoolDefined in singleton-bool-0.1.8 · Data.Singletons.Bool
    Example1 expression
    showsPrec 0 STrue """STrue"
  • OrdP SBoolDefined in singleton-bool-0.1.8 · Data.Singletons.Bool
  • Eq (SBool b)Defined in singleton-bool-0.1.8 · Data.Singletons.Bool
  • Ord (SBool b)Defined in singleton-bool-0.1.8 · Data.Singletons.Bool
  • Show (SBool b)Defined in singleton-bool-0.1.8 · Data.Singletons.Bool
  • NFData (SBool b)Defined in singleton-bool-0.1.8 · Data.Singletons.Bool
  • SBoolI b => Boring (SBool b)Defined in singleton-bool-0.1.8 · Data.Singletons.Bool
classclass SBoolI (b :: Bool) where
#

Methods

Instances2SBoolI
  • SBoolI 'FalseDefined in singleton-bool-0.1.8 · Data.Singletons.Bool
  • SBoolI 'TrueDefined in singleton-bool-0.1.8 · Data.Singletons.Bool