[英]How do I know where in my Haskell Program an Exception can be Thrown?
I'm working on a 1-10k line personal Haskell project, and I'm using various IO-libraries such as Network.HTTP.Conduit inside workers spawned with Pipes.Concurrent. 我正在开发一个1-10k线路的个人Haskell项目,我正在使用Pipes.Concurrent生成的工人内部使用各种IO库,例如Network.HTTP.Conduit。
I just realized that some of these IO libraries are throwing exceptions in edge cases. 我刚刚意识到其中一些IO库在边缘情况下抛出异常。
Is there any way for GHC to give me compile-time warnings about uncaught exceptions? 有没有办法让GHC给我关于未捕获异常的编译时警告? What is the best way to find out the exceptions a library can throw?
找出库可以抛出的异常的最佳方法是什么?
Thanks! 谢谢!
Just answering my own question as it stands in 2018. Hopefully this will improve over time. 只是在2018年回答我自己的问题。希望这会随着时间的推移而改善。
At compile-time, there is no way to know which parts of your Haskell program can throw exceptions. 在编译时,无法知道Haskell程序的哪些部分可以抛出异常。 Some libraries choose to return Either/Maybe monads to deal with edge cases safely and others choose to throw exceptions.
有些库选择返回Either / Maybe monad来安全地处理边缘情况,而其他库则选择抛出异常。
Personally, I believe this makes Haskell a lot less attractive to run in production, especially since these exceptions will rarely have stack traces. 就个人而言,我认为这使得Haskell在生产中运行的吸引力降低了很多,特别是因为这些异常很少有堆栈跟踪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.