diagrams/diagrams-lib — pull request #140 by bergey (2013-11-27 03:07:24+00:00)
Title: Unified angle type

This code is not at all ready to merge; this PR is for discussion.

This branch replaces the `Angle` type class with a single `Angle` type, and `Iso`s to (de)construct `Angle`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.
* [Concrete angle type in camera - avoids polymorphism, but loses unit-agnosticism](
https://github.com/diagrams/diagrams-lib/blob/master/src/Diagrams/ThreeD/Camera.hs#L53)
* [Spherical coordinates parameterized by angle type](https://github.com/diagrams/diagrams-lib/blob/master/src/Diagrams/ThreeD/Types.hs#L136)
* [Multi-parameter Angle class in generalizing away from Double](https://github.com/diagrams/diagrams-lib/commit/8cd5bb89bc07def9ce39de8a04a89aafda2e09f1#diff-a0225900b55610e164cf0bae3642235eL199)
* [Associated type in generalizing away from Double](https://github.com/noinia/diagrams-lib/commit/6c446fe1d4addf884e608410426c73f674ef7bf1#diff-a0225900b55610e164cf0bae3642235eR236)

# 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):
``` haskell
a = pi ^. from rad :: Angle
b = review deg 90 :: Angle
a ^. turn :: Double
view rad b :: Double
turn # 0.25 :: Angle -- (#) from Control.Lens, not from Diagrams
```

# 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 hardcoded `Double`s easier. What do folks think?