Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IsIn instance for NamedRoutes #1707

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
IsIn e (a :<|> b) = Or (IsIn e a) (IsIn e b)
IsIn (e :> a) (e :> b) = IsIn a b
IsIn e e = ()
IsIn e (NamedRoutes record) = IsIn e (ToServantApi record)

-- | Check whether a type is a member of a list of types.
-- This is a type-level analogue of @'elem'@.
Expand Down Expand Up @@ -75,7 +76,7 @@
-- @'NoContent'@ is removed from the list and not tested. (This allows for leaving the body
-- completely empty on responses to requests that only accept 'application/json', while
-- setting the content-type in the response accordingly.)
type family BodyTypes' c api :: [*] where

Check warning on line 79 in servant-swagger/src/Servant/Swagger/Internal/TypeLevel/API.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.6.2

Using ‘*’ (or its Unicode variant) to mean ‘Data.Kind.Type’

Check warning on line 79 in servant-swagger/src/Servant/Swagger/Internal/TypeLevel/API.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.6.2

Using ‘*’ (or its Unicode variant) to mean ‘Data.Kind.Type’
BodyTypes' c (Verb verb b cs (Headers hdrs a)) = AddBodyType c cs a '[]
BodyTypes' c (Verb verb b cs NoContent) = '[]
BodyTypes' c (Verb verb b cs a) = AddBodyType c cs a '[]
Expand Down
1 change: 1 addition & 0 deletions servant/src/Servant/API/TypeLevel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ type family IsIn (endpoint :: *) (api :: *) :: Constraint where
IsIn e (sa :<|> sb) = Or (IsIn e sa) (IsIn e sb)
IsIn (e :> sa) (e :> sb) = IsIn sa sb
IsIn e e = ()
IsIn e (NamedRoutes record) = IsIn e (ToServantApi record)

-- | Check whether @sub@ is a sub API of @api@.
--
Expand Down
Loading