[Haskell-cafe] Haskell-Cafe Digest, Vol 106, Issue 38
ok at cs.otago.ac.nz
Wed Jun 27 06:25:20 CEST 2012
On 27/06/2012, at 3:18 PM, John Lato wrote:
> On Wed, Jun 27, 2012 at 9:15 AM, Richard O'Keefe <ok at cs.otago.ac.nz> wrote:
>> On 27/06/2012, at 12:51 PM, John Lato wrote:
>>> data Tree a = Leaf a | Branch (Tree a) ( Tree a)
>>> deriving (Foldable, Show)
>> While I am familiar with deriving (Show),
>> I am not familiar with deriving (Foldable),
>> which looks rather useful.
>> just says "With -XDeriveFoldable, you can derive instances of the
>> class Foldable, defined in Data.Foldable." but it provides no details.
>> Would you care to explain more about deriving (Foldable)?
> There's not much to explain, DeriveFoldable basically does just that;
> automatically provide an instance of the Foldable class for a data
That was sufficiently obvious, yes.
The question remains, ***WHAT*** instance?
> I think the original proposal for DeriveFoldable was from Twan
> van Laarhoven, http://email@example.com/msg02116.html,
which goes into a great deal of detail about what deriving (Functor)
does, but none whatsoever about what deriving (Foldable) does. Even
for Functor, another 3 or 4 nontrivial examples would be nice.
> and there's a little bit of history on GHC's trac,
> http://hackage.haskell.org/trac/ghc/ticket/2953. The current
> implementation probably hasn't changed much since Simon PJ's original
> patch, although there's probably substantial overlap with ghc's
> generics these days.
That trac entry contains one sentence that seems to still apply:
"What is missing is a section in the user manual describing the changes."
It refers to section 8.5, which is now 7.5, and there is still no
adequate documentation there.
> As for the Foldable class itself, the docs at
> are pretty good.
Yes, Foldable *is* documented.
However, that page says nothing whatever about deriving (Foldable).
More information about the Haskell-Cafe