-- | the path is not empty and leading slashes are removed
anaUri :: [String] -> [QueryPair] -> [String] -> Either String Query
anaUri pathBits query globals = case anaQuery query globals of
    Left err -> Left err
    Right (mi, qk) -> let path = intercalate "/" pathBits in
     case (mi, readMaybe path) of
      (Just i, Just j) | i /= j -> Left "different dg ids"
      (_, mj) -> Right $ Query
        (case catMaybes [mi, mj] of
          [] -> NewDGQuery path []
          i : _ -> DGQuery i $ if isJust mj then Nothing else Just path)
        qk
anaUri :: [String] -> [QueryPair] -> [String] -> Either String Query
anaUri pathBits query globals = case anaQuery query globals of
    Left err -> Left err
    Right (mi, qk) -> let path = intercalate "/" pathBits in
     case (mi, readMaybe path) of
      (Just i, Just j) | i /= j -> Left "different dg ids"
      (_, mj) -> Right $ Query
        (case catMaybes [mi, mj] of
          [] -> NewDGQuery path []
          i : _ -> DGQuery i $ if isJust mj then Nothing else Just path)
        qk
anaUri pathBits query globals = case anaQuery query globals of
    Left err -> Left err
    Right (mi, qk) -> let path = intercalate "/" pathBits in
     case (mi, readMaybe path) of
      (Just i, Just j) | i /= j -> Left "different dg ids"
      (_, mj) -> Right $ Query
        (case catMaybes [mi, mj] of
          [] -> NewDGQuery path []
          i : _ -> DGQuery i $ if isJust mj then Nothing else Just path)
        qk