Re: [Haskell-cafe] A clarification about what happens under the hood with foldMap

2012-10-24 Thread Alfredo Di Napoli
Thanks guys for the clarification, this blowed my mind a bit :P As far as I understood, is that my initial thought about Sum and Product was wrong; in fact, they don't even participate to the party! This is confirmed by the Oleg's paradox about (-). What really happens is that Endo (which I guess

[Haskell-cafe] A clarification about what happens under the hood with foldMap

2012-10-23 Thread Alfredo Di Napoli
Hi Cafe, I was playing with the classic example of a Foldable structure: Trees. So the code you can find both on Haskell Wiki and LYAH is the following: data Tree a = Empty | Node (Tree a) a (Tree a) deriving (Show, Eq) instance Foldable Tree where foldMap f Empty = mempty foldMap f

Re: [Haskell-cafe] A clarification about what happens under the hood with foldMap

2012-10-23 Thread Chaddaï Fouché
Le 23 oct. 2012 09:54, Alfredo Di Napoli alfredo.dinap...@gmail.com a écrit : What this code does is straighforward. I was struck from the following sentences in LYAH: Notice that we didn't have to provide the function that takes a value and returns a monoid value. We receive that function as

[Haskell-cafe] A clarification about what happens under the hood with foldMap

2012-10-23 Thread Alfredo Di Napoli
-- Forwarded message -- From: Alfredo Di Napoli alfredo.dinap...@gmail.com Date: 23 October 2012 10:35 Subject: Re: [Haskell-cafe] A clarification about what happens under the hood with foldMap To: Chaddaï Fouché chaddai.fou...@gmail.com I'm sure I'm missing a point, but the

[Haskell-cafe] A clarification about what happens under the hood with foldMap

2012-10-23 Thread oleg
I was playing with the classic example of a Foldable structure: Trees. So the code you can find both on Haskell Wiki and LYAH is the following: data Tree a = Empty | Node (Tree a) a (Tree a) deriving (Show, Eq) instance Foldable Tree where foldMap f Empty = mempty foldMap f (Node

Re: [Haskell-cafe] A clarification about what happens under the hood with foldMap

2012-10-23 Thread Chaddaï Fouché
On Tue, Oct 23, 2012 at 10:36 AM, Alfredo Di Napoli alfredo.dinap...@gmail.com wrote: I'm sure I'm missing a point, but the minimum definition for a Foldable instance is given in terms of foldMap, so I get the cake for free, foldr included, right? In the example I have defined my treeSum as:

Re: [Haskell-cafe] A clarification about what happens under the hood with foldMap

2012-10-23 Thread Alfredo Di Napoli
Thanks guys, I'll work my way through Oleg's paradox as well as what you just said Chaddai. I'm very busy right now, but I'll probably come back to you tomorrow morning, when I'll have an hour to think freely :) Cheers, A. ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] A clarification about what happens under the hood with foldMap

2012-10-23 Thread John Lato
From: Alfredo Di Napoli alfredo.dinap...@gmail.com Subject: [Haskell-cafe] A clarification about what happens under the hoodwith foldMap I'm sure I'm missing a point, but the minimum definition for a Foldable instance is given in terms of foldMap, so I get the cake for free,