-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replicate from the singletons paper doesn't typecheck - issue with induction with SingI
#578
Comments
The paper assumes that the replicate :: forall n a . (SingI n) => a -> Vec n a
replicate a = case (sing :: Sing n) of
SZero -> Nil
- SSucc _ -> a :> replicate a
+ SSucc m -> withSingI m $ a :> replicate a |
Another option is to use the replicate :: forall n a . (SingI n) => a -> Vec n a
replicate a = case (sing :: Sing n) of
SZero -> Nil
- SSucc _ -> a :> replicate a
+ SSucc Sing -> a :> replicate a The effect is the same, matching on |
@int-index's analysis is spot-on. As for why the modern I'll opt to close this issue, but feel free to re-open it if there is something else amiss. |
Thank you all for the clarifications ! I can now solve the issue with
When I try this I get the following warning. Is that expected ?
|
What GHC/ |
@RyanGlScott GHC 9.2.7 and singletons-3.0.2 according to the issue description |
Sorry, my mistake, actually I was using ghc 9.0.2. Updating to 9.4.7 (current recommended in ghcup) solves the issue. |
Thanks for confirming! My guess is that you ran into an old GHC bug that made its pattern-match coverage checking results unreliable in the presence of GADTs + pattern synonyms. Happily, newer GHCs appear to handle this much better. |
Hi,
I can't seem to replicate the replicate :-) function from the singletons paper (page 5).
I get the error:
In general I can't seem to do induction with SingI n where n is a Nat. I've been going around this to define all the functions as receiving SNat and then doing some versions with SingI n which just call the SNat versions, but the papers claims that I could define a function like replicate using implicit Nat directly.
Any help with this is appreciated !
The text was updated successfully, but these errors were encountered: