
--- John Goerzen wrote: tick :: Int -> State Int Int tick newval = do put newval return newval Or this: tick :: State Int Int tick = do n <- get return n That is even more incomprehensible to me -- why would removing a line before the return cause a type error? --- end of quote --- I can run both of those without a problem - could you post more of your code? It's probably somewhere else. /gXm

On 2004-10-07, J. Garrett Morris
I can run both of those without a problem - could you post more of your code? It's probably somewhere else. /gXm
You're right; I must have goofed somewhere. But I don't have real code yet, since I can't figure out the basic way of doing things. Here was my latest attempt: getOrSet :: Maybe Int -> State Int Int getOrSet m = case m of Nothing -> do n <- get return n Just x -> do put x return x But it doesn't seem to really be useful. When I try execState/evalState, it just return my argument when I call it with Nothing, or the thing passed to Just when I call it with that.
participants (2)
-
J.Garrett.Morris@Dartmouth.EDU
-
John Goerzen