module Control.Monad.Indexed.State where
import Control.Comonad
import Control.Arrow
import Control.Functor.Extras
import Control.Functor.HigherOrder
import Control.Functor.Indexed
import Control.Monad
import Control.Monad.Indexed
newtype IxState i j a = IxState { runIxState :: i -> (a, j) }
instance IxFunctor IxState where
imap f (IxState m) = IxState (first f . m)
instance IxMonad IxState where
ireturn = IxState . (,)
ibind f (IxState m) = IxState $ \s1 -> let (a,s2) = m s1 in runIxState (f a) s2