Diagrams/Dev/Migrate1.1: Difference between revisions
(Explain new Angle type) |
(link to user manual angles section) |
||
Line 3: | Line 3: | ||
== Angles are now represented by a single type == | == Angles are now represented by a single type == | ||
The types <code>Turn</code>, <code>Rad</code>, and <code>Deg</code> have been subsumed by the new type <code>Angle</code>. The old type class <code>Angle</code> is no longer needed. | The types <code>Turn</code>, <code>Rad</code>, and <code>Deg</code> have been subsumed by the new type <code>Angle</code>. The old type class <code>Angle</code> is no longer needed. [http://projects.haskell.org/diagrams/doc/manual.html#angles See the user manual for more exposition.] | ||
Code which constructed angles like | Code which constructed angles like |
Latest revision as of 15:05, 17 May 2014
This page describes breaking API changes between diagrams 1.0 and 1.1, along with explanations of how to migrate to the new 1.1 API.
Angles are now represented by a single type
The types Turn
, Rad
, and Deg
have been subsumed by the new type Angle
. The old type class Angle
is no longer needed. See the user manual for more exposition.
Code which constructed angles like
(0.5 :: Turn)
can be written instead as
(0.5 @@ turn)
The new functions rad
and deg
can be used similarly. All three have type Iso from lens
.
Extracting a measurement with particular units, which used to look like
Rad theta = convertAngle a
can be written
theta = a ^. rad
The function convertAngle
is no longer needed, and has been removed. Finally, where the Angle
type class was used as a constraint,
Angle a => a -> b
becomes
Angle -> b