Skip to Content
Get Programming with Haskell
book

Get Programming with Haskell

by Will Kurt
March 2018
Beginner
616 pages
16h 53m
English
Manning Publications
Content preview from Get Programming with Haskell

Lesson 30. Introducing the Monad type class

After reading lesson 30, you’ll be able to

  • Understand the limitations of both Functor and Applicative
  • Use Monad’s (>>=) operator to chain together functions in a context
  • Write IO code without do-notation

You’ve just finished learning about two important type classes, Functor and Applicative. Each has allowed you to perform increasingly powerful computations within a context such as Maybe or IO. Functor allows you to change individual values in a context:

GHCi> (+ 2) <$> Just 3
Just 5

Applicative increases your power by enabling you to use partial application in a context. This, in turn, allows you to use multiple arguments in a context:

GHCi> pure (+) <*> Just 3 <*> Just 2
Just 5

In this lesson, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Get Programming with Go

Get Programming with Go

Nathan Youngman, Roger Peppe
Effective Haskell

Effective Haskell

Rebecca Skinner

Publisher Resources

ISBN: 9781617293764Publisher SupportOtherPublisher WebsiteSupplemental ContentErrata PagePurchase Link