### implement algebras with some extra structure

I seem not to be understanding the way to implement categories with extra structure. Suppose I want to implement the category `Cs`

of pairs `(A,S)`

where `A`

is a `QQ`

-algebra and `S`

is a linear endomorphism of `A`

with the obvious morphisms. `Algebras(QQ)`

is a full subcategory of `Cs`

by adding the zero endormophism. And we also have the forgetful functor from `Cs`

to `Algebras(QQ)`

which consists to simply forget `S`

.

Now from reading the examples in
https://doc.sagemath.org/html/en/reference/categories/index.html
or
https://doc.sagemath.org/html/en/thematic_tutorials/coercion_and_categories.html
I could set up

```
class Cs(Category)
def super_categories(self):
return[Algebras(QQ)]
```

And that woul d give me a canonical forgetful functor `Cs`

-> `Algebras(QQ)`

. Now my problem is when I want to create a parent of `Cs()`

starting from a parent in `Algebras(QQ)`

. That is, I could set up a new parent and elements which will have to implement the methods for `Algebras(QQ)`

:

```
sage: from sage.misc.abstract_method import abstract_methods_of_class
sage: abstract_methods_of_class(Algebras(QQ).parent_class)
{'optional': ['algebra_generators'], 'required': ['__contains__']}
sage: abstract_methods_of_class(Algebras(QQ).element_class)
{'optional': ['_add_', '_mul_'], 'required': ['__nonzero__']}
```

But instead of implementing those methods I would want to use the methods of the underlying parent of `Algebras(QQ)`

. Something like a hypothetical `PolynomialRing(QQ, 'x', category=Cs())`

. In other words I'm looking to implement the functor `A -> (A, 0)`

above.

Finally I have similar concerns about implementing `Cs()`

in the other two possible ways, namely as the subcategory of the category of arrows in ~~Algebras(QQ)~~VectorSpaces(QQ)

with the same source and ~~target, ~~target an object from `Algebras(QQ)`

, or as a super category of `Algebras(QQ)`

using `_subcategory_hook_`

. Always I get to the point where I don't know how to implement something like `PolynomialRing(QQ, category=Cs())`

. What I am doing now is keeping a copy of the algebra `A`

inside of an instance of `Cs.parent_class`

and then implementing the element and parent mehods of `Algebras(QQ)`

by pointing to the corresponding methods of `A`

but that seems silly. I'd appreciate any ~~pointer. ~~pointer.