If the semantics of a language says that a function
f is equivalent to a function g, but there is a function h such that
h(f) is not equivalent to h(g), then h cannot be a function. Therefore
that language cannot be a (purely) functional language. That is the pure and simple reason why functions are not Showable in Haskell. This doesn't mean that it isn't possible to show functions -- even compiled code can usually be reverse-engineered to yield some printable version of an equivalent function -- but if the language is to remain pure, such facilities should be relegated to the development tools (debugger, etc.). -Paul Benja Fallenstein wrote: Hi Henning, On Dec 18, 2007 3:53 PM, Henning Thielemann <[EMAIL PROTECTED]> wrote:Since this was discussed already here, I summed it up in: http://www.haskell.org/haskellwiki/Show_instance_for_functionsI find the discussion under "theoretical answer" unsatisfying. The property that a Show instance for functions would break is extensionality, and while extensionality is a desirable trait and matches the common mathematical intuitions, a system with intensional functions certainly isn't "unmathematical" or impure.Further, even with extensionality, we can (with compiler support) in principle have Show instances other than enumerating the graph. At least for simple non-recursive functions, showing the Böhm tree of the function could be useful (except that you loop forever if you encounter bottom somewhere, of course, instead of printing "bottom" as you would if you could print the actual Böhm tree). For example, id would be shown as "\a -> a," maybe would be shown as "\a b c -> case c of { Just d -> b d; Nothing -> a }," and all would be shown as "\a -> case a of { (b:c) -> case b of { False -> False; True -> case c of { (d:e) -> case d of { False -> False" et cetera ad infinitum. Of course, for functions on ints this would indeed reduce to enumerating the graph, printed as an infinite case _expression_. - Benja _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe |
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe