Diagrams/Dev/Migrate1.0: Difference between revisions
(finish -> 1.0 migration guide) |
(correct version numbers) |
||
Line 1: | Line 1: | ||
This page describes breaking API changes between diagrams 0. | This page describes breaking API changes between diagrams 0.7 and 1.0, along with explanations of how to migrate to the new 1.0 API. | ||
== Updates for <code>lens</code> compatibility == | == Updates for <code>lens</code> compatibility == |
Latest revision as of 18:41, 18 February 2014
This page describes breaking API changes between diagrams 0.7 and 1.0, along with explanations of how to migrate to the new 1.0 API.
Updates for lens
compatibility
Diagrams has now added the lens
package as a dependency; at the moment, for the most part this means
- Options record are now accessed using lenses
Newtype
instances have been replaced, generally, byWrapped
instances.
More sophisticated and interesting lenses for diagrams are planned for the future.
There are two main ways this affects existing 0.7 code:
&
operator renamed to ^&
The &
operator from diagrams-0.7 (for constructing literal points and vectors) clashes with the operator of the same name from lens
. Thus &
has been renamed to ^&
.
Options records now use lenses
Code which used options records, like
foo with { bar = 1, baz = Nothing }
will need to be updated, since bar
and baz
are no longer field names but lenses. You can update your code in one of two ways:
The first is to use the new lenses, like so:
foo (with & bar .~ 1 & baz .~ Nothing)
The second is to continue using record update notation, but prefix the field names with underscores:
foo with { _bar = 1, _baz = Nothing }
Functions no longer exported from Diagrams.Prelude
The following functions/modules are no longer exported from Diagrams.Prelude
, because of frequent name clashes. However, they are still available with an explicit import:
e
. The aliasfromDirection
is still exported fromDiagrams.Prelude
. If you wante
you can importDiagrams.TwoD.Vector
.
Diagrams.BoundingBox
Reorganization
- Some of the contents of
Diagrams.Parametric
(relating to adjusting the length of segments and trails) have been moved toDiagrams.Parametric.Adjust
.
ScaleInv
and related functions have been moved fromDiagrams.TwoD.Transform
toDiagrams.TwoD.Transform.ScaleInv
.