← Back to context

Comment by FreakLegion

9 hours ago

Most languages can do this if it's what you want. In Python it would be:

    class Some[T]:
        value: T

    type Option[T] = Some[T] | None

    def get_owner(id: DocumentId) -> Option[Option[UserId]]: ...

    match get_owner(document_id):
        case None:
            ...
        case Some(None):
            ...
        case Some(Some(x)):
            ...

Yeah, that's more like what you would do if you wanted to translate the entire concept to Python instead of just the signature, and I probably should have mentioned that alternative as well (or should have said "A Python solution"). Can't say I've seen this approach used in practice, interestingly, though I'm probably not nearly as familiar with the Python that exists out there as most other commenters here.

The name clash is unfortunate, but luckily naming things is famously one of the easiest problems in CS so that should be trivial to solve :P