So you flipped the elements of the pair in your definition of return from (x,st) to (st,x).
this code compiles correcly:newtype State s a = State { runState :: s -> (a,s) }
instance Monad (State s) where
--return :: a -> State s a
return x = State (\st -> (x,st))
but this one doesn't compile:newtype State s a = State { runState :: a -> (a,s) }Why is this happening?
instance Monad (State s) where
--return :: a -> State s a
return x = State (\st -> (st,x))
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners