okapi-0.2.0.0: A bidirectional HTTP description language
Safe HaskellNone
LanguageGHC2024

Okapi

Synopsis

Documentation

data Forest shape where Source #

Constructors

(:->) :: forall method path query headers body status resHeaders resBody. Request method path query headers body -> Response status resHeaders resBody -> Forest (Shape method path query headers body (Response status resHeaders resBody)) 
(:-<) :: forall (responses :: (Type -> Type -> Type -> Type) -> Type) method path query headers body. Cases responses => Request method path query headers body -> Responses Response responses -> Forest (Shape method path query headers body (responses Response)) 

Instances

Instances details
GFunction n (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Function n (Shape method path query headers body result)))) Source # 
Instance details

Defined in Okapi.Mode.Function

Methods

gServe :: (n ~> IO) -> S1 sm (Rec0 (Forest (Shape method path query headers body result))) () -> S1 sm' (Rec0 (Function n (Shape method path query headers body result))) () -> Middleware

GenericOAPI (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) Source # 
Instance details

Defined in Okapi.Artifact.OpenApi

Methods

gOpenApi :: S1 sm (Rec0 (Forest (Shape method path query headers body result))) () -> OpenApi

GClient (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Client (Shape method path query headers body result)))) Source # 
Instance details

Defined in Okapi.Mode.Client

Methods

gClient :: ClientSettings -> S1 sm (Rec0 (Forest (Shape method path query headers body result))) () -> S1 sm' (Rec0 (Client (Shape method path query headers body result))) ()

GLink (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Link (Shape method path query headers body result)))) Source # 
Instance details

Defined in Okapi.Mode.Link

Methods

gLink :: S1 sm (Rec0 (Forest (Shape method path query headers body result))) () -> S1 sm' (Rec0 (Link (Shape method path query headers body result))) ()

data Shape method path query headers body result Source #

Instances

Instances details
GFunction n (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Function n (Shape method path query headers body result)))) Source # 
Instance details

Defined in Okapi.Mode.Function

Methods

gServe :: (n ~> IO) -> S1 sm (Rec0 (Forest (Shape method path query headers body result))) () -> S1 sm' (Rec0 (Function n (Shape method path query headers body result))) () -> Middleware

GenericOAPI (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) Source # 
Instance details

Defined in Okapi.Artifact.OpenApi

Methods

gOpenApi :: S1 sm (Rec0 (Forest (Shape method path query headers body result))) () -> OpenApi

GClient (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Client (Shape method path query headers body result)))) Source # 
Instance details

Defined in Okapi.Mode.Client

Methods

gClient :: ClientSettings -> S1 sm (Rec0 (Forest (Shape method path query headers body result))) () -> S1 sm' (Rec0 (Client (Shape method path query headers body result))) ()

GLink (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Link (Shape method path query headers body result)))) Source # 
Instance details

Defined in Okapi.Mode.Link

Methods

gLink :: S1 sm (Rec0 (Forest (Shape method path query headers body result))) () -> S1 sm' (Rec0 (Link (Shape method path query headers body result))) ()

fn :: ((Request method path query headers body, Request) -> n result) -> Function n (Shape method path query headers body result) Source #

serve :: forall (n :: Type -> Type) method path query headers body result. (n ~> IO) -> Forest (Shape method path query headers body result) -> Function n (Shape method path query headers body result) -> Application Source #

tryServe :: forall (n :: Type -> Type) method path query headers body result. (n ~> IO) -> Forest (Shape method path query headers body result) -> Function n (Shape method path query headers body result) -> Middleware Source #

data Function (n :: Type -> Type) shape where Source #

Constructors

Fn :: forall method path query headers body (n :: Type -> Type) result. ((Request method path query headers body, Request) -> n result) -> Function n (Shape method path query headers body result) 

Instances

Instances details
GFunction n (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Function n (Shape method path query headers body result)))) Source # 
Instance details

Defined in Okapi.Mode.Function

Methods

gServe :: (n ~> IO) -> S1 sm (Rec0 (Forest (Shape method path query headers body result))) () -> S1 sm' (Rec0 (Function n (Shape method path query headers body result))) () -> Middleware

data Client shape where Source #

Constructors

Cb :: forall method path query headers body result. (Request method path query headers body -> IO (Either ClientError result)) -> Client (Shape method path query headers body result) 

Instances

Instances details
GClient (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Client (Shape method path query headers body result)))) Source # 
Instance details

Defined in Okapi.Mode.Client

Methods

gClient :: ClientSettings -> S1 sm (Rec0 (Forest (Shape method path query headers body result))) () -> S1 sm' (Rec0 (Client (Shape method path query headers body result))) ()

data Route (n :: Type -> Type) where Source #

Constructors

(:=) :: forall shape (n :: Type -> Type). Forest shape -> Function n shape -> Route n infixl 0 

newtype Handle Source #

Constructors

Handle 

handle :: forall (n :: Type -> Type). (n ~> IO) -> Route n -> Handle Source #

app :: forall server (n :: Type -> Type). (Generic (server Forest), Generic (server (Function n)), GFunction n (Rep (server Forest)) (Rep (server (Function n)))) => (n ~> IO) -> server Forest -> server (Function n) -> Application Source #

client :: (Generic (server Forest), Generic (server Client), GClient (Rep (server Forest)) (Rep (server Client))) => server Forest -> ClientSettings -> server Client Source #

openApi :: (Generic (server Forest), GenericOAPI (Rep (server Forest))) => server Forest -> OpenApi Source #

endpointToOpenApi :: Forest (Shape method path query headers body result) -> OpenApi Source #

type (~>) (f :: Type -> Type) (g :: Type -> Type) = forall a. f a -> g a Source #

fetch :: Manager -> String -> Forest (Shape method path query headers body result) -> Request method path query headers body -> IO (Either ClientError result) Source #

data ClientError Source #

Constructors

ClientError 

Instances

Instances details
Show ClientError Source # 
Instance details

Defined in Okapi.Mode.Client

Eq ClientError Source # 
Instance details

Defined in Okapi.Mode.Client

data URI Source #

Constructors

URI 

Fields

Instances

Instances details
HasField "full" URI Text Source # 
Instance details

Defined in Okapi.Mode.Link

Methods

getField :: URI -> Text #

data Link shape where Source #

Constructors

Link :: forall path query method headers body result. (path -> query -> URI) -> Link (Shape method path query headers body result) 

Instances

links :: (Generic (server Forest), Generic (server Link), GLink (Rep (server Forest)) (Rep (server Link))) => server Forest -> server Link Source #

data KnownMethod (m :: Symbol) where Source #

Constructors

GET :: KnownMethod "GET" 
POST :: KnownMethod "POST" 
PUT :: KnownMethod "PUT" 
DELETE :: KnownMethod "DELETE" 

Instances

Instances details
Show (KnownMethod m) Source # 
Instance details

Defined in Okapi.HTTP.Request.Method

Eq (KnownMethod m) Source # 
Instance details

Defined in Okapi.HTTP.Request.Method

type GET = KnownMethod "GET" Source #

type POST = KnownMethod "POST" Source #

type PUT = KnownMethod "PUT" Source #

type DELETE = KnownMethod "DELETE" Source #

data KnownStatus (s :: Nat) where Source #

Constructors

S200 :: KnownStatus 200 
S201 :: KnownStatus 201 
S204 :: KnownStatus 204 
S404 :: KnownStatus 404 
S500 :: KnownStatus 500 

Instances

Instances details
Num (KnownStatus 200) Source # 
Instance details

Defined in Okapi.HTTP.Response.Status

Num (KnownStatus 201) Source # 
Instance details

Defined in Okapi.HTTP.Response.Status

Num (KnownStatus 204) Source # 
Instance details

Defined in Okapi.HTTP.Response.Status

Num (KnownStatus 404) Source # 
Instance details

Defined in Okapi.HTTP.Response.Status

Num (KnownStatus 500) Source # 
Instance details

Defined in Okapi.HTTP.Response.Status

Show (KnownStatus s) Source # 
Instance details

Defined in Okapi.HTTP.Response.Status

Eq (KnownStatus s) Source # 
Instance details

Defined in Okapi.HTTP.Response.Status

data ArrayStyle Source #

Instances

Instances details
Show ArrayStyle Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

Eq ArrayStyle Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

class (Generic (responses Response), Generic (responses Response), Generic (responses Response), Generic (responses (Response :: Type -> Type -> Type -> Type)), GConstruct (Rep (responses Response)), GTraverse Response Response (Rep (responses Response)) (Rep (responses Response)), GTraverse Response Response (Rep (responses Response)) (Rep (responses Response)), GTraverse Response (Response :: Type -> Type -> Type -> Type) (Rep (responses Response)) (Rep (responses (Response :: Type -> Type -> Type -> Type))), GTraverse Response Response (Rep (responses Response)) (Rep (responses Response)), GZip Response Response (Rep (responses Response)) (Rep (responses Response))) => Cases (responses :: (Type -> Type -> Type -> Type) -> Type) Source #

data Responses (f :: Type -> Type -> Type -> Type) (responses :: (Type -> Type -> Type -> Type) -> Type) Source #

getResponses :: forall (f :: Type -> Type -> Type -> Type) responses. Responses f responses -> NonEmpty (responses f) Source #

cases :: forall (responses :: (Type -> Type -> Type -> Type) -> Type). Cases responses => GArgs Response (Rep (responses Response)) (Responses Response responses) Source #

parseRequest :: Request method path query headers body -> Request -> IO (Either (Request method path query headers body) (Request method path query headers body)) Source #

parseRequestResult :: Request method path query headers body -> Request -> IO (Request method path query headers body) Source #

printRequest :: Request method path query headers body -> Request method path query headers body -> IO Request Source #

link :: Request method path query headers body -> path -> query -> Text Source #

parseResponse :: Response status headers body -> Response -> IO (Either (Response status headers body) (Response status headers body)) Source #

parseResponseResult :: Response status headers body -> Response -> IO (Response status headers body) Source #

parseResponses :: Cases responses => Responses Response responses -> Response -> IO (Either (Responses (Response :: Type -> Type -> Type -> Type) responses) (responses Response)) Source #

printResponse :: Response status headers body -> Response status headers body -> IO Response Source #

printResponses :: Cases responses => Responses Response responses -> responses Response -> IO Response Source #

type SymTree (t :: Type -> Type) a = Tree t a a Source #

A symmetrical Tree t i o where i ~ o.

data Leaf (t :: Type -> Type) a Source #

Constructors

Leaf 

Fields

data Info Source #

Constructors

Info 

Fields

Instances

Instances details
Show Info Source # 
Instance details

Defined in Okapi.Tree

Methods

showsPrec :: Int -> Info -> ShowS #

show :: Info -> String #

showList :: [Info] -> ShowS #

Eq Info Source # 
Instance details

Defined in Okapi.Tree

Methods

(==) :: Info -> Info -> Bool #

(/=) :: Info -> Info -> Bool #

class HasLeaf (t :: Type -> Type) a where Source #

Methods

leaf :: Leaf t a Source #

Instances

Instances details
HasLeaf Cookie ByteString Source # 
Instance details

Defined in Okapi.HTTP.Request.Cookies

HasLeaf Cookie Int16 Source # 
Instance details

Defined in Okapi.HTTP.Request.Cookies

HasLeaf Cookie Int32 Source # 
Instance details

Defined in Okapi.HTTP.Request.Cookies

HasLeaf Cookie Int64 Source # 
Instance details

Defined in Okapi.HTTP.Request.Cookies

HasLeaf Cookie Text Source # 
Instance details

Defined in Okapi.HTTP.Request.Cookies

HasLeaf Cookie Day Source # 
Instance details

Defined in Okapi.HTTP.Request.Cookies

HasLeaf Cookie UUID Source # 
Instance details

Defined in Okapi.HTTP.Request.Cookies

HasLeaf Cookie Integer Source # 
Instance details

Defined in Okapi.HTTP.Request.Cookies

HasLeaf Cookie Bool Source # 
Instance details

Defined in Okapi.HTTP.Request.Cookies

HasLeaf Cookie Int Source # 
Instance details

Defined in Okapi.HTTP.Request.Cookies

HasLeaf Headers ByteString Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers Int16 Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers Int32 Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers Int64 Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers Text Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers Day Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers DiffTime Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers UTCTime Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers LocalTime Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers TimeOfDay Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers UUID Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers Integer Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers Bool Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers Double Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers Float Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers Int Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Path Int16 Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path Int32 Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path Int64 Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path Text Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path UUID Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path Integer Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path Int Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Methods

leaf :: Leaf Path Int Source #

HasLeaf Query Int16 Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query Int32 Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query Int64 Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query Text Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query Day Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query UTCTime Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query UUID Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query Integer Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query Bool Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query Double Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query Float Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Query Int Source # 
Instance details

Defined in Okapi.HTTP.Request.Query

HasLeaf Attributes ByteString Source # 
Instance details

Defined in Okapi.HTTP.Response.Attributes

HasLeaf Attributes Integer Source # 
Instance details

Defined in Okapi.HTTP.Response.Attributes

HasLeaf Attributes Int Source # 
Instance details

Defined in Okapi.HTTP.Response.Attributes

HasLeaf Headers ByteString Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers Int16 Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers Int32 Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers Int64 Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers Text Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers Day Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers DiffTime Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers UTCTime Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers LocalTime Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers TimeOfDay Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers UUID Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers Integer Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers Bool Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers Double Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers Float Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf Headers Int Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf SetCookie ByteString Source # 
Instance details

Defined in Okapi.HTTP.Response.SetCookies

HasLeaf SetCookie Int16 Source # 
Instance details

Defined in Okapi.HTTP.Response.SetCookies

HasLeaf SetCookie Int32 Source # 
Instance details

Defined in Okapi.HTTP.Response.SetCookies

HasLeaf SetCookie Int64 Source # 
Instance details

Defined in Okapi.HTTP.Response.SetCookies

HasLeaf SetCookie Text Source # 
Instance details

Defined in Okapi.HTTP.Response.SetCookies

HasLeaf SetCookie Day Source # 
Instance details

Defined in Okapi.HTTP.Response.SetCookies

HasLeaf SetCookie UUID Source # 
Instance details

Defined in Okapi.HTTP.Response.SetCookies

HasLeaf SetCookie Integer Source # 
Instance details

Defined in Okapi.HTTP.Response.SetCookies

HasLeaf SetCookie Bool Source # 
Instance details

Defined in Okapi.HTTP.Response.SetCookies

HasLeaf SetCookie Int Source # 
Instance details

Defined in Okapi.HTTP.Response.SetCookies

HasLeaf Headers (TimeOfDay, TimeZone) Source # 
Instance details

Defined in Okapi.HTTP.Request.Headers

HasLeaf Headers (TimeOfDay, TimeZone) Source # 
Instance details

Defined in Okapi.HTTP.Response.Headers

HasLeaf (BareItem :: Type -> Type) ByteString Source # 
Instance details

Defined in Okapi.HTTP.RFC9651.BareItem

HasLeaf (BareItem :: Type -> Type) Scientific Source # 
Instance details

Defined in Okapi.HTTP.RFC9651.BareItem

HasLeaf (BareItem :: Type -> Type) Text Source # 
Instance details

Defined in Okapi.HTTP.RFC9651.BareItem

Methods

leaf :: Leaf (BareItem :: Type -> Type) Text Source #

HasLeaf (BareItem :: Type -> Type) UTCTime Source # 
Instance details

Defined in Okapi.HTTP.RFC9651.BareItem

HasLeaf (BareItem :: Type -> Type) Integer Source # 
Instance details

Defined in Okapi.HTTP.RFC9651.BareItem

HasLeaf (BareItem :: Type -> Type) Bool Source # 
Instance details

Defined in Okapi.HTTP.RFC9651.BareItem

Methods

leaf :: Leaf (BareItem :: Type -> Type) Bool Source #

HasLeaf (BareItem :: Type -> Type) Double Source # 
Instance details

Defined in Okapi.HTTP.RFC9651.BareItem

Methods

leaf :: Leaf (BareItem :: Type -> Type) Double Source #

HasLeaf (BareItem :: Type -> Type) Float Source # 
Instance details

Defined in Okapi.HTTP.RFC9651.BareItem

Methods

leaf :: Leaf (BareItem :: Type -> Type) Float Source #

HasLeaf (BareItem :: Type -> Type) Int Source # 
Instance details

Defined in Okapi.HTTP.RFC9651.BareItem

Methods

leaf :: Leaf (BareItem :: Type -> Type) Int Source #

(=.) :: Profunctor p => (a -> b) -> p b c -> p a c infixr 5 Source #

int :: forall (t :: Type -> Type). HasLeaf t Int => Leaf t Int Source #

int16 :: forall (t :: Type -> Type). HasLeaf t Int16 => Leaf t Int16 Source #

int32 :: forall (t :: Type -> Type). HasLeaf t Int32 => Leaf t Int32 Source #

int64 :: forall (t :: Type -> Type). HasLeaf t Int64 => Leaf t Int64 Source #

integer :: forall (t :: Type -> Type). HasLeaf t Integer => Leaf t Integer Source #

bool :: forall (t :: Type -> Type). HasLeaf t Bool => Leaf t Bool Source #

float :: forall (t :: Type -> Type). HasLeaf t Float => Leaf t Float Source #

double :: forall (t :: Type -> Type). HasLeaf t Double => Leaf t Double Source #

text :: forall (t :: Type -> Type). HasLeaf t Text => Leaf t Text Source #

day :: forall (t :: Type -> Type). HasLeaf t Day => Leaf t Day Source #

localTime :: forall (t :: Type -> Type). HasLeaf t LocalTime => Leaf t LocalTime Source #

utcTime :: forall (t :: Type -> Type). HasLeaf t UTCTime => Leaf t UTCTime Source #

timeOfDay :: forall (t :: Type -> Type). HasLeaf t TimeOfDay => Leaf t TimeOfDay Source #

uuid :: forall (t :: Type -> Type). HasLeaf t UUID => Leaf t UUID Source #

type IsoJson a = (FromJSON a, ToJSON a, ToSchema a) Source #

method :: forall (m :: Symbol) path query headers body. KnownMethod m -> Request Method path query headers body -> Request (KnownMethod m) path query headers body Source #

path :: SymTree Path path -> Request method [Text] query headers body -> Request method path query headers body Source #

query :: SymTree Query query -> Request method path Query headers body -> Request method path query headers body Source #

headers :: SymTree Headers headers -> Request method path query RequestHeaders body -> Request method path query headers body Source #

body :: SymTree Body body -> Request method path query headers (IO ByteString) -> Request method path query headers body Source #

pathOf :: (Generic path, GPath (Rep path)) => Request method [Text] query headers body -> Request method path query headers body Source #

queryOf :: (Generic query, GQuery (Rep query)) => Request method path Query headers body -> Request method path query headers body Source #

headersOf :: (Generic headers, GHeaders (Rep headers)) => Request method path query RequestHeaders body -> Request method path query headers body Source #

segment :: Text -> Leaf Path a -> Tree Path a a Source #

Parse and print a single typed path segment.

>>> printer (segment "id" int) (42 :: Int)
["42"]
>>> parser (segment "id" int) ["42"]
(Right 42,[])
>>> parser (segment "id" int) ["hello"]
(Left ParseError,["hello"])
>>> parser (segment "id" int) []
(Left ParseError,[])
printParse parser printer (segment "n" int) (x :: Int)
printParse parser printer (segment "n" integer) x
printStable parser printer (segment "n" int) (x :: Int)

segment_ :: Leaf Path a -> a -> Tree Path () () Source #

Match a fixed literal segment.

>>> printer (segment_ int 42) ()
["42"]
>>> parser (segment_ int 42) ["42"]
(Right (),[])
>>> parser (segment_ int 42) ["99"]
(Left ParseError,["99"])

segments :: Leaf Path a -> Tree Path (NonEmpty a) (NonEmpty a) Source #

Parse and print all remaining path segments as a non-empty list.

printParse parser printer (segments int) (x :| xs)
printStable parser printer (segments int) (x :| xs)

param :: Text -> Leaf Query a -> Tree Query a a Source #

Parse and print a required query parameter.

printParse parser printer (param "k" int) (x :: Int)
printStable parser printer (param "k" int) (x :: Int)

param' :: Text -> Leaf Query a -> Tree Query (Maybe a) (Maybe a) Source #

Parse and print an optional query parameter.

printParse parser printer (param' "k" int) (x :: Maybe Int)
printStable parser printer (param' "k" int) (x :: Maybe Int)

param_ :: Text -> Leaf Query a -> a -> Tree Query () () Source #

flag :: Text -> Tree Query () () Source #

Parse and print a boolean flag (presence = True).

printParse parser printer (flag "f") ()
printParse parser printer (flag' "f") (x :: Bool)
printStable parser printer (flag' "f") (x :: Bool)

list :: ArrayStyle -> Text -> Leaf Query a -> Tree Query (NonEmpty a) (NonEmpty a) Source #

Parse and print a non-empty list of query parameters.

printParse parser printer (list Exploded "k" int) (x :| xs)
printParse parser printer (list CommaDelimited "k" int) (x :| xs)
printStable parser printer (list Exploded "k" int) (x :| xs)

list' :: ArrayStyle -> Text -> Leaf Query a -> Tree Query [a] [a] Source #

field :: HeaderName -> Leaf Headers a -> Tree Headers a a Source #

Parse and print a required request header field.

printParse parser printer (field "x-foo" int) (x :: Int)
printStable parser printer (field "x-foo" int) (x :: Int)

field' :: HeaderName -> Leaf Headers a -> Tree Headers (Maybe a) (Maybe a) Source #

Parse and print an optional request header field.

printParse parser printer (field' "x-foo" int) (x :: Maybe Int)

cookie :: ByteString -> Leaf Cookie a -> Tree Headers a a Source #

Parse and print a required request cookie.

printParse parser printer (cookie "sid" int) (x :: Int)
printStable parser printer (cookie "sid" int) (x :: Int)

cookie' :: ByteString -> Leaf Cookie a -> Tree Headers (Maybe a) (Maybe a) Source #

Parse and print an optional request cookie.

printParse parser printer (cookie' "sid" int) (x :: Maybe Int)