---------------------------------- StateT ------------------------------------

newtype StateT s m a = StateT{runStateT :: s -> m (a,s)}

instance Monad m => Functor (StateT s m) where
    fmap f (StateT fa) = StateT $ \s -> do
        (xa, sx) <- fa s
        return (f xa, sx)

instance Monad m => Applicative (StateT s m) where
    pure x = StateT $ \s -> return (x, s)
    StateT ff <*> StateT fa = StateT $ \s -> do