| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Okapi
Synopsis
- data Forest shape where
- (:->) :: 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))
- data 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)
- 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
- 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
- data Function (n :: Type -> Type) shape where
- data Client shape where
- data Route (n :: Type -> Type) where
- newtype Handle = Handle {}
- handle :: forall (n :: Type -> Type). (n ~> IO) -> Route n -> Handle
- 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
- client :: (Generic (server Forest), Generic (server Client), GClient (Rep (server Forest)) (Rep (server Client))) => server Forest -> ClientSettings -> server Client
- openApi :: (Generic (server Forest), GenericOAPI (Rep (server Forest))) => server Forest -> OpenApi
- endpointToOpenApi :: Forest (Shape method path query headers body result) -> OpenApi
- type (~>) (f :: Type -> Type) (g :: Type -> Type) = forall a. f a -> g a
- fetch :: Manager -> String -> Forest (Shape method path query headers body result) -> Request method path query headers body -> IO (Either ClientError result)
- data ClientError = ClientError
- data ClientSettings = ClientSettings {}
- data URI = URI {}
- data Link shape where
- links :: (Generic (server Forest), Generic (server Link), GLink (Rep (server Forest)) (Rep (server Link))) => server Forest -> server Link
- data KnownMethod (m :: Symbol) where
- GET :: KnownMethod "GET"
- POST :: KnownMethod "POST"
- PUT :: KnownMethod "PUT"
- DELETE :: KnownMethod "DELETE"
- type GET = KnownMethod "GET"
- type POST = KnownMethod "POST"
- type PUT = KnownMethod "PUT"
- type DELETE = KnownMethod "DELETE"
- data KnownStatus (s :: Nat) where
- S200 :: KnownStatus 200
- S201 :: KnownStatus 201
- S204 :: KnownStatus 204
- S404 :: KnownStatus 404
- S500 :: KnownStatus 500
- type S200 = KnownStatus 200
- type S201 = KnownStatus 201
- type S204 = KnownStatus 204
- type S404 = KnownStatus 404
- type S500 = KnownStatus 500
- data ArrayStyle
- 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)
- data Responses (f :: Type -> Type -> Type -> Type) (responses :: (Type -> Type -> Type -> Type) -> Type)
- getResponses :: forall (f :: Type -> Type -> Type -> Type) responses. Responses f responses -> NonEmpty (responses f)
- cases :: forall (responses :: (Type -> Type -> Type -> Type) -> Type). Cases responses => GArgs Response (Rep (responses Response)) (Responses Response responses)
- parseRequest :: Request method path query headers body -> Request -> IO (Either (Request method path query headers body) (Request method path query headers body))
- parseRequestResult :: Request method path query headers body -> Request -> IO (Request method path query headers body)
- printRequest :: Request method path query headers body -> Request method path query headers body -> IO Request
- link :: Request method path query headers body -> path -> query -> Text
- parseResponse :: Response status headers body -> Response -> IO (Either (Response status headers body) (Response status headers body))
- parseResponseResult :: Response status headers body -> Response -> IO (Response status headers body)
- parseResponses :: Cases responses => Responses Response responses -> Response -> IO (Either (Responses (Response :: Type -> Type -> Type -> Type) responses) (responses Response))
- printResponse :: Response status headers body -> Response status headers body -> IO Response
- printResponses :: Cases responses => Responses Response responses -> responses Response -> IO Response
- type SymTree (t :: Type -> Type) a = Tree t a a
- data Leaf (t :: Type -> Type) a = Leaf {}
- data Info = Info {}
- class HasLeaf (t :: Type -> Type) a where
- (=.) :: Profunctor p => (a -> b) -> p b c -> p a c
- int :: forall (t :: Type -> Type). HasLeaf t Int => Leaf t Int
- int16 :: forall (t :: Type -> Type). HasLeaf t Int16 => Leaf t Int16
- int32 :: forall (t :: Type -> Type). HasLeaf t Int32 => Leaf t Int32
- int64 :: forall (t :: Type -> Type). HasLeaf t Int64 => Leaf t Int64
- integer :: forall (t :: Type -> Type). HasLeaf t Integer => Leaf t Integer
- bool :: forall (t :: Type -> Type). HasLeaf t Bool => Leaf t Bool
- float :: forall (t :: Type -> Type). HasLeaf t Float => Leaf t Float
- double :: forall (t :: Type -> Type). HasLeaf t Double => Leaf t Double
- scientific :: forall (t :: Type -> Type). HasLeaf t Scientific => Leaf t Scientific
- text :: forall (t :: Type -> Type). HasLeaf t Text => Leaf t Text
- day :: forall (t :: Type -> Type). HasLeaf t Day => Leaf t Day
- localTime :: forall (t :: Type -> Type). HasLeaf t LocalTime => Leaf t LocalTime
- utcTime :: forall (t :: Type -> Type). HasLeaf t UTCTime => Leaf t UTCTime
- timeOfDay :: forall (t :: Type -> Type). HasLeaf t TimeOfDay => Leaf t TimeOfDay
- uuid :: forall (t :: Type -> Type). HasLeaf t UUID => Leaf t UUID
- type IsoJson a = (FromJSON a, ToJSON a, ToSchema a)
- request :: Request Method [Text] Query RequestHeaders (IO ByteString)
- methodGET :: Request GET [Text] Query RequestHeaders (IO ByteString)
- methodPOST :: Request POST [Text] Query RequestHeaders (IO ByteString)
- methodPUT :: Request PUT [Text] Query RequestHeaders (IO ByteString)
- methodDELETE :: Request DELETE [Text] Query RequestHeaders (IO ByteString)
- method :: forall (m :: Symbol) path query headers body. KnownMethod m -> Request Method path query headers body -> Request (KnownMethod m) path query headers body
- path :: SymTree Path path -> Request method [Text] query headers body -> Request method path query headers body
- query :: SymTree Query query -> Request method path Query headers body -> Request method path query headers body
- headers :: SymTree Headers headers -> Request method path query RequestHeaders body -> Request method path query headers body
- body :: SymTree Body body -> Request method path query headers (IO ByteString) -> Request method path query headers body
- pathOf :: (Generic path, GPath (Rep path)) => Request method [Text] query headers body -> Request method path query headers body
- queryOf :: (Generic query, GQuery (Rep query)) => Request method path Query headers body -> Request method path query headers body
- headersOf :: (Generic headers, GHeaders (Rep headers)) => Request method path query RequestHeaders body -> Request method path query headers body
- response :: Response Status ResponseHeaders (IO ByteString)
- status200 :: Response S200 ResponseHeaders (IO ByteString)
- status201 :: Response S201 ResponseHeaders (IO ByteString)
- status204 :: Response S204 ResponseHeaders (IO ByteString)
- status404 :: Response S404 ResponseHeaders (IO ByteString)
- status500 :: Response S500 ResponseHeaders (IO ByteString)
- segment :: Text -> Leaf Path a -> Tree Path a a
- segment_ :: Leaf Path a -> a -> Tree Path () ()
- segments :: Leaf Path a -> Tree Path (NonEmpty a) (NonEmpty a)
- param :: Text -> Leaf Query a -> Tree Query a a
- param' :: Text -> Leaf Query a -> Tree Query (Maybe a) (Maybe a)
- param_ :: Text -> Leaf Query a -> a -> Tree Query () ()
- flag :: Text -> Tree Query () ()
- flag' :: Text -> Tree Query Bool Bool
- list :: ArrayStyle -> Text -> Leaf Query a -> Tree Query (NonEmpty a) (NonEmpty a)
- list' :: ArrayStyle -> Text -> Leaf Query a -> Tree Query [a] [a]
- field :: HeaderName -> Leaf Headers a -> Tree Headers a a
- field' :: HeaderName -> Leaf Headers a -> Tree Headers (Maybe a) (Maybe a)
- field_ :: HeaderName -> ByteString -> Tree Headers h h -> Tree Headers h h
- contentType :: MediaType -> Tree Headers h h -> Tree Headers h h
- cookie :: ByteString -> Leaf Cookie a -> Tree Headers a a
- cookie' :: ByteString -> Leaf Cookie a -> Tree Headers (Maybe a) (Maybe a)
- fieldRFC9651 :: HeaderName -> Tree RFC9651 a a -> Tree Headers a a
- fieldBareItem :: HeaderName -> Leaf (BareItem :: Type -> Type) a -> Tree Headers a a
- fieldItem :: HeaderName -> Tree Item a a -> Tree Headers a a
- fieldList :: HeaderName -> Tree List a a -> Tree Headers a a
- fieldDictionary :: HeaderName -> Tree Dictionary a a -> Tree Headers a a
- attribute :: ByteString -> Leaf Attributes a -> Tree Attributes a a
- attribute' :: ByteString -> Leaf Attributes a -> Tree Attributes (Maybe a) (Maybe a)
- secure :: Tree Attributes () ()
- httpOnly :: Tree Attributes () ()
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
| 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 # | |
| GenericOAPI (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) Source # | |
| GClient (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Client (Shape method path query headers body result)))) Source # | |
| GLink (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Link (Shape method path query headers body result)))) Source # | |
data Shape method path query headers body result Source #
Instances
| 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 # | |
| GenericOAPI (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) Source # | |
| GClient (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Client (Shape method path query headers body result)))) Source # | |
| GLink (S1 sm (Rec0 (Forest (Shape method path query headers body result)))) (S1 sm' (Rec0 (Link (Shape method path query headers body result)))) Source # | |
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) |
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) |
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 #
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
| Show ClientError Source # | |
Defined in Okapi.Mode.Client Methods showsPrec :: Int -> ClientError -> ShowS # show :: ClientError -> String # showList :: [ClientError] -> ShowS # | |
| Eq ClientError Source # | |
Defined in Okapi.Mode.Client | |
data ClientSettings Source #
Constructors
| ClientSettings | |
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) |
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
| Show (KnownMethod m) Source # | |
Defined in Okapi.HTTP.Request.Method Methods showsPrec :: Int -> KnownMethod m -> ShowS # show :: KnownMethod m -> String # showList :: [KnownMethod m] -> ShowS # | |
| Eq (KnownMethod m) Source # | |
Defined in Okapi.HTTP.Request.Method Methods (==) :: KnownMethod m -> KnownMethod m -> Bool # (/=) :: KnownMethod m -> KnownMethod m -> Bool # | |
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
type S200 = KnownStatus 200 Source #
type S201 = KnownStatus 201 Source #
type S204 = KnownStatus 204 Source #
type S404 = KnownStatus 404 Source #
type S500 = KnownStatus 500 Source #
data ArrayStyle Source #
Constructors
| Exploded | |
| CommaDelimited | |
| SpaceDelimited | |
| PipeDelimited |
Instances
| Show ArrayStyle Source # | |
Defined in Okapi.HTTP.Request.Query Methods showsPrec :: Int -> ArrayStyle -> ShowS # show :: ArrayStyle -> String # showList :: [ArrayStyle] -> ShowS # | |
| Eq ArrayStyle Source # | |
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 #
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 #
class HasLeaf (t :: Type -> Type) a where Source #
Instances
(=.) :: Profunctor p => (a -> b) -> p b c -> p a c infixr 5 Source #
scientific :: forall (t :: Type -> Type). HasLeaf t Scientific => Leaf t Scientific Source #
request :: Request Method [Text] Query RequestHeaders (IO ByteString) Source #
methodGET :: Request GET [Text] Query RequestHeaders (IO ByteString) Source #
methodPOST :: Request POST [Text] Query RequestHeaders (IO ByteString) Source #
methodPUT :: Request PUT [Text] Query RequestHeaders (IO ByteString) 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)
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)
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)
field_ :: HeaderName -> ByteString -> Tree Headers h h -> Tree Headers h h Source #
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)
fieldRFC9651 :: HeaderName -> Tree RFC9651 a a -> Tree Headers a a Source #
fieldBareItem :: HeaderName -> Leaf (BareItem :: Type -> Type) a -> Tree Headers a a Source #
fieldDictionary :: HeaderName -> Tree Dictionary a a -> Tree Headers a a Source #
attribute :: ByteString -> Leaf Attributes a -> Tree Attributes a a Source #
attribute' :: ByteString -> Leaf Attributes a -> Tree Attributes (Maybe a) (Maybe a) Source #
secure :: Tree Attributes () () Source #
httpOnly :: Tree Attributes () () Source #