[Haskell-cafe] Printing functions

Björn Bringert bringert at cs.chalmers.se
Wed Jan 25 12:30:43 EST 2006

Creighton Hogg wrote:
> Hi,
> I'm working on writing a genetic programming system in 
> Haskell, and I wanted to know what might be a good way to 
> print out the programs that are being generated.
> There's no instance of Show for functions, but I'd really 
> like to see what's happening so that I know if it's working 
> right.
> What should I try?

One way would be to, instead of generating Haskell functions directly (I 
guess this is what you are doing), declare an algebraic data type with 
constructors for the various basic functions that you use (again I'm 
guessing as to how you are doing this). Then you can have a Show 
instance for that type, and a function for producing a real function 
from a value of your type.


More information about the Haskell-Cafe mailing list