-- | Fetch the contents of a namespace using the namespace ID.
getNamespaceContents :: String -> L2.L2NamespaceID -> ModelTranslation L2.L2NamespaceContents
getNamespaceContents strWhy nsid = do
  maybeNS <- (M.lookup nsid . L2.l2AllNamespaces) <$> getL2Model
  case maybeNS of
    Nothing -> error $ "Internal Compiler Error: Can't find namespace ID " ++ show nsid ++ " in model for "
                        ++ strWhy
    Just v -> return v

-- | Modify the contents of a namespace using namespace ID.
getNamespaceContents :: String -> L2.L2NamespaceID -> ModelTranslation L2.L2NamespaceContents
getNamespaceContents strWhy nsid = do
  maybeNS <- (M.lookup nsid . L2.l2AllNamespaces) <$> getL2Model
  case maybeNS of
    Nothing -> error $ "Internal Compiler Error: Can't find namespace ID " ++ show nsid ++ " in model for "
                        ++ strWhy
    Just v -> return v

-- | Modify the contents of a namespace using namespace ID.
getNamespaceContents strWhy nsid = do
  maybeNS <- (M.lookup nsid . L2.l2AllNamespaces) <$> getL2Model
  case maybeNS of
    Nothing -> error $ "Internal Compiler Error: Can't find namespace ID " ++ show nsid ++ " in model for "
                        ++ strWhy
    Just v -> return v

-- | Modify the contents of a namespace using namespace ID.