Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kinds of bugs that are more likely/prone in Haskell programs than in other languages?

Tags:

haskell

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?

like image 232
misterbee Avatar asked Jan 13 '14 17:01

misterbee


1 Answers

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).
like image 103
Joachim Breitner Avatar answered Nov 07 '22 04:11

Joachim Breitner