问题
I'm learning Idris and I got stuck on a very simple lemma that shows that some specific index is impossible for a data type. I've tried to use impossible patterns but Idris refuses them with the following error message:
RegExp.idr line 32 col 13:
hasEmptyZero prf is a valid case
The complete code piece is available in the following gist:
https://gist.github.com/rodrigogribeiro/f27f1f035e5a98f506ee
Any help is appreciated.
回答1:
I've talk with people at freenode Idris community and they explained to me that absurd pattern needs a explicit impossible case in order to detect that is really impossible. As an example:
hasEmptyZero : HasEmpty Zero -> Void
hasEmptyZero HasEps impossible
Here putting the constructor HasEps
helps Idris to detect that it cannot be used to construct a value of type HasEmpty Zero
. The complete (working) code is at the following gist:
https://gist.github.com/rodrigogribeiro/5b39048df1d9ddc083ec
来源:https://stackoverflow.com/questions/32947534/impossible-patterns-in-idris