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

Claus Reinke claus.reinke at talk21.com
Tue Sep 18 09:15:57 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?

as for earlier questions/suggestions in this thread:

>>                      Is there a way to make GHCi not print the result
>> of an action but still make my variables get bound?
>
>This seems to be a common question (I myself asked it recently), so
>I've added an entry to the GHCi page on the wiki.
>
>Ideally, it would be nice if this were discoverable from within GHCi,
>but I'm not sure how this would best be done.

i've run into this myself!-) there is a patch pending for ghc head 
(so it may not be in 6.8.1:-( that would show the GHCi-specific 
flags together with the GHCi options:

    Prelude> :set
    options currently set: none.
    GHCi-specific dynamic flag settings:
      -fno-print-explicit-foralls
      -fprint-bind-result
      -fno-break-on-exception
      -fno-break-on-error
      -fno-print-evld-with-show
    other dynamic, non-language, flag settings:
    ..

so you'd at least know which possibly relevant flags there
are, and if the names are not expressive enough, the :help would
point you to the flag reference:

    :help
    ..
      Options for ':set' and ':unset':
    
        +r            revert top-level expressions after each evaluation
        +s            print timing/memory stats after each evaluation
        +t            print type after evaluation
        -<flags>      most GHC command line flags can also be set here
                             (eg. -v2, -fglasgow-exts, etc.)
                        for GHCi-specific flags, see User's Guide,
                        Flag reference, Interactive-mode options
    ..

>I've always wondered if ghc(i) --help should be a bit more
>instructive, or perhaps if there were a man page that lay somewhere
>between the --help message and the manual in terms of
>comprehensiveness. It's a pretty major jump from a short description
>of 4 command line options (only one of which I have ever used) to the
>entire manual, with a ~10 page table of contents.

please note that the flag reference, which was pointed to 
earlier in this thread, is just such a summary, and there's
a subsection dedicated to GHCi-specific options. there
isn't much in that section in 6.6.1:

http://www.haskell.org/ghc/docs/latest/html/users_guide/flag-reference.html#id3132588

but in ghc head and the upcoming 6.8, you'll find most of 
the GHCi-related flags summarized there.

hth,
claus



More information about the Haskell-Cafe mailing list