Tag Archives: haskell

Adventures in Haskell – Error handling

I fell in love with Haskell almost the day I started using it.  It’s not perfect, though, and one of its weaker areas is error/exception handling.  I’m not going to cover all ways to return errors.  For more details, see 8 ways to report errors in Haskell.
Haskell has an Exception class in the Control.Exception module, [...]

Adventures in Haskell – Pattern Matching

Simple
Another nice feature of Haskell is pattern matching. I glossed over it in the Fibonacci function, so let’s review.
fib :: (Integral t) => t -> t
fib 0 = 1
fib 1 = 1
fib n = fib (n – 1) + fib (n – 2)
Analogous code in Java would be:
public int fib(int n) {
[...]

Adventures in Haskell – Type inference

I’m learning Haskell, so I thought I’d write about my adventures as I go along.
One of the first things I noticed about Haskell (apart from the obvious, such as being functional) is that it is very good about type inference. This means that the vast majority of the time, I don’t need to tell Haskell [...]