Idris中Type上的模式匹配 [英] Pattern matching on Type in Idris
本文介绍了Idris中Type上的模式匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能是基本的,但我不明白为什么以下功能为 fnc Nat 和 fnc Integer 回答1,甚至没有包含在模式中
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
推荐答案
您不能对类型进行模式匹配,也不应.当我编译您的代码时,我会收到下一个错误:
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:
- Old discussion.
- Some similar question.
- Some similar issue on GitHub.
更新:
最后找到与答案相关的更重要的问题:
Finally found more relevant question with answer:
这篇关于Idris中Type上的模式匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文