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

-- |Returns the id in the map list if it exists. if it does not, creates a new one 
-- |adds it to the map, using a state transformer.
newid' :: Int -> Idx -> StateT [(Idx, Idx)] (State IdxSet) Idx
newid' i v = do
  mp <- get
  case lookup v mp of 
    Just v' -> return v'
    Nothing -> do v' <- lift (newid i)
                  modify (\mp' -> (v,v') : mp')
                  return v'

-- |Returns the id in the map list if it exists. if it does not, creates a new one 
-- |adds it to the map, using a state transformer.
newid' i v = do
  mp <- get
  case lookup v mp of 
    Just v' -> return v'
    Nothing -> do v' <- lift (newid i)
                  modify (\mp' -> (v,v') : mp')
                  return v'

-- |Returns the id in the map list if it exists. if it does not, creates a new one 
-- |adds it to the map, using a state transformer.