[Haskell-beginners] Control.Monad.State: State CTOR unneeded to
create a State?
Larry Evans
cppljevans at suddenlink.net
Thu Oct 30 23:07:59 EDT 2008
Page:
http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Monad-State.html#2
suggests, with the content:
Constructors
State
runState :: (s -> (a, s))
that State has a labeled constructor:
http://www.haskell.org/onlinereport/exps.html#sect3.15.2
yet the Examples section:
http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Monad-State.html#4
shows, AFAICT, no call to the State CTOR:
tick :: State Int Int
tick = do n <- get
put (n+1)
return n
I assume the n must be an Int (since it's in n+1), but what are the
get and put. There is a get and put described here:
http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Monad-State.html#1
however, I don't see how they are relevant since they are defined for
an already existing MonadState, and AFAICT, tick hasn't been defined
yet since it's on the lhs of the =.
Please, what am I missing?
TIA
-regards
Larry
More information about the Beginners
mailing list