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

Simon Peyton-Jones simonpj at microsoft.com
Thu Sep 20 03:41:03 EDT 2007

| >| It seems that GHCi outputs the contents of the variable you've created
| >| when there's only one of them.
| >
| >Indeed, that is documented behaviour (first bullet here:
| >http://www.haskell.org/ghc/docs/latest/html/users_guide/ch03s04.html#ghci-stmts
| >)
| >Perhaps it's confusing behaviour?  If so do suggest an alternative.
| why not simply do what the flag suggests, either always try to
| print the bind-result, or never? i assume there has been a use
| case where this special case has been found useful/necessary?

Hmm.  Currently GHCi prints the value of the *variable* that you bind.  For example

        Just x <- foo 4

will print the value of x, *not* the value of (Just x).  So if two variables are bound, there'd be two values to print.

But an alternative behaviour would be to print the value of the LHS, constructors and all. That is in the above example, print
        Just <value of x>
Then if there were two values, for example
        (x,Just y) <- bar 5
then it'd print
        ( <value of x>, Just <value of y> )

That would be a change from current behaviour, but it'd look identical when the LHS was a simple variable (the wildly common case), and it'd do something useful when multiple variables are bound.

I'll add a Trac feature request so as not to forget this suggestion.


More information about the Haskell-Cafe mailing list