-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add COMPLETE pragma for Vec: Nil, (:>) #2716
Add COMPLETE pragma for Vec: Nil, (:>) #2716
Conversation
It looks like the tests are failing, but as far as I can tell the errors have nothing to do with my changes. |
Can you rebase @axman6? The CI failures are caused by haskell-actions/setup#77, and has been worked around in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does LGTM. Surprising we didn't have this.
Hmm, I had hoped that I could rebase in github, but apparently it just merges the target branch in - hopefully this is still fine. |
f4f97e3
to
a6cf272
Compare
Ok, I've rebased properly now, we'll see how this goes (though merging in master also didn't pass which is odd). |
a6cf272
to
d71bb3c
Compare
I've rebased again.. Hopefully the CI errors are now gone. @christiaanb could you give this a look to? To me this looks "obviously correct", but we had some subtleties creeping in with |
Nil and :> . From that perspective I’d rather the compiler suggests you use Cons .
|
Sure, that would be a good reason to remove the patterns entirely, but we've tried before and couldn't for various reasons. So while we're stuck with them, isn't the correct thing to do is add a complete pragma? Or are you saying that that makes things worse somehow? |
I guess we're fine, I cannot even get a recursive function to type-check: module Test where
import Clash.Prelude
myMap :: forall n a b . (a -> b) -> Vec n a -> Vec n b
myMap _ Nil = Nil
myMap f (x :> (xs :: Vec m a)) = f x :> myMap f xs
topEntity :: Vec 3 Int -> Vec 3 Int
topEntity = myMap (+1) gives:
So I guess I don't have to worry that Clash won't be able to unroll the recursion. |
I was banging my head against some type errors for hours until I decided to use the `Cons` constructor instead of the `:>` pattern - hopefully this will save someone else the same pain.
d71bb3c
to
3f4f65a
Compare
Thanks for the comment @christiaanb, thanks for the CI fixes @DigitalBrains1. I think we can merge this one. |
I was banging my head against some type errors for hours until I decided to use the
Cons
constructor instead of the:>
pattern - hopefully this will save someone else the same pain.Still TODO: