help from the community?

Jacques Carette carette at mcmaster.ca
Thu Feb 1 17:14:27 EST 2007



Malcolm Wallace wrote:
>> If you restrict yourself to programs entirely written by humans, I 
>> agree completely.  But if you consider programs written by programs 
>> (say Template Haskell to be specific, but it could be via many other 
>> means), such degenerate types occur rather often.
>
> I find the "program-generated code" argument rather weak.  In that 
> past it was used to justify all kinds of minor horrors like excess 
> commas in lists and so on.  But if one can write a program to generate 
> syntactically valid but ugly code, one can easily spend a little extra 
> effort on making the result beautiful too.  

I used to think so too - but some very hard-won experience [1] has 
changed my mind.  Generating good code is very hard.  And if you are 
doing it in a typeful way (see [1] again), you may not be able to "spend 
a little extra effort" to make the results beautiful, because typeful 
code does not let you do introspection very easily.

I will agree with you on one aspect: if the "program-generated code" 
done by untyped manipulations, then writing a small type-simplifier is 
pretty easy, and my argument is weak.  But this is Haskell we're talking 
about, and one should really hope that TH will eventually be typed, no?

> After all, which is the more difficult task - devising the auto-coding 
> schema, or pretty-printing?  

If pretty-printing was all there was to it, I would not have made this 
comment.  Pretty-printing is indeed easy.  Typeful type-level 
programming is quite hard.

Jacques

[1] http://www.cas.mcmaster.ca/~carette/metamonads/



More information about the Haskell-prime mailing list