on master help sign in
feat: Polymorphic `Elem` for `Union` (#1637)

Close https://github.com/haskell-servant/servant/issues/1590

commita4194dc490c689a5d6ca4baf94ba4c5985b43e15 authorGuillaume Bouchard <guillaum.bouchard@gmail.com> dateFri 23 Dec 2022, 09:42 (4 years ago) parent6392dce
1 file changed+2−2
servant/src/Servant/API/UVerb/Union.hs+2−2
servant/src/Servant/API/UVerb/Union.hs+2−2
@@ -128,9 +128,9 @@ type DuplicateElementError (rs :: [k]) =
128128 ':$$: 'Text " " ':<>: 'ShowType rs
129129
130130type family Elem (x :: k) (xs :: [k]) :: Bool where
131+ Elem x (x ': _) = 'True
132+ Elem x (_ ': xs) = Elem x xs
131133 Elem _ '[] = 'False
132− Elem x (x' ': xs) =
133− If (x == x') 'True (Elem x xs)
134134
135135type family Unique xs :: Constraint where
136136 Unique xs = If (Nubbed xs == 'True) (() :: Constraint) (TypeError (DuplicateElementError xs))