I’ve been writing more and more Haskell lately, as part of a side project involving GraphQL. As part of working with the language, I’ve had to work with its compile errors. The Haskell compiler gives you errors that are extremely informative—if you know the language. If you don’t know the language very well, the compiler errors can occasionally be opaque and unhelpful.
I’ve very much enjoyed using Haskell, and I figure the best way for me to give back to the community is to make this situation a little better. In order to do this, we’re going to take a fun dive into Haskell errors, why they’re confusing, and how they might be improved.
This is very much not a literate Haskell file, because none of the snippets within will actually compile! You can discuss this post here.
On a pure technical level, this is correct. The usage of (+), as a function with type signature (Num a) => a -> a -> a, causes a constraint to arise in the program. However, the word arise is a little confusing here. I’ve personally seen my friends think this has something to do with “raising” in the sense of exceptions in a Ruby program. One simple language change already improves clarity: