You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When implementing a simple type class going through a type alias, functions which should type check don't, and the error it gives doesn't make much sense.
Desktop (please complete the following information):
Go to the file nspec/docs/prelude.juvix.md and attempt to type check it (you may need to remove the ? in nspec/docs/.juvix-build/0.6.9/deps/[...]/Package.juvix).
On line 506, the line right {B} {A} x will be highlighted with the error
The expression right {B} {A} x has type: Result B A but is expected to have type: Result A _ B A
Expected behavior
I don't believe this should produce an error at all, but Result also only takes two arguments, so the error reporting that it should take four is nonsense anyway.
Screenshots
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered:
You can explicitly declare the type of swap in the instance as a workaround for now:
instance
EitherCommutativeProduct : CommutativeProduct Either :=
mkCommutativeProduct@{
swap {A B} : Result A B -> Result B A := \{ e :=
case e of {
| (left x) := right {B} {A} x
| (right x) := left x
}};
};
alternatively with clearer style:
instance
EitherCommutativeProduct : CommutativeProduct Either :=
mkCommutativeProduct@{
swap {A B} : Result A B -> Result B A
| (left x) := right {B} {A} x
| (right x) := left x;
};
janmasrovira
changed the title
Spurious type checking error generated when using traits and aliases simultaneously
Spurious type checking error generated when using a lambda involving types without a type signature
Jan 8, 2025
Describe the bug
When implementing a simple type class going through a type alias, functions which should type check don't, and the error it gives doesn't make much sense.
Desktop (please complete the following information):
To Reproduce
Steps to reproduce the behavior:
right {B} {A} x
will be highlighted with the errorExpected behavior
I don't believe this should produce an error at all, but Result also only takes two arguments, so the error reporting that it should take four is nonsense anyway.
Screenshots
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: