code: def union(cls):
    
    # TODO: Check that the union base type is used as a tag and nothing else (e.g. no attributes)!
    assert isinstance(cls, type)
    return type(cls.__name__, (cls,), {
      '_is_union': True,
    })
docs: A class decorator which other classes can specify that they can resolve to with `UnionRule`.
  
    Annotating a class with @union allows other classes to use a UnionRule() instance to indicate that
    they can be resolved to this base union class. This class will never be instantiated, and should
    have no members -- it is used as a tag only, and will be replaced with whatever object is passed
    in as the subject of a `yield Get(...)`. See the following example:
  
    @union
    class UnionBase(object): pass
  
    @rule(B, [X])
    def get_some_union_type(x):
      result = yield Get(ResultType, UnionBase, x.f())
      # ...
  
    If there exists a single path from (whatever type the expression `x.f()` returns) -> `ResultType`
    in the rule graph, the engine will retrieve and execute that path to produce a `ResultType` from
    `x.f()`. This requires also that whatever type `x.f()` returns was registered as a union member of
    `UnionBase` with a `UnionRule`.
  
    Unions allow @rule bodies to be written without knowledge of what types may eventually be provided
    as input -- rather, they let the engine check that there is a valid path to the desired result.