2006-03-11から1日間の記事一覧
参考: http://www.haskell.org/hawiki/MonadState newtype State s a = State { runState :: (s -> (a, s)) } instance Monad (State s) where return a = State $ \s -> (a, s) x >>= f = State $ \s -> let (v, s') = runState x s in runState (f v) s' c…