Opened 4 years ago

Closed 15 months 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 Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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 4 years ago by igloo

  • Milestone set to 6.16.1

comment:2 Changed 2 years ago by igloo

  • Milestone changed from 7.4.1 to 7.6.1
  • Priority changed from normal to low

comment:3 Changed 19 months ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2

comment:4 Changed 15 months ago by monoidal

  • Resolution set to duplicate
  • Status changed from new to closed

Fixed in GHC 7.6.1, see #5461.

Note: See TracTickets for help on using tickets.