Difference between revisions of "Diagrams/Dev/Migrate1.0"

From HaskellWiki
< Diagrams‎ | Dev
Jump to navigation Jump to search
(finish -> 1.0 migration guide)
(correct version numbers)
 
Line 1: Line 1:
This page describes breaking API changes between diagrams 0.6 and 0.7, along with explanations of how to migrate to the new 0.7 API.
+
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, by Wrapped 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 alias fromDirection is still exported from Diagrams.Prelude. If you want e you can import Diagrams.TwoD.Vector.
  • Diagrams.BoundingBox

Reorganization

  • Some of the contents of Diagrams.Parametric (relating to adjusting the length of segments and trails) have been moved to Diagrams.Parametric.Adjust.
  • ScaleInv and related functions have been moved from Diagrams.TwoD.Transform to Diagrams.TwoD.Transform.ScaleInv.