newidST' :: Monad m => Int -> Idx -> StateT [(Idx, Idx)] (StateT IdxSet m) Idx
newidST' i v = do
  mp <- get
  case lookup v mp of 
    Just v' -> return v'
    Nothing -> do v' <- lift (newidST i)
                  modify (\mp' -> (v,v') : mp')
                  return v'

-- |Creates a new id (for the list of ids specified by the first parameter) using
-- |a state transformer, rather than a state monad.
newidST' :: Monad m => Int -> Idx -> StateT [(Idx, Idx)] (StateT IdxSet m) Idx
newidST' i v = do
  mp <- get
  case lookup v mp of 
    Just v' -> return v'
    Nothing -> do v' <- lift (newidST i)
                  modify (\mp' -> (v,v') : mp')
                  return v'

-- |Creates a new id (for the list of ids specified by the first parameter) using
-- |a state transformer, rather than a state monad.
newidST' i v = do
  mp <- get
  case lookup v mp of 
    Just v' -> return v'
    Nothing -> do v' <- lift (newidST i)
                  modify (\mp' -> (v,v') : mp')
                  return v'

-- |Creates a new id (for the list of ids specified by the first parameter) using
-- |a state transformer, rather than a state monad.