Haskell程序比其他语言更容易/容易出现的错误种类? [英] Kinds of bugs that are more likely/prone in Haskell programs than in other languages?

查看:94
本文介绍了Haskell程序比其他语言更容易/容易出现的错误种类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其中一个受到高度赞扬的特性是,如果一个程序编译,它很可能是最正确的,比用一个语言不太复杂或严格的类型系统编写的程序更可靠。



也就是说,Haskell是一个将运行时错误转换为编译错误的系统: - )

我想知道,Haskell编程是否会导致一些程序员可能会引入运行时错误,而这种错误在类型较弱的语言中没有明显的类比(外观和频率)?

一些基本的例子(不是很好,我在寻找什么需要警惕的建议)




  • 由于懒惰引起的渐近性能错误

  • 由于结构错误递归造成的无限循环
  • fundeps / type-families将逻辑推入类型级别,其中代码更神秘且错误更难现货?



其他/更好的陷阱例子?



有关该视图的源代码,请参阅:




  • E。海塞林克。丝绸:使网页功能。 2012年3月伦敦2012年函数式编程交换。

  • C。 J.桑普森。体验报告:Haskell在现实世界中:用懒惰的功能语言编写商业应用程序。在ICFP '09,第185-190页,2009年。

  • S。 WEHR。 Kommerzielle Softwareentwicklung mit Haskell。 Hal6,莱比锡,2011年10月。幻灯片(德文版)


One of the highly-touted features is that if a program compiles, it highly likely to be mostly correct, more so than a program written in a language with a less sophisticated or strict type system.

That is, Haskell is a system for translating runtime errors to compiler errors :-)

I wonder, does programming in Haskell give rise to situations where a programmer could introduce a runtime bug that doesn't have an obvious analog (in appearance and frequency) in a less strongly-typed language?

Some basic examples that pop into my head: (not great, I am looking for advice on what to be wary of)

  • asymptotic performance bugs due to laziness
  • infinite loop due to wrongly structured recursion
  • fundeps/type-families pushing logic to type level, where code is more "arcane" and errors are harder to spot?

Other/better examples of gotchas?

解决方案

It doesn’t have to be asymptotic, but space leaks due to lazyness are a problem in real-world applications of Haskell. I know of Haskell-using companies that completely switched to strict datatypes (while still using the laziness of function parameters).

For sources on that view, see:

  • E. Hesselink. Silk: making the sematic web functional. Functional Programming Exchange 2012, London, March 2012.
  • C. J. Sampson. Experience report: Haskell in the ’real world’: writing a commercial application in a lazy functional lanuage. In ICFP ’09, pages 185–190, 2009.
  • S. Wehr. Kommerzielle Softwareentwicklung mit Haskell. Hal6, Leipzig, Oct 2011. Slides (in German).

这篇关于Haskell程序比其他语言更容易/容易出现的错误种类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆