Hacker News new | past | comments | ask | show | jobs | submit login

I was so disappointed that this turned from Python to Haskell, I would just _love_ to have something like this in Python. Even just type annotations.

A similar thing I have been thinking about doing in robotics contexts is to annotate vectors and transformation matrices with their reference frames. So you can only matrix-vector multiply between compatible types: `object_in_world = camera_to_world @ object_in_camera`. It can be done somewhat in C++.




Something I briefly mention in the post is pint [0] for Python, but unfortunately, I don't think dimensions can be specified via type annotations.

At least you can check the input of functions at runtime [1].

[0]: https://github.com/hgrecco/pint

[1]: https://pint.readthedocs.io/en/stable/advanced/wrapping.html


Could this be done with an IDE plugin (for Pycharm or whatnot)? It is tedious to go though code and carefully annotate each variable and run so many compile test, read error, revise, cycles. It should be possible on a per function basis to statically check how each variable relates to the inputs and outputs, and just annotate those. Then the plugin could solve the units for each item, and only ask for an annotation where needed to resolve an ambiguous case.


Check out sympy.physics.units. I've been using it for unit-checking in my symbolic work for a few years.

https://docs.sympy.org/latest/modules/physics/units/index.ht...




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: