News for hackers. Stuff that matters.
Re:Even pure functions have side-effects by ars on Tuesday September 06, 2011 @06:24PM (#2967542)
I don't think pure functions are supposed to throw exceptions, instead they should return error values.
Re:Even pure functions have side-effects by scottdw2 on Tuesday September 06, 2011 @07:34PM (#2967714)
Yes, but they usually use some form of monad to hold either an exception or a value.

The implementation of >>= (haskell calls it bind, buts it's useful to think of it like an overloaded ";" that takes a continuation as a parameter ) examines the return value and decided wether to run the normal path or the exception path...

It doesn't quite perform the same as exceptions do (it burdens both paths with if checks, whereas imperative exceptions only burden the error path)

But the code you write looks almost identical to exception handling code. It doesn't look like something using if checks.

Re:Even pure functions have side-effects by T_S_ on Tuesday September 06, 2011 @11:41PM (#2968248)
The Maybe and Either type classes are typically used to model exceptions in Haskell.
Re:Even pure functions have side-effects by mdwrigh2 on Wednesday September 07, 2011 @12:05AM (#2968310)
There's actually some discussion about how to handle errors in Haskell. See: http://blog.ezyang.com/2011/08/8-ways-to-report-errors-in-ha...