简体   繁体   English

我怎么知道我的Haskell程序中可以抛出异常?

[英]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.

相关问题 如何使我的 Haskell 功能在我的 Python Flask 应用程序中可用? - How do I make my Haskell functions available in my Python Flask app? 春季:如何知道查询来自何处? 使用@RequestHeader(值=“用户代理”) - Spring : How do I know where a query comes from? using @RequestHeader (value = “User-Agent”) 如何使用 observable .map 和 .subscribe 处理我的数据 - How to where do i process my data with observable .map and .subscribe 发生异常后如何返回循环? - How can I return to my loop after an exception? 我如何知道我的网站是通过HTTP还是HTTP / 2提供? - How do I know if my website is being served over HTTP or HTTP/2? 我怎么知道一个网站是否接受iframe? - How do I know if a website accepts iframes? 我怎么知道要使用哪个NSURLRequestCachePolicy - How do I know which NSURLRequestCachePolicy to use 我如何知道每个限制的偏移量? - How do I know the offset for each limit? 如何从我的命令行程序调试 HTTPS 发布请求? - How do I debug HTTPS post requests from my commandline program? 如何将本地ipv6地址绑定到我的node.js程序? - How do I bind local ipv6 address to my node.js program?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM