Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Incrementing i

Name: Anonymous 2009-03-16 8:40

i++; versus i+=1; versus i=i+1;

Discuss.

Name: Anonymous 2009-03-16 14:34

I use state monad for that;

newtype State s a = State { runState :: (s -> (a,s)) }
 
instance Monad (State s) where
    return a        = State $ \s -> (a,s)
    (State x) >>= f = State $ \s -> let (v,s') = x s in runState (f v) s'

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List