抓住错误抛出"错误"?

mis*_*tor 9 haskell exception-handling either

有一些stdlib函数会在无效输入上抛出错误.例如:

Prelude> read "1o2" :: Int
*** Exception: Prelude.read: no parse
Run Code Online (Sandbox Code Playgroud)

我想把它包起来Either e a代替.我怎样才能做到这一点?

Dan*_*ner 14

没有勺子.你没有听到我的消息.

但是,对于这个特定的例子,你应该使用reads.