
Thanks for the C# advise, but I was actually just comparing my C# code with similar Haskell code. Yes, I also like aspect oriented programming, dynamic code generation, and LINQ to avoid boilerplate code in C#, but this is a Haskell group, and I want to be curried ;-) But, for my students I'm actually building a small website, webservice, database with some rich client applications, in C# 3.0... I would really love to do that in Haskell, but I haven't got a clue how to start. I would need a replacement for ASP.NET (e.g. generating HTML on the server, similar to the PHP stuff), LINQ (translating Haskell to SQL), webservice wrapper generators, webservice security, etc... Any hints on useful Haskell packages would be very welcome. LINQ takes its ideas from FP, so maybe Haskell already had something similar for decades? :) Hugh Perkins wrote:
On 10/3/07, Peter Verswyvelen
wrote: I needed to type at least 3 times the amount of code, much of which was boilerplate code, and the code is not elegant.
Reflection is your friend here.
Example. Code before reflection:
MyConfig { // some properties here
public MyConfig() { XmlDocument dom = XmlHelper.Loadxml("config.xml"); somevalue1 = getIntValue( dom, "value1"); somevalue2 = getStringValue( dom, "value2"); // blah, blah, blah... } }
With reflection:
MyConfig { // some properties here
public MyConfig() { ReflectionHelper.LoadMe( this, "config.xml" ); } }
Just typed this in off the top of my head, so it might have errors in, but you get the idea.
Of course, in this case you could just use Microsoft XmlSerializer, but I quite like the flexibility of using my own serializer (it's not that hard to write, just a hundred lines or so).
... but then, you can do something similar to display arbitrary objects to html... or write to sql... or write to a proprietary protocol... or ... many things!
I kindof know what you mean though. Declaring variable types is kindof a pain, and of course anything to do with lists is insanely easier to write in Haskell (/Erlang).