GHCi should allow custom definition of print for implicit output
|Reported by:||ezyang||Owned by:|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Revisions:|
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:2 Changed 3 years ago by igloo
- Milestone changed from 7.4.1 to 7.6.1
- Priority changed from normal to low