I am stuck with following monad problem:
Let's say I have a standard monad State with state S = (LS, RS). I also have another monad:
newtype StateP a = StateP {runP :: S -> (a, RS)}
I want to perform some computation using StateP then merge state with state in State monad:
merge m :: StateP() -> State()
merge m = do
s@(l,r) <- get
put (l, snd (runP m s))
It is not working, but I don't get why? Is there another way to achieve such functionality?