A Deep Dive on Haskell's Unique Handling of Side Effects
Monads are a tricky subject. So tricky in fact, that most of the material out there about them is either a.) focused on surface level questions like "what is a monad" or b.) aimed at really abstract details like "how do monads relate to category theory". But there's not nearly as much content about how to use monads in a larger project context.
It's one thing to know what a monad is and how to write basic monadic code. But this will only give you a small amount of the power of monads! As you build more complex Haskell programs, monads can make your life a lot easier...if you know how to use them!
So how does one learn these techniques?
The answer of course, is with hands on practice. And Monday Morning Haskell has just the tool you need for that! Effectful Haskell is our short course aimed at teaching you the techniques to use monads to organize all the various effects in your system. You'll learn:
- How to construct a monad that encapsulates all the various effects in your system.
- How to use monad classes to perform IO actions while limiting the scope of your different functions.
- How free monads can make it outrageously simple to configure and modify the behavior of your program, like changing your underlying database layer, or adding mock test effects.
- And as an extra bonus, you'll also get a primer on how to deploy a Haskell application to the web using Heroku!
If this checks all the boxes for what you'd like to learn, this is the course for you!
Course Content and Outline
The course content consists of 3 elements:
- Video Lectures
- Screencast Videos
- Programming Exercises
In video lectures, your teacher will introduce the core concepts of the lesson, including an in-depth breakdown of the code you need to implement the feature.
Screencast videos will show these concepts in action, in an IDE, so you can follow along.
Finally, you'll then get the chance to try the concepts for yourself with our detailed programming exercises. These exercises are the most important part of the course! By writing the code and applying the concepts yourself, you'll build up the confidence to use these ideas in your own projects.
This short course has roughly 3 different parts. Here are the different areas you'll cover:
Building an App Monad
After a quick review of monads and especially monad transformers, we'll learn how to build an "App Monad" that encapsulates the many different effects we want within our system. We'll start with a simple practice application, but then we'll apply these ideas to a fully operational web server!
Using Monad Classes
Once we've enumerated the different effects in our system, we'll learn some more advanced ways to access these effects. We'll use monads to delineate the exact functionality we can expect from various functions so our application has clear boundaries. We'll write functions that ultimately perform IO activity (like accessing a database) even without arbitrary IO access.
Next, we'll learn about "Free Monads", an interesting concept that can accomplish the effect separation we get from monad classes while reducing our boilerplate. We'll explore the different customization options we can get with free monads, especially when it comes to making our system more testable.
Deploying a Basic Application
To conclude the course, you'll get a quick run-down of how to launch a fully configurable Haskell application on Heroku and deploy it to the cloud!
For a detailed outline and FAQ, keep scrolling!
James is a Software Engineer living in Atlanta, GA. He first discovered Haskell in college, but began using it consistently since 2015. His Haskell experience blends multiple side projects as well as professional work. In late 2016, he began the Monday Morning Haskell blog, where he publishes new Haskell content every week.
Start1: Introduction (6:52)
Preview2: Monad Transformers (5:51)
Preview3: What is an Effect? (9:19)
Start4: Monad Typeclasses (5:51)
Start5: Making Our Own Typeclasses (4:37)
Start6: Test Effects (6:33)
Start7: Server Basics (29:35)
Start8: Natural Transformations (6:50)
Start9: Tracking State with MVar (6:19)
Start10: Generalizing Our Server (7:12)
Start11: Server Test Effects (7:06)
Start12: Free Monads (9:29)
Start13: Free-ing Our Server (6:03)
Start14: Eff Test Effects (4:31)
Start15: Conclusion (15:55)