[Haskell-cafe] Could someone teach me why we use Data.Monoid?
Magnus Therning
magnus at therning.org
Fri Nov 13 12:00:12 EST 2009
On Fri, Nov 13, 2009 at 4:52 PM, Andrew Coppin
<andrewcoppin at btinternet.com> wrote:
> Stephen Tetley wrote:
>>
>> 2009/11/13 Rafael Gustavo da Cunha Pereira Pinto
>> <RafaelGCPP.Linux at gmail.com>:
>>
>>>
>>> Monoid is the category of all types that have a empty value and an append
>>> operation.
>>>
>>>
>>
>> Or more generally a neutral element and an associative operation:
>>
>> The multiplication monoid (1,*)
>>
>> 9*1*1*1 = 9
>>
>> 1 is neutral but you might be hard pressed to consider it _empty_.
>>
>
> This is the thing. If we had a class specifically for containers, that could
> be useful. If we had a class specifically for algebras, that could be
> useful. But a class that represents "any possible thing that can technically
> be considered a monoid" seems so absurdly general as to be almost useless.
> If you don't know what an operator *does*, being able to abstract over it
> isn't especially helpful...
>
> ...in my humble opinion. (Which, obviously, nobody else will agree with.)
But can't you say exactly the same about Monads?
And at times it's useful to be able to switch between getting all
results (List) and getting one (or none, Maybe), no?
/M
--
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnus@therning.org Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
More information about the Haskell-Cafe
mailing list