#11159 closed bug (fixed)

'-interactive-print myPrint' forgotten after :load or :reload

Reported by: hukarere Owned by:
Priority: normal Milestone: 8.0.1
Component: Documentation Version: 7.6.3
Keywords: Cc: bravit, watashi
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #5461 Differential Rev(s):
Wiki Page:



I would like to use a custom print function. I tried all possible ways for setting it: (1) running ghci -interactive-print myPrint; (2) adding ':set -interactive-print myPrint' to ~/.ghci; (3) typing ':set -interactive-print myPrint' interactively. It works, but only before :load or :reload. After that,it's forgotten (standard print used again) and I have to type ':set -interactive-print myPrint' again. Is there a way to make this setting persistent, i. e. survive after :load or :reload?


Change History (8)

comment:1 Changed 18 months ago by hukarere


I forgot to mention my version of ghc: 7.6.3.

comment:2 Changed 18 months ago by thomie

Cc: bravit added

Still a problem with HEAD.

Maybe the creator of this feature, @bravit, knows a solution?

comment:3 Changed 18 months ago by thomie

Component: CompilerGHCi

comment:4 Changed 17 months ago by bravit

This was fixed already in https://phabricator.haskell.org/D867

It works as expected in HEAD, but not in 7.10.3.

Last edited 17 months ago by bravit (previous) (diff)

comment:5 Changed 17 months ago by thomie

Cc: watashi added

Hi bravit, thanks for having a look.

After a :reload, the interactive printer doesn't work anymore. Here is an example.

$ cat Test.hs
module SpecPrinter where
import System.IO

sprint a = putStrLn $ show a ++ "!"
$ ~/ghc-devel2/inplace/bin/ghc-stage2 --version
The Glorious Glasgow Haskell Compilation System, version 7.11.20151216
$ ~/ghc-devel2/inplace/bin/ghc-stage2 --interactive -interactive-print=SpecPrinter.sprint Test
GHCi, version 7.11.20151216: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling SpecPrinter      ( Test.hs, interpreted )
Ok, modules loaded: SpecPrinter.
*SpecPrinter> "hi"
*SpecPrinter> :reload
Ok, modules loaded: SpecPrinter.
*SpecPrinter> "hi"

Note that after the :reload, the exclamation mark (!) isn't printed anymore.

Do you agree this is not working as expected? I'm seeing the same behaviour with ghc-7.10.3 as with HEAD.

CC @watashi, as the author of D867. I also note that a test was missing from that Diff, so maybe it recently got broken again?

comment:6 Changed 17 months ago by bravit

Hi thomie,

If interactive printing function is defined in external package then it is kept after reloading (thanks to D867, now in HEAD). If it is defined locally then it is no more effective after reloading, it's a new function in some way. I consider this behaviour as reasonable. Don't you agree?

comment:7 Changed 17 months ago by Thomas Miedema <thomasmiedema@…>

In 7cddcde/ghc:

Docs: -interactive-print should reside in registered package

Since commit 03c4893e355948fe865bc52c744359c42e4b06d7, ic_int_print is
retained from registered packages after `:reload`.

Fixes #11159.

comment:8 Changed 17 months ago by thomie

Component: GHCiDocumentation
Milestone: 8.0.1
Resolution: fixed
Status: newclosed

Ah, ok, I missed the "external package" part. Sounds reasonable.

I updated the User's Guide to mention this.


Note: See TracTickets for help on using tickets.