[Haskell-cafe] get a string representation (show) of a function argument

Roman Cheplyaka roma at ro-che.info
Sun Apr 1 01:24:36 CEST 2012

* TP <paratribulations at free.fr> [2012-04-01 00:29:15+0200]
> I am wondering if there is any means to get "f 3 5" instead of "8" in the 
> output of this program.

No, this is not possible by referential transparency. The output of your
function can't depend on whether it is passed 8 or the result of f 3 5.

In Lisp-like languages, you could do what you want by using macros.
However, they have their own problems: you have to remember whether
something is a function or a macro, and what quoting it expects. For
instance, have a look at this StackOverflow question (and the answers):

In Haskell you can achieve your goal by using quasiquoting, but, unlike
in Lisp, it won't look like an ordinary function invocation (because it

Roman I. Cheplyaka :: http://ro-che.info/

More information about the Haskell-Cafe mailing list