tags:

views:

111

answers:

1

Hi, I need to use a number (a Rational ) as the log type of a Writer Monad. Unfortunately , number are not Monoid. Is there a module (or something) instantiating Numbers as Monoid, or should I do it myself ?

(I just want to know if it exists already somewhere to not reinvent the wheel, I don't need help to do it myself if needed)

+6  A: 

There are different possible ways of viewing numbers as a monoid (addition or products), so you have to use a wrapper to select one. See the docs for Data.Monoid - either Sum or Product. Obviously if you want some other operation you should write your own.

Ganesh Sittampalam
That's what I was looking for, thanks
mb14