[Haskell-cafe] How can I stop GHCi from calling "show" for IOactions?

Dougal Stanton ithika at gmail.com
Thu Sep 20 17:50:38 EDT 2007

On 20/09/2007, Ryan Ingram <ryani.spam at gmail.com> wrote:

> I think a more consistent behavior would be to not print the LHS at
> all.  If you wanted to print the result of the computation you could
> just do:
>     Prelude> bar 5
> or, if you also wanted bound variables afterwards:
>     Prelude> (x, Just y) <- bar 5
>     Prelude> (x, Just y)
> Perhaps this is my imperative background speaking, but I don't see
> much difference at the GHCi prompt between these two:
>     Prelude> let x = 5
>     Prelude> x <- return 5

I agree with this interpretation. If I want to just *do* the action,
I'll type it. If I want to *store* the action then I'll bind it to
something. That's the intuition I have, anyway. And it works for pure

Prelude> let ns = [1..]
Prelude> [1..]

The difference between those two feels like the difference between:

Prelude> contents <- readFile "massive.txt"
Prelude> readFile "massive.txt"

But as Ryan mentioned, this may just be poor intuition from an overly
imperative mindset...



More information about the Haskell-Cafe mailing list