From 049268790e3e2ab6ea2b23529f5648232377cf5c Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 26 Oct 2017 15:43:22 +0200 Subject: [PATCH] Add a "meet the transformers" slide --- reveal/monad-transformer-state.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/reveal/monad-transformer-state.md b/reveal/monad-transformer-state.md index f73461d..a360253 100644 --- a/reveal/monad-transformer-state.md +++ b/reveal/monad-transformer-state.md @@ -37,6 +37,26 @@ title: Everything you didn't want to know about monad transformer state * Feel free to ask me about them later! * Also, only doing shallow transformers (1 layer) +---- + +## Meet the transformers + +```haskell +newtype ReaderT r m a = ReaderT (r -> m a) +newtype StateT s m a = StateT (s -> m (a, s)) +newtype ExceptT e m a = ExceptT ( m (Either e a)) +``` + +Or specialized to `IO` and turned into functions: + +```haskell +type ReaderIO r a = r -> IO a +type StateIO s a = s -> IO (a, s) +type ExceptIO e a = IO (Either e a) +``` + +Let's motivate some problems + --- ## A concurrent problem