Skip to content

Comment on Snap for Beginners: Haskell Web Developmentparent

Comments

Haskellers just call them Monoid and happily include anything that's associative+identity. When talking to people not yet familiar with Haskell or abstract algebra, it's commonly a good idea to simplify the notion and call Monoid the same as concatenation. That's all.

    newtype Sum = Sum { getSum :: Int }
    instance Monoid Sum where
      mempty = Sum 0
      mappend (Sum a) (Sum b) = Sum (a + b)
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.