Closed rgrover closed 4 years ago
Try ~=~
instead of =
.
||| Explicit heterogeneous ("John Major") equality. Use this when Idris
||| incorrectly chooses homogeneous equality for `(=)`.
||| @ a the type of the left side
||| @ b the type of the right side
||| @ x the left side
||| @ y the right side
public export
(~=~) : (x : a) -> (y : b) -> Type
(~=~) = Equal
thanks.
Any suggestions on how to define vectNilRightNeutral in this new world with heterogeneous equality?
vectNilRightNeutral : (xs : Vect len a) -> (xs ++ []) ~=~ xs
vectNilRightNeutral [] = Refl
vectNilRightNeutral (x :: xs) =
let inductiveHypothesis = vectNilRightNeutral xs
in rewrite inductiveHypothesis
in Refl
compiles to the error message:
Can't solve constraint between:
len
and
plus len 0
Compiling the following declaration emits an error message. The code is adapted from the nearly identical function in
Data.Vect.idr
in Idris1.Steps to Reproduce
Expected Behavior
Should compile.
Observed Behavior
Why is the type-system complaining in this case?
Switching the order of arguments to
++
satisfies the type-checker (quite likely following from the definition ofplus
whereplus n 0
cannot be normalized any further):Nevertheless, it should not be a problem to state the type
xs ++ [] = xs
.Typing the following on the Idris2 REPl gives the same error: