@@ -136,6 +136,10 @@ type family Or (a :: Constraint) (b :: Constraint) :: Constraint where
136 Or () b = ()
136 Or () b = ()
137 Or a () = ()
137 Or a () = ()
139+-- | If both a or b produce an empty constraint, produce an empty constraint.
140+type family And (a :: Constraint) (b :: Constraint) :: Constraint where
139-- | You may use this type family to tell the type checker that your custom type
143-- | You may use this type family to tell the type checker that your custom type
140-- may be skipped as part of a link. This is useful for things like
144-- may be skipped as part of a link. This is useful for things like
141-- 'QueryParam' that are optional in a URI and do not affect them if they are
145-- 'QueryParam' that are optional in a URI and do not affect them if they are
@@ -164,29 +168,19 @@ type family IsElem endpoint api :: Constraint where
164 IsElem sa (MatrixParam x y :> sb) = IsElem sa sb
168 IsElem sa (MatrixParam x y :> sb) = IsElem sa sb
165 IsElem sa (MatrixParams x y :> sb) = IsElem sa sb
169 IsElem sa (MatrixParams x y :> sb) = IsElem sa sb
166 IsElem sa (MatrixFlag x :> sb) = IsElem sa sb
170 IsElem sa (MatrixFlag x :> sb) = IsElem sa sb
168− IsElem e a = IsElem' e a
169 IsElem (Get ct typ) (Get ct' typ) = IsSubList ct ct'
171 IsElem (Get ct typ) (Get ct' typ) = IsSubList ct ct'
170 IsElem (Post ct typ) (Post ct' typ) = IsSubList ct ct'
172 IsElem (Post ct typ) (Post ct' typ) = IsSubList ct ct'
171 IsElem (Put ct typ) (Put ct' typ) = IsSubList ct ct'
173 IsElem (Put ct typ) (Put ct' typ) = IsSubList ct ct'
172− IsElem e e = 'True
174+ IsElem e e = ()
173− IsElem e a = 'False
175+ IsElem e a = IsElem' e a
176−type family IsSubList a b where
178+type family IsSubList a b :: Constraint where
177− IsSubList '[] b = 'True
179+ IsSubList '[] b = ()
178− IsSubList '[x] (x ': xs) = 'True
180+ IsSubList '[x] (x ': xs) = ()
179 IsSubList '[x] (y ': ys) = IsSubList '[x] ys
181 IsSubList '[x] (y ': ys) = IsSubList '[x] ys
180 IsSubList (x ': xs) y = IsSubList '[x] y `And` IsSubList xs y
182 IsSubList (x ': xs) y = IsSubList '[x] y `And` IsSubList xs y
181− IsSubList a b = 'False
183+ IsSubList a b = 'True ~ 'False
183−type family IsLink'' l where
184− IsLink'' (e :> Get cts x) = IsLink' e
185− IsLink'' (e :> Post cts x) = IsLink' e
186− IsLink'' (e :> Put cts x) = IsLink' e
187− IsLink'' (e :> Delete) = IsLink' e
191-- Phantom types for Param
185-- Phantom types for Param
192data Matrix
186data Matrix
@@ -343,7 +337,7 @@ instance HasLink (Get y r) where
343 type MkLink (Get y r) = URI
337 type MkLink (Get y r) = URI
344 toLink _ = linkURI
338 toLink _ = linkURI
346−instance HasLink (Post r) where
340+instance HasLink (Post y r) where
347 type MkLink (Post y r) = URI
341 type MkLink (Post y r) = URI
348 toLink _ = linkURI
342 toLink _ = linkURI