How to do it?
It does not make sense. Sorry.
In the do block, the following:
a <- b c
equivalent to:
b >>= (\a -> c)
Only a <- b will be equivalent: b >>= (\a ->) , which is a grammar error.
There is no need to store x in the where clause anyway. In your program:
foo :: Int -> IO () foo n = do x <- bar 6 ...
after x <- bar 6 , you can reuse x everywhere in the do block.
source share