[Haskell-cafe] use of modules to save typing
mpm at alumni.caltech.edu
Thu Jul 8 05:15:44 EDT 2010
Michael Mossey wrote:
> incrCursor :: State PlayState ()
> incrCursor =
> cur <- gets playState_cursor
> len <- gets playState_len
> let newCur = min (cur+1) (len-1)
> modify (playState_update_cursor newCur)
Whoa, I just realized I'm not using 'modify' to full advantage. This can
incrCursor = modify incrCursor'
incrCursor' (PlayState cursor len verts doc) =
PlayState (min (cursor+1)(len - 1)) len verts doc)
Hmm, I'm already feeling better about the State monad.
Additional question: what is proper terminology here?
"incrCursor is a monad"
"incrCursor is a monadic function"
"incrCursor is a monadic type"
"State is a monad"
"State is a type constructor of a monad"
"State is a monadic type"
"incrCursor is a monadic computation"
More information about the Haskell-Cafe