Re: [Haskell-cafe] Code that writes code

2010-08-25 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/24/10 17:51 , Richard O'Keefe wrote: > On Aug 22, 2010, at 7:34 PM, Jesse Schalken wrote: >> I would also like to strongly discourage code generators. > > I've used ad hoc code generators a lot, and never had > reason to regret it. > > The key p

Re: [Haskell-cafe] Code that writes code

2010-08-24 Thread Ivan Lazar Miljenovic
On 25 August 2010 07:51, Richard O'Keefe wrote: > > On Aug 22, 2010, at 7:34 PM, Jesse Schalken wrote: > >> Every software project which I've worked on that used a code generator >> turned into a nightmare, because when we find we need to change >> something about the generator's output, all the a

Re: [Haskell-cafe] Code that writes code

2010-08-24 Thread Donn Cave
Quoth "Richard O'Keefe" , ... >> Of course code generation is perfectly fine when the output is not >> intended to be read and maintained by a human. > > "Read" and "maintained" are two different issues. > Depending on the tool-chain, it may be necessary for people to > read the generated code whil

Re: [Haskell-cafe] Code that writes code

2010-08-24 Thread Antoine Latter
In the past I've taken a hybrid approach - ad-hoc fixes are done to the generated code, but it is done via 'patch' as an automated step, and the diff is stored in source control with everything else. You'll need extra tool support to build the diff, as well. It's still really brittle, and I would

Re: [Haskell-cafe] Code that writes code

2010-08-24 Thread Richard O'Keefe
On Aug 22, 2010, at 7:34 PM, Jesse Schalken wrote: > I would also like to strongly discourage code generators. I've used ad hoc code generators a lot, and never had reason to regret it. The key point is that ALL maintenance of the generated code must be done by maintaining the generator and its

Re: [Haskell-cafe] Code that writes code

2010-08-22 Thread Ivan Lazar Miljenovic
Jesse Schalken writes: > I would also like to strongly discourage code generators. > > Any code that has to be "generated" can and should have its common > characteristics separated out with only unique characterstic remaining > typically with an interface (i.e. type class) or polymorphic type >

Re: [Haskell-cafe] Code that writes code

2010-08-22 Thread Andrew Coppin
Jesse Schalken wrote: I would also like to strongly discourage code generators. Any code that has to be "generated" can and should have its common characteristics separated out with only unique characterstic remaining typically with an interface (i.e. type class) or polymorphic type dividing th

Re: [Haskell-cafe] Code that writes code

2010-08-22 Thread Andrew Coppin
Bill Atkins wrote: Have you looked at creating Template Haskell splices to generate this for you? The thought had crossed my mind. On the other hand, with my current approach, the generated code is just another source file that doesn't look any different. On reflection, I kinda like that.

Re: [Haskell-cafe] Code that writes code

2010-08-22 Thread Jesse Schalken
I would also like to strongly discourage code generators. Any code that has to be "generated" can and should have its common characteristics separated out with only unique characterstic remaining typically with an interface (i.e. type class) or polymorphic type dividing the two, creating a separa

Re: [Haskell-cafe] Code that writes code

2010-08-21 Thread Bill Atkins
Have you looked at creating Template Haskell splices to generate this for you? On Friday Aug 20, 2010, at 2:21 PM, Andrew Coppin wrote: > All I'm actually using it to do is generate a set of fixed-size containers > (each of which has a bazillion class instances). I've got a variable-sized > con

Re: [Haskell-cafe] Code that writes code

2010-08-21 Thread Erik de Castro Lopo
Andrew Coppin wrote: > Well, yeah, if you've got so much boiler plate that you have to automate > generating the boilerplate, you're probably doing it wrong. ;-) > > All I'm actually using it to do is generate a set of fixed-size > containers (each of which has a bazillion class instances). I'v

Re: [Haskell-cafe] Code that writes code

2010-08-20 Thread Andrew Coppin
Graham Klyne wrote: Maybe not helpful to you at this stage, but... An alternative to generating source code is to factor out the common "boilerplate" elements into separate functions, suitably parameterized, and to use higher order functions to stitch these together. Well, yeah, if you've g

Re: [Haskell-cafe] Code that writes code

2010-08-20 Thread Christopher Done
Check out the userHooks in Cabal[1]. I believe you can use, e.g. hookedPreProcessors[2], or preBuild to preprocess your files into regular Haskell files before building takes place. [1]: http://www.haskell.org/ghc/docs/6.12.1/html/libraries/Cabal/Distribution-Simple-UserHooks.html#t%3AUserHooks [

Re: [Haskell-cafe] Code that writes code

2010-08-20 Thread Graham Klyne
Maybe not helpful to you at this stage, but... An alternative to generating source code is to factor out the common "boilerplate" elements into separate functions, suitably parameterized, and to use higher order functions to stitch these together. An example of this kind of approach, which is ha

Re: [Haskell-cafe] Code that writes code

2010-08-19 Thread John Millikin
My preferred approach is to check the generation script into source control, and add it to Cabal's extra-source-files section. If the generated file is a standard .hs module, Cabal should add it to the sdist automatically. You might want to add a note to the README documenting how to regenerate th

[Haskell-cafe] Code that writes code

2010-08-19 Thread Andrew Coppin
I'm working on a small Haskell package. One module in particular contains so much boilerplate that rather than write the code myself, I wrote a small Haskell program that autogenerates it for me. What's the best way to package this for Cabal? Just stick the generated file in there? Or is there