# Non-monolithic version of 'sequence' for IO monad?

**Levent Erkok
**
erkok@cse.ogi.edu

*Tue, 6 Nov 2001 08:59:01 +0000*

On Tuesday 06 November 2001 01:20 pm, Josef Svenningsson wrote:
>* Let me elaborate on the strictness of a monad. The strictness of a monad
*>* depends on how one implements the `bind' function. If the monad has a
*>* strict bind then in examples like Koen's the print function will never be
*>* called. If bind is lazy then the list will be produced incrementally.
*
Can you elaborate? The bind for the Maybe monad is strict in its first argument.
Is the Maybe monad strict in your sense? If that's the case, we should understand
what is a bottom for the type IO a (for some type a), before deciding
whether the IO monad is strict or not. Do you have a definition for that?
Coming back to IO monad, I'd rather say it's eager (trying to avoid the word
strict, but that's what I mean) in its actions, but certainly not in the values
it produces. All the actions will be performed before you can view any results,
but the results themselves are lazily produced. My favorite example is:
fixIO (\cs -> getChar >>= \c -> return (c:cs))
you wait until getChar is done, but the final list is produced lazily.
I'd really love to see a more formal definition of the strictness of a monad,
especically for internal monads like IO and ST.
-Levent.