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
Unified angle type #140
Unified angle type #140
Conversation
With the latest patches, this branch builds. There's probably still documentation that doesn't match. |
rotateBy = transform . rotation | ||
-- | A synonym for 'rotate', interpreting its argument in units of | ||
-- turns; it can be more convenient to write @rotateBy (1\/4)@ than | ||
-- @'rotate' (1\/4 ^. from turn')@. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing open single quote?
In general, I like this a lot. It feels right and makes a lot of things so much simpler. However, I think we need a better story for constructing As an alternative, we could have Just brainstorming here. I'm not sure I really like any of the above proposals. |
So we need some operator that is not in Lens, not in Diagrams, and not profanity. There must still be a few of those. Seriously, I agree that this would be better than any of the syntax examples I gave above. Some initial thoughts on names:
Is there a reason you want I'd rather use the |
Yes, I would also rather use the The reason I suggested Turning around the I like |
Great. I just added |
Cool, looks good to me. |
I also meant to ask about precedence for |
Picking operator precedence is a black art. I never really know what the "right" way to approach it is. The precedence you picked for |
This looks very nice. Definitely preferable to what we had (IMHO). |
This code is not at all ready to merge; this PR is for discussion.
This branch replaces the
Angle
type class with a singleAngle
type, andIso
s to (de)constructAngle
s from various units. The important changes are in the first commit; the second begins the process of updating code to use the new type.Motivation
The
Angle
class leads to frequent unwanted polymorphism. It leads to stranger types, also.Semantics
Expressions such as "pi radians + 90 degrees" are well-defined. Making
Angle
a type allows such expressions to type check.Syntax
lens
lets us write any of these (type signatures added for clarity):Discussion
I hope this syntax is nearly as nice as the current
(pi :: Rad)
, with types that are closer to how we actually think about angles. I think it will make removing hardcodedDouble
s easier. What do folks think?