Pattern matching on Type in Idris

会有一股神秘感。 提交于 2019-12-23 18:04:17

问题


Probably it's elementary but I don't understand why the following function answers 1 for fnc Nat and also, for fnc Integer, which is not even included as a pattern.

fnc : Type -> Integer
fnc Bool = 1
fnc Nat = 2

回答1:


You can't pattern match on type and you shouldn't. When I compile your code I receive next error:

warning - Unreachable case: fnc Nat

This was already discussed earlier:

  1. Old discussion.
  2. Some similar question.
  3. Some similar issue on GitHub.

UPDATE:

Finally found more relevant question with answer:

Why is typecase a bad thing?



来源:https://stackoverflow.com/questions/45439486/pattern-matching-on-type-in-idris

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