fix type instance conflict#3
Conversation
|
Take this with a grain of salt, because I only have a thin grasp of type-level programming, but I think this makes more sense: type family (<+>) (a :: k1) (b :: k2) :: Constraint
type instance (<+>) _ [] = (() :: Constraint)
type instance (<+>) [] _ = (() :: Constraint)
-type instance (<+>) (c ': cs) (a :: Type) = (c a, a <+> cs)
-type instance (<+>) c (a ': as) = (c a, c <+> as)
+type instance (<+>) (c ': cs) (a ': as) = (c a, cs <+> a, c <+> as)
infixl 9 <+>If either are empty, it's already bailed, so we know both have at least one element, so we apply the first element of each list to each other, then each element of the rest of the first list to the first element of the second list and each element of the rest of the second list to the first element of the first list. I dunno why GHC is saying @Shou are we off track here? Edit: I guess each element of both lists has to also be applied to each other, so: -type instance (<+>) (c ': cs) (a ': as) = (c a, cs <+> a, c <+> as)
+type instance (<+>) (c ': cs) (a ': as) = (c a, cs <+> a, c <+> as, cs <+> as) |
|
Hey, @GuillaumedeVolpiano, since you already have the repo forked, if you think my solution makes more sense, would you go ahead and apply it on your PR?; I can't be bothered to make another PR. |
|
How would you even write type-level tests for type-level functions? I think this library needs a test suite. |
Fixes #1
Not sure it's the best way to do it, but for now, it's the only one I've found.