Opened 7 years ago

Closed 5 years ago

#4177 closed feature request (duplicate)

GHCi should allow custom definition of print for implicit output

Reported by: ezyang Owned by:
Priority: low Milestone: 7.6.2
Component: GHCi Version: 6.10.4
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Right now, a value of type a desugars to:

let it = expr
print it

Where print is actually an identifier referencing System.IO.print. This makes it a tad difficult for users to overload the behavior of print for their own nefarious (debugging) purposes.

I propose that we allow some way of overriding the print used for printing statements. I think there are few ways we could do this:

  • We could look in the user bindings and check to see if there is print defined, and then use that instead. This would truly make this “just an extension to the Prelude”, but if there are conflicting definitions of print the user may not appreciate the breakage (though they'd be able to just let print = ... to resolve the ambiguity).
  • We could look in the user bindings and check to see if there is some magic variable corresponding to print defined, and use that instead.
  • We could add a command that adds a special binding for print and references that instead (default being System.IO.Print).

I have a vague idea how you might implement the first two by editing ./compiler/typecheck/TcRnDriver.lhs, although I don't know how one would make the local binding information available at that location. I have no idea how to implement the latter.

Change History (4)

comment:1 Changed 7 years ago by igloo

Milestone: 6.16.1

comment:2 Changed 6 years ago by igloo

Priority: normallow

comment:3 Changed 5 years ago by igloo


comment:4 Changed 5 years ago by monoidal

Resolution: duplicate
Status: newclosed

Fixed in GHC 7.6.1, see #5461.

Note: See TracTickets for help on using tickets.