Skip to content

Instantly share code, notes, and snippets.

View andrewguy9's full-sized avatar

Andrew Thomson andrewguy9

  • Adobe
  • Moraga CA
View GitHub Profile
@sdiehl
sdiehl / state.hs
Created January 13, 2015 18:44
State monad implementation + example
import Control.Monad
-------------------------------------------------------------------------------
-- State Monad Implementation
-------------------------------------------------------------------------------
newtype State s a = State { runState :: s -> (a,s) }
instance Monad (State s) where
return a = State $ \s -> (a, s)