What's the practical value of all those newtype wrappers in `Data.Monoid`?

前端 未结 5 450
误落风尘
误落风尘 2020-12-15 21:13

When looking at Data.Monoid, I see there are various newtype wrappers, such as All, Sum, or Product, which e

5条回答
  •  天涯浪人
    2020-12-15 21:22

    The basic idea, I think, is that you can have something like

    reduce = foldl (<>) mempty
    

    and it'll work for any list of those wrapped things.

提交回复
热议问题