-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about measurements #518
Comments
It looks like your trying to discover the quantity type from the unit symbol. That creates a problem for the type system. Normally squants would parse a string for a particular quantity type
but you would like to have something generic
and it would return the correct type. However, what type is And while this might be useful for the general handling of value/unit pairs, it breaks the general principle of enforcing dimensional analysis type rules. If we somehow can treat That's also true when accepting input from a user. If they're supplying a quantity of mass, we should know that. I am interested in your use case, particularly if I am missing the point. |
I think you understood the problem I have and partly answered it cannot be done. My use case is that I need to parse a CSV containing a bill of materials with a description and a quantity so I wanted to have something like:
So basically I want a container of quantities (in my case quantities will only be of kind Mass, Area and Unit) but later I want to group them by dimension. But as you say, having That's the reason of creating Measurements sum type to unify things, but my feeling was that it is a lot of boilerplate and/or that I'm not exercising squants to its fullets. |
Sorry if this is not the place but I haven't found a community for asking this question.
My use case is that I have "measurements" that could be either "units", "kg" or "m2" for items, so I have the tuple (item, measurement).
I haven't found a clean way of holding this other than creating a sum type called Measurement and having:
But now I want to have a MeasurementDimension in my anticorruption layer and I'm facing the same problem, creating a new sum type. All this boilerplate looks like I haven't understood properly the type hiearchy of squants.
Am I overengineering? What would be a cleaner approach to work seamlessly with just 3 disparate quantities?
The text was updated successfully, but these errors were encountered: