CIr*_*ine 6 erlang haskell elixir pattern-matching
我对Haskell的模式匹配行为感到困惑.如果我在Erlang或Elixir中将1与2匹配,我希望得到匹配错误消息.在Haskell中,ghci只是默默接受匹配尝试.
使用Erlang:
2> 1 = 2.
** exception error: no match of right hand side value 2
Run Code Online (Sandbox Code Playgroud)
在iex中使用Elixir:
iex(1)> 1 = 2
** (MatchError) no match of right hand side value: 2
Run Code Online (Sandbox Code Playgroud)
但是,在ghci中使用Haskell:
Prelude> 1 = 2
Prelude>
Run Code Online (Sandbox Code Playgroud)
有人可以解释为什么Haskell不报告匹配错误?