This isn't just a question about Haskell. It applies to any language
with an exception mechanism, including C++ and Java. Even C (segv is
an exception mechanism...)
The question is really how to communicate failure to the caller, in a
way the caller can not ignore, without unduely inconvienencing
Neil Mitchell wrote:
> I suggest you try rewriting this program to be complete:
>
> http://darcs.haskell.org/nofib/imaginary/digits-of-e2/Main.lhs
>
> (if you do, please post the result to the list)
As Gen Zhang noted, the problem seems to be quite straightforward:
just express in types the fact
Dougal Stanton wrote:
The Maybe construction is very useful for explicitly handling
circumstances where the function cannot produce a sensible answer.
But how far should this notion be taken? When you're writing a function
which you realise may not produce what you want, in what circumstances
wo
On Mon, 12 Mar 2007 11:37:43 +
"Neil Mitchell" <[EMAIL PROTECTED]> wrote:
> Catch also checks division by zero, explicit patterns etc. To see the
> world of pain you would be in if you go down the "make everything
> total" route, I suggest you try rewriting this program to be complete:
>
> ht
Hi
> head []
return Nothing? I guess it's a bit of a silly suggestion, but it helps
to highlight why we use Maybe in the first place. So --- where's the
cutoff point in your code?
If that is what you want, then see my Safe library:
http://www-users.cs.york.ac.uk/~ndm/projects/libraries.php#sa
The Maybe construction is very useful for explicitly handling
circumstances where the function cannot produce a sensible answer.
But how far should this notion be taken? When you're writing a function
which you realise may not produce what you want, in what circumstances
would you use a Maybe, and