O'Reilly logo

Get Programming with Haskell by Will Kurt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lesson 17. Design by composition—Semigroups and Monoids

After reading lesson 17, you’ll be able to

  • Create new functions with function composition
  • Use Semigroup to mix colors
  • Learn how to use guards in code
  • Solve probability problems with Monoid

In the preceding lesson, you looked at how sum types allow you to think outside the typical hierarchical design patterns present in most programming languages. Another important way that Haskell diverges from traditional software design is with the idea of composability. Composability means that you create something new by combining two like things.

What does it mean to combine two things? Here are some examples: you can concatenate two lists and get a new list, you can combine two documents and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required