You are previewing Learn You a Haskell for Great Good!.
1. Learn You a Haskell for Great Good!
2. Introduction
3. 1. Starting Out
1. Calling Functions
2. Baby's First Functions
3. An Intro to Lists
4. Texas Ranges
5. I'm a List Comprehension
6. Tuples
4. 2. Believe the Type
1. Explicit Type Declaration
3. Type Variables
4. Type Classes 101
5. 3. Syntax in Functions
1. Pattern Matching
2. Guards, Guards!
3. where?!
4. let It Be
5. case Expressions
6. 4. Hello Recursion!
1. Maximum Awesome
2. A Few More Recursive Functions
3. Quick, Sort!
4. Thinking Recursively
7. 5. Higher-Order Functions
1. Curried Functions
2. Some Higher-Orderism Is in Order
3. The Functional Programmer's Toolbox
4. Lambdas
5. I Fold You So
6. Function Application with \$
7. Function Composition
8. 6. Modules
1. Importing Modules
2. Solving Problems with Module Functions
3. Mapping Keys to Values
4. Making Our Own Modules
9. 7. Making Our Own Types and Type Classes
1. Defining a New Data Type
2. Shaping Up
3. Record Syntax
4. Type Parameters
5. Derived Instances
6. Type Synonyms
7. Recursive Data Structures
8. Type Classes 102
9. A Yes-No Type Class
10. The Functor Type Class
11. Kinds and Some Type-Foo
10. 8. Input and Output
1. Separating the Pure from the Impure
2. Hello, World!
3. Gluing I/O Actions Together
4. Some Useful I/O Functions
5. I/O Action Review
11. 9. More Input and More Output
1. Files and Streams
3. To-Do Lists
4. Command-Line Arguments
5. More Fun with To-Do Lists
6. Randomness
7. Bytestrings
12. 10. Functionally Solving Problems
1. Reverse Polish Notation Calculator
2. Heathrow to London
13. 11. Applicative Functors
1. Functors Redux
2. Functor Laws
3. Using Applicative Functors
4. Useful Functions for Applicatives
14. 12. Monoids
1. Wrapping an Existing Type into a New Type
3. Meet Some Monoids
4. Folding with Monoids
15. 13. A Fistful of Monads
2. Getting Your Feet Wet with Maybe
4. Walk the Line
5. do Notation
16. 14. For a Few Monads More
1. Writer? I Hardly Knew Her!
2. Reader? Ugh, Not This Joke Again
3. Tasteful Stateful Computations
4. Error Error on the Wall
6. Making a Safe RPN Calculator
17. 15. Zippers
1. Taking a Walk
2. Focusing on Lists
3. A Very Simple Filesystem
18. Index
20. Colophon

# Chapter 14. For a Few Monads More

You’ve seen how monads can be used to take values with contexts and apply them to functions, and how using `>>=` or `do` notation allows you to focus on the values themselves, while Haskell handles the context for you.

You’ve met the `Maybe` monad and seen how it adds a context of possible failure to values. You’ve learned about the list monad and seen how it lets us easily introduce nondeterminism into our programs. You’ve also learned how to work in the `IO` monad, even before you knew what a monad was!

In this chapter, we’ll cover a few other monads. You’ll see how they can make your programs clearer by letting you treat all sorts of values as monadic ones. Further exploration of monads will also solidify your intuition ...