show function

Jerzy Karczmarczuk karczma at info.unicaen.fr
Wed Dec 3 15:13:36 EST 2003


Christian Maeder wrote:
> rui yang wrote:
> 
>>I want to print a function which itself have some functions as it's parameters 
>>and will return some functions as the results, and I want to print out the 
>>result, does anyone knows how to define the instance declaration of show class 
>>to this function type?
> 
> 
> I don't know if it is possible to define a Show-instance for a function
> type, but you should not do so, because functions are usually
> "unshowable". If you have a function as a result you can only apply it
> to some further argument and (try to) show the result of that application.


Please, don't be so categorical, and if you confess that you don't know
whether it is possible, then test first.

There are cases where you might create some complex data structures containing
functional objects: for specific dispatching, simulating OO, for writing
interpreters, etc.

Then you *MAY* need - if only for debugging - to look at your data. Of course
you cannot "print the sine function", but it is easy to write, say, in Hugs,

instance Show (a->b) where
   show f = "<sorry, this is a function, I can't show it>"

============

Moreover, if we get down from the Haskell crystal mountain, we might see
languages where functional entities KEEP A LOT of secondary information,
which permit to auto-document them in a more specific, communicative way.
Look at Python functions...


Jerzy Karczmarczuk




More information about the Haskell mailing list