什么原因导致“无可辩驳的模式失败的模式”这是什么意思? [英] What causes "irrefutable pattern failed for pattern" and what does it mean?

查看:147
本文介绍了什么原因导致“无可辩驳的模式失败的模式”这是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


无可争辩的模式失败模式

irrefutable pattern failed for pattern

是什么意思?
什么情况会导致此运行时错误?

mean? What cases will cause this runtime error?

推荐答案

嗯,我认为这意味着它说的 - 不匹配,但没有其他选择。这个例子:

Well, I assume it means what it says - that a pattern doesn't match but there is no alternative. This example:


但是对于程序:

But for the program:

g x = let Just y = f x in h y 

GHC报告:

Main: M1.hs:9:11-22:
    Irrefutable pattern failed for pattern Data.Maybe.Just y 

显示失败的根源。

来自 http://www.haskell.org/haskellwiki/Debugging

示例的要点是,如果 fx 返回 Nothing 那么GHC就无法为 y 赋值。

The point of the example is that if f x returns Nothing then there is no way GHC can assign a value to y.

这篇关于什么原因导致“无可辩驳的模式失败的模式”这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆