[Haskell-beginners] Re: Forcing evalation in the IO Monad

Philip Scott pscott at foo.me.uk
Fri Apr 16 14:50:21 EDT 2010


> Prelude Control.Exception>  let lst = [undefined,undefined] :: [Bool]
> Prelude Control.Exception>  evaluate lst>>= putStrLn . take 1 . show
> [
> Prelude Control.Exception>  evaluate lst>>= print
> [*** Exception: Prelude.undefined
>
>    
Ahh, yes you are of course right. Hmm so, how do we crack this nut 
without resorting to deepSeq etc.. It must be possible, because it 
happens when you print it!

Am I going to have to resort to physically writing the output to /dev/null ?

It seems like such an ordinary thing to want to do, the fact that it is 
hard makes me think I must be approaching this in the wrong way (which 
is usually the case when I get my knickers in a twist with Haskell ;)

- Phil


More information about the Beginners mailing list