GHCi 6.12.3 stdout redirection works for :type, but not for :info

Claus Reinke claus.reinke at
Mon Sep 20 12:43:20 EDT 2010

Dear GHCi / IO experts,

I'm encountering some odd GHCi behaviour with some
old ghci.conf code of mine (used to work in older GHCis).

The problem is that my code for redirecting the output
of GHCi commands still works for things like :type, but
no longer for things like :info (this is my smallest example
demonstrating the effect).

With the attached GHCi script defining a

    :redir <var> <command>

command that should redirect the ouput of <command>
into variable <var>, we get the output appended below
(note the Exception for WriteConsole "handle is invalid",
which is written into the temporary file when :info is
called while stdout is redirected to that temporary file;
in other words, the error message appears where the
output of the command fails to appear).

Is that an expected change with a known workaround,
so that I just need to update my code, or is that
unexpected behaviour that can only be fixed in GHCi?


PS. This is on Windows 7, if that matters.

------------- example session output
$ -ignore-dot-ghci
GHCi, version 6.12.3:  :? for help
Prelude> :cmd readFile "redir.script"
Prelude> :redir x :t map
Prelude> x
"-- logging GHCi stdout\nmap :: (a -> b) -> [a] -> [b]\n"
Prelude> :redir y :i map
Prelude> y
"-- logging GHCi stdout\n*** Exception: WriteConsole: invalid argument (Das 
Handle ist ung\252ltig.)\n"

-------------- next part --------------
A non-text attachment was scrubbed...
Name: redir.script
Type: application/octet-stream
Size: 843 bytes
Desc: not available
Url :

More information about the Glasgow-haskell-users mailing list