Author: sbo

Desugaring the State (Transformer) Monad Part IV

Desugared Example Code module Main where import Control.Monad.State.Strict (StateT(..)) import Data.Functor.Identity (Identity(..)) type OccurrenceValue = Int type OccurrenceState = Int countOccurrence :: String -> StateT OccurenceState Identity OccurenceValue countOccurrence [] = StateT $ \s -> Identity (s, s) countOccurrence (x:xs) = StateT $ \s -> runStateT (k x xs s) s m1 :: Char -> […]

Desugaring the State (Transformer) Monad Part I

Why is learning Monads difficult? One of the things Haskell is most famous for are monads. There is a page on the Haskell wiki https://wiki.haskell.org/Monad_tutorials_timeline#year_2015 where a lot of Monad tutorials a listed. So it seems that understanding monads is somehow difficult. Why is this the case? There is this great ebook of Stephen Diehl […]