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.
The fold function is an example of a generic program, which can
be defined using generic programming libraries. Since the fold
has to know about
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.o
I've had to use some fold functions recently and I've come to
the conclusion that Haskell should automatically generate
fold functions for data definitions. To clarify what I mean,
for the data definition:
data MyData = This Int Char | That String Int Int
there should be a matching function