为什么Haskell报告不匹配1 = 2?

时间:2018-04-29 15:56:05

标签: haskell erlang pattern-matching elixir

我对Haskell的模式匹配行为感到困惑。如果我在Erlang或Elixir中将1与2匹配,我希望得到匹配错误消息。在Haskell中,ghci只是默默接受匹配尝试。

在erl中使用Erlang:

2> 1 = 2.
** exception error: no match of right hand side value 2

在iex中使用Elixir:

iex(1)> 1 = 2
** (MatchError) no match of right hand side value: 2

但是,Haskell在ghci:

Prelude> 1 = 2
Prelude> 

有人可以解释为什么Haskell不会报告匹配错误吗?

0 个答案:

没有答案