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)
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
SumorProduct. Obviously if you want some other operation you should write your own.