Hacker News new | ask | show | jobs
by KPGv2 351 days ago
> I still don't know what a monoid is though

In short, it's a data type with addition defined. So

"a" + "b" = "ab" <-- string and concat is a monoid

1 + 5 = 6 <-- nat and natural number addition is a monoid

[1] + [2] = [1, 2] <-- list and concat is a monoid

*edit* (it also has a zero defined, such as "" or 0 or [])

> Or an applicative

you can think of these as "i'd use a functor here via fmap, except my mapping function takes more than one argument"