Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like this too, but it's worth noting two things:

1) this is from 2007

2) Real World Haskell (which is authored in part by dons) recommends against using fail, and it's much more recent.

From http://book.realworldhaskell.org/read/monads.html :

Warning - Beware of fail

Many Monad instances don't override the default implementation of fail that we show here, so in those monads, fail uses error. Calling error is usually highly undesirable, since it throws an exception that callers either cannot catch or will not expect.

Even if you know that right now you're executing in a monad that has fail do something more sensible, we still recommend avoiding it. It's far too easy to cause yourself a problem later when you refactor your code and forget that a previously safe use of fail might be dangerous in its new context.



Thanks for stomping on my dreams. :P

In any case, Haskell's not the only institution that's tried to deprecate fail:

http://news.bbc.co.uk/1/hi/england/suffolk/4724703.stm




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: