Personal tools


From HaskellWiki

< Diagrams | Dev(Difference between revisions)
Jump to: navigation, search
(Start migration page to 1.0)
(finish -> 1.0 migration guide)

Revision as of 03:39, 25 November 2013

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.


1 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:

1.1 & 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 ^&.

1.2 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 }

2 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

3 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.