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

Stefan O'Rear stefanor at cox.net
Sat Sep 15 23:44:33 EDT 2007


On Sat, Sep 15, 2007 at 08:35:02PM -0700, Ryan Ingram wrote:
> Prelude> let inf = repeat 1
> Prelude> inf
> [1,1,(lots of output until I press ctrl-c),Interrupted.
> (I expect this to happen)
> Prelude> let x = inf
> (no output here!)
> Prelude> :t x
> x :: [Integer]
> Prelude> return inf
> [1,1,(lots of output until I press ctrl-c),Interrupted.
> (I also expect this to happen)
> Prelude> y <- return inf
> [1,1,(lots of output until I press ctrl-c),Interrupted.
> (I do not expect this to happen here!)
> Prelude> :t y
> 
> <interactive>:1:0: Not in scope: 'y'
> 
> Is this a bug?  Why does "y <- return exp" have different behavior
> than "let y = exp"?  Is there a way to make GHCi not print the result
> of an action but still make my variables get bound?

GHC manual, Flag reference, Interactive-mode options:

| -fno-print-bind-result │ Turn off printing of binding results in GHCi      │ dynamic        │ -       │

with a link to:

http://haskell.org/ghc/dist/current/docs/users_guide/interactive-evaluation.html#ghci-stmts

"Note that let bindings do not automatically print the value bound,
unlike monadic bindings."

"The automatic printing of binding results can be supressed with :set
-fno-print-bind-result (this does not supress printing the result of
non-binding statements).  You might want to do this to prevent the
result of binding statements from being fully evaluated by the act of
printing them, for example."

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070915/68c63d42/attachment.bin


More information about the Haskell-Cafe mailing list