[Haskell-cafe] data declarations should provide fold functions
wren ng thornton
wren at freegeek.org
Wed Jan 7 23:44:21 EST 2009
Tim Newsham wrote:
> I know the short-term answer is "use TH" to derive folds if
> I want them, but I think such an important concept should probably
> be part of the language.
If you don't mind the hairy code, there's always this generic answer
from #haskell almost a year ago:
http://hpaste.org/7682
You'd need to hook it up with a preprocessor script since it's a
String->String function. It should be pretty easy to rewrite that into
TH code in order to clean it up.
I agree, it'd be nice to have it as a standard deriving clause, but
since every fold has a different type it's challenging to make it fit
into the language rather than being a wart. Some of the stuff in
Data.Generics, Data.Typable, etc might could help. If you come up with
anything you like, it shouldn't be too hard to (convince someone to)
convert the logic into a language extension.
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list