Skip to content

Commit 5c1c376

Browse files
committed
Add NamedRoutes instance for IsElem
1 parent 02242e9 commit 5c1c376

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

changelog.d/1699

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
synopsis: Add NamedRoutes instance to IsElem
2+
prs: #1699
3+
issues: #1674
4+
description: {
5+
Add missing IsElem instance for NamedRoutes, this allows links to be checked
6+
with `safeLink`.
7+
}

servant/src/Servant/API/TypeLevel.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ import Servant.API.QueryParam
6464
(QueryFlag, QueryParam, QueryParams)
6565
import Servant.API.ReqBody
6666
(ReqBody)
67+
import Servant.API.NamedRoutes
68+
(NamedRoutes)
69+
import Servant.API.Generic
70+
(ToServantApi)
6771
import Servant.API.Sub
6872
(type (:>))
6973
import Servant.API.Verbs
@@ -142,6 +146,7 @@ type family IsElem endpoint api :: Constraint where
142146
IsElem (Verb m s ct typ) (Verb m s ct' typ)
143147
= IsSubList ct ct'
144148
IsElem e e = ()
149+
IsElem e (NamedRoutes rs) = IsElem e (ToServantApi rs)
145150
IsElem e a = IsElem' e a
146151

147152
-- | Check whether @sub@ is a sub-API of @api@.

0 commit comments

Comments
 (0)