modeling out of memory

Cagdas Ozgenc co19@cornell.edu
Mon, 3 Mar 2003 11:12:21 +0200


> > Greetings,
> >
> > 1) How does one model "out of memory" condition in Haskell, perhaps
using a Maybe type?
>
> Unfortuntely not since it would not be referentially transparent. It's
> part of a more general issue of exceptions in pure code.
>
> You can't have
>
> calculateSomething :: X -> Maybe Y
>
> Such that it returns Nothing if it ran out of memory.
>
<snip>
> Probably the thing to do is just catch the exceptions rather than have
> your functions return Maybe types. That way you don't have to deal with
> Maybes all over the place.

Does this make the use of Monads doubtful? I mean it doesn't seem easy to
have a completely pure language, and the time one starts introducing few
impurities one also starts thinking why not include many others?

Just a thought...