Coding 2025-07-14

By Max Woerner Chase

I think if I'm going to get anywhere with this concept of a context, or a path, or whatever, I'm going to need to sketch things out before trying to create the classes. Let's do this as a before-and-after.

def _inferred_type(self) -> abc.CompType[TY | Type[TY, K], K | TypeKind]:
    func_type = self.rator.inferred_type()
    if not isinstance(func_type, Type):
        msg = f"Expected function, got {self.rator} of type {func_type}"
        raise TypeError(msg)
    self.rand.check_type(func_type.from_)
    return func_type.to

And the goal is something like:

def _inferred_type(self, path: Path) -> Generator[
    Constraint,
    None,
    tuple[
        abc.CompType[TY | Type[TY, K], K | TypeKind],
        Path,
    ],
]:
    func_type, type_path = (
        yield from Type.coerce(
            self.rator.inferred_type(
                path / AccessedFrom("rator")
            )
        )
    )
    yield from (
        self.rand.check_type(
            path / AccessedFrom("rand"),
            (
                func_type.from_,
                type_path / AccessedFrom("from_")
            ),
        )
    )
    return func_type.to, type_path / AccessedFrom("to")

This should give me something to chew on, so far as coming up with proper interfaces. I'm most interested in coming up with some way to cut down on the redundancy of generating the value and accessing the path. As I said, something to chew on. Anyway, I'm tired.

Good night.