Impossible patterns in Idris

橙三吉。 提交于 2019-12-12 11:34:51

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!