setAttr :: Attr a => AttrTable a -> NodeInfo -> a -> AttrTable a
setAttr at node av =
    case nameOfNode node of
        Nothing  -> onlyPosErr "setAttr" at (posOfNode node)
        Just aid ->
          case at of
            (SoftTable fm desc) -> assert (isUndef (NameMap.findWithDefault undef (nameId aid) fm)) $
                                     SoftTable (NameMap.insert (nameId aid) av fm) desc
            (FrozenTable _arr _) -> interr frozenErr
          where
            frozenErr     = "Attributes.setAttr: Tried to write frozen attribute in\n"
                            ++ errLoc at (posOfNode node)

-- | update the value of an attribute from the given attribute table
--
setAttr :: Attr a => AttrTable a -> NodeInfo -> a -> AttrTable a
setAttr at node av =
    case nameOfNode node of
        Nothing  -> onlyPosErr "setAttr" at (posOfNode node)
        Just aid ->
          case at of
            (SoftTable fm desc) -> assert (isUndef (NameMap.findWithDefault undef (nameId aid) fm)) $
                                     SoftTable (NameMap.insert (nameId aid) av fm) desc
            (FrozenTable _arr _) -> interr frozenErr
          where
            frozenErr     = "Attributes.setAttr: Tried to write frozen attribute in\n"
                            ++ errLoc at (posOfNode node)

-- | update the value of an attribute from the given attribute table
--
setAttr at node av =
    case nameOfNode node of
        Nothing  -> onlyPosErr "setAttr" at (posOfNode node)
        Just aid ->
          case at of
            (SoftTable fm desc) -> assert (isUndef (NameMap.findWithDefault undef (nameId aid) fm)) $
                                     SoftTable (NameMap.insert (nameId aid) av fm) desc
            (FrozenTable _arr _) -> interr frozenErr
          where
            frozenErr     = "Attributes.setAttr: Tried to write frozen attribute in\n"
                            ++ errLoc at (posOfNode node)

-- | update the value of an attribute from the given attribute table
--