From a4194dc490c689a5d6ca4baf94ba4c5985b43e15 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Fri, 23 Dec 2022 09:42:52 +0100 Subject: [PATCH] feat: Polymorphic `Elem` for `Union` (#1637) Close https://github.com/haskell-servant/servant/issues/1590 --- servant/src/Servant/API/UVerb/Union.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/servant/src/Servant/API/UVerb/Union.hs b/servant/src/Servant/API/UVerb/Union.hs index 11d93e74..696b54dd 100644 --- a/servant/src/Servant/API/UVerb/Union.hs +++ b/servant/src/Servant/API/UVerb/Union.hs @@ -128,9 +128,9 @@ type DuplicateElementError (rs :: [k]) = ':$$: 'Text " " ':<>: 'ShowType rs type family Elem (x :: k) (xs :: [k]) :: Bool where + Elem x (x ': _) = 'True + Elem x (_ ': xs) = Elem x xs Elem _ '[] = 'False - Elem x (x' ': xs) = - If (x == x') 'True (Elem x xs) type family Unique xs :: Constraint where Unique xs = If (Nubbed xs == 'True) (() :: Constraint) (TypeError (DuplicateElementError xs))