3 ms·
> toAdditive ((toMultiplicative a) <> (toMultiplicative x)) <> toAdditive b > This is of course an insane way to program If you have a set with two binary oper
by greydius 5y ago
> toAdditive ((toMultiplicative a) <> (toMultiplicative x)) <> toAdditive b
> This is of course an insane way to program
If you have a set with two binary operations, then a monoid isn't the correct abstraction.
How would you propose to define <> so that a<>x<>b means ax+b and not e.g. a+xb. And how would your proposal be materially different from newtype conversions?
- joppy 5y ago> If you have a set with two binary operations, then a monoid isn't the correct abstraction. I guess my point is that even if I used "the correct abstraction" here, meaning a ring or something, then the whole newtype setup still makes it annoying for me to split off one operation and feed it into a function expecting a monoid: the way that fold and friends work is much more natural, just taking a starting value 1 and an operation * for example, rather than some kind of "Multiplicative" newtype or whatever. In general I see a lot of the abstract algebra type towers in Haskell and Purescript as being unhelpful, and making a huge assumption that (for example) there will rarely be two monoid instances on a type. In reality in abstract algebra we use tons of different operations on the same objects all the time, and I really just want to define those operations and then be able to use them.