Safe Haskell | None |
---|---|
Language | Haskell2010 |
Defines the types and kinds for working with type and value level HTTP status codes.
In particular, this module exports a datatype, Status
which is meant
to be used with DataKinds
providing one type, e.g. 'Ok
for every
common HTTP response status (and an override one CustomStatus
). It
also exports Sing
values for each Status
-kinded type each merely
being the name of that type prepended with S
.
Finally, it exports a set of type synonms for each Status
-kinded type
so that they can be referenced without the quote prefix '
.
- data SomeStatus where
- SomeStatus :: forall s. Sing s -> SomeStatus
- httpStatus :: forall sc. Sing sc -> Status
- statusCode :: forall sc. Sing sc -> Int
- parseStatus :: Int -> SomeStatus
- data Status
- = CustomStatus Nat
- | Continue
- | SwitchingProtocols
- | Ok
- | Created
- | Accepted
- | NonAuthoritiveInformation
- | NoContent
- | ResetContent
- | PartialContent
- | IMUsed
- | MultipleChoices
- | MovedPermanently
- | Found
- | SeeOther
- | NotModified
- | TemporaryRedirect
- | PermanentRedirect
- | BadRequest
- | Unauthorized
- | PaymentRequired
- | Forbidden
- | NotFound
- | MethodNotAllowed
- | NotAcceptable
- | ProxyAuthenticationRequired
- | RequestTimeout
- | Conflict
- | Gone
- | LengthRequired
- | PreconditionFailed
- | PayloadTooLarge
- | RequestURITooLong
- | UnsupportedMediaType
- | RequestedRangeNotSatisfiable
- | ExpectationFailed
- | MisdirectedRequest
- | UnprocessableEntity
- | Locked
- | FailedDependency
- | UpgradeRequired
- | PreconditionRequired
- | TooManyRequests
- | RequestHeaderFieldsTooLarge
- | UnavailableForLegalReasons
- | InternalServerError
- | NotImplemented
- | BadGateway
- | ServiceUnavailable
- | GatewayTimeout
- | HTTPVersionNotSupported
- | VariantAlsoNegotiates
- | InsufficientStorage
- | LoopDetected
- | NotExtended
- | NetworkAuthenticationRequired
- data family Sing a
- type CustomStatus code = CustomStatus code
- type Continue = Continue
- type SwitchingProtocols = SwitchingProtocols
- type Ok = Ok
- type Created = Created
- type Accepted = Accepted
- type NonAuthoritiveInformation = NonAuthoritiveInformation
- type NoContent = NoContent
- type ResetContent = ResetContent
- type PartialContent = PartialContent
- type IMUsed = IMUsed
- type MultipleChoices = MultipleChoices
- type MovedPermanently = MovedPermanently
- type Found = Found
- type SeeOther = SeeOther
- type NotModified = NotModified
- type TemporaryRedirect = TemporaryRedirect
- type PermanentRedirect = PermanentRedirect
- type BadRequest = BadRequest
- type Unauthorized = Unauthorized
- type PaymentRequired = PaymentRequired
- type Forbidden = Forbidden
- type NotFound = NotFound
- type MethodNotAllowed = MethodNotAllowed
- type NotAcceptable = NotAcceptable
- type ProxyAuthenticationRequired = ProxyAuthenticationRequired
- type RequestTimeout = RequestTimeout
- type Conflict = Conflict
- type Gone = Gone
- type LengthRequired = LengthRequired
- type PreconditionFailed = PreconditionFailed
- type PayloadTooLarge = PayloadTooLarge
- type RequestURITooLong = RequestURITooLong
- type UnsupportedMediaType = UnsupportedMediaType
- type RequestedRangeNotSatisfiable = RequestedRangeNotSatisfiable
- type ExpectationFailed = ExpectationFailed
- type MisdirectedRequest = MisdirectedRequest
- type UnprocessableEntity = UnprocessableEntity
- type Locked = Locked
- type FailedDependency = FailedDependency
- type UpgradeRequired = UpgradeRequired
- type PreconditionRequired = PreconditionRequired
- type TooManyRequests = TooManyRequests
- type RequestHeaderFieldsTooLarge = RequestHeaderFieldsTooLarge
- type UnavailableForLegalReasons = UnavailableForLegalReasons
- type InternalServerError = InternalServerError
- type NotImplemented = NotImplemented
- type BadGateway = BadGateway
- type ServiceUnavailable = ServiceUnavailable
- type GatewayTimeout = GatewayTimeout
- type HTTPVersionNotSupported = HTTPVersionNotSupported
- type VariantAlsoNegotiates = VariantAlsoNegotiates
- type InsufficientStorage = InsufficientStorage
- type LoopDetected = LoopDetected
- type NotExtended = NotExtended
- type NetworkAuthenticationRequired = NetworkAuthenticationRequired
Functions and types for working with HeaderName
Sing
s
data SomeStatus where Source
It's difficult to get ahold of values of Status
directly since they
may contain Nat
values which do not exist. Instead, we can get almost
the same effect through an existential which holds a singleton at the
Status
kind
Note that while the Haddocks show this as taking any Sing
type it is
actually constrained only to have Sing
s of kind Status
.
SomeStatus :: forall s. Sing s -> SomeStatus |
httpStatus :: forall sc. Sing sc -> Status Source
parseStatus :: Int -> SomeStatus Source
The Status
type/kind
A data type representing HTTP statuses (codes). Much more importantly,
with DataKinds
enabled this becomes a kind describing types, one for
each such status.
It's worth noting that values of this type can be had, but one branch,
CustomStatus
will not work since it requires Nat
values which cannot
be had. For this reason prefer using values of SomeStatus
instead of
values of Status
directly.
data family Sing a
The singleton kind-indexed data family.
Type synonyms for more convenient use of Status
es
type CustomStatus code = CustomStatus code Source
type ResetContent = ResetContent Source
type PartialContent = PartialContent Source
type MultipleChoices = MultipleChoices Source
type NotModified = NotModified Source
type BadRequest = BadRequest Source
type Unauthorized = Unauthorized Source
type PaymentRequired = PaymentRequired Source
type NotAcceptable = NotAcceptable Source
type RequestTimeout = RequestTimeout Source
type LengthRequired = LengthRequired Source
type PayloadTooLarge = PayloadTooLarge Source
type UpgradeRequired = UpgradeRequired Source
type TooManyRequests = TooManyRequests Source
type NotImplemented = NotImplemented Source
type BadGateway = BadGateway Source
type GatewayTimeout = GatewayTimeout Source
type LoopDetected = LoopDetected Source
type NotExtended = NotExtended Source