Re: [Haskell-cafe] Haskell and the Software design process

On Mon, 3 May 2010, Gregory Collins wrote:
Don Stewart
writes: Some key points:
* Avoid partial functions
As an important corollary to this one I would add: "never throw exceptions from pure code". They often leak out from "catch" blocks and ruin your day.
It's not possible to throw exceptions from pure code. You can only call 'error' and that's another name for 'undefined', i.e. you have a partial (non-total ?) function.

Henning Thielemann
It's not possible to throw exceptions from pure code. You can only call 'error' and that's another name for 'undefined', i.e. you have a partial (non-total ?) function.
http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-E...
?
G.
--
Gregory Collins

Gregory Collins schrieb:
Henning Thielemann
writes: It's not possible to throw exceptions from pure code. You can only call 'error' and that's another name for 'undefined', i.e. you have a partial (non-total ?) function.
http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-E...
I see. This should be forbidden, at all! :-)

Henning Thielemann
http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-E...
I see. This should be forbidden, at all! :-)
Why is this worse than or different from 'error'? To me it looks like 'error', only with a non-string parameter. -k -- If I haven't seen further, it is by standing in the footprints of giants

Ketil Malde schrieb:
Henning Thielemann
writes: http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-E...
I see. This should be forbidden, at all! :-)
Why is this worse than or different from 'error'? To me it looks like 'error', only with a non-string parameter.
Because it encourages the use in a non-error way, that is, catching such an exception is regarded as good use.

On May 3, 2010, at 12:14 , Henning Thielemann wrote:
Ketil Malde schrieb:
Henning Thielemann
writes: http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-E...
I see. This should be forbidden, at all! :-)
Why is this worse than or different from 'error'? To me it looks like 'error', only with a non-string parameter.
Because it encourages the use in a non-error way, that is, catching such an exception is regarded as good use.
One could argue that it's a more comprehensible to mortals version of Control.Monad.Cont. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Ketil Malde
Henning Thielemann
writes: http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-E...
I see. This should be forbidden, at all! :-)
Why is this worse than or different from 'error'? To me it looks like 'error', only with a non-string parameter.
Calling 'error' is just as bad IMO!
G
--
Gregory Collins

Gregory Collins
Henning Thielemann
writes:
http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-E...
I see. This should be forbidden, at all! :-)
Why is this worse than or different from 'error'? To me it looks like 'error', only with a non-string parameter.
Calling 'error' is just as bad IMO!
Which is the same as 'as good'? I think error is legitimate in many cases. For instance: * when you know a branch will never be taken, you can add an 'error "this will never happen"' which both informs other readers of the code of the intended usage, and provides a greppable message if you were wrong. * for stub functions during development ('undefined' doesn't tell you which undefined value you tried to evaluate) * Functions like division, which is still useful, even if it is partial. -k -- If I haven't seen further, it is by standing in the footprints of giants
participants (5)
-
Brandon S. Allbery KF8NH
-
Gregory Collins
-
Henning Thielemann
-
Henning Thielemann
-
Ketil Malde