Skip to content

Comment on Why don't you use dependent types?parent

Comments

For example, I wish Python had the ability to express "a 10 x 5 matrix of float32s" as a type, and typecheck that.

Numpy arrays have been checkable by dtype for a little while now, and I think recent versions also support shape constraints.

Can these constraints be statically checked with mypy or a language server?

The dtype constraint can with pyright (and presumably others). We're still on older versions of numpy so I don't have first hand knowledge of the shape constraints.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.