Personal tools

Diagrams/Dev/Migrate1.0

From HaskellWiki

< Diagrams | Dev(Difference between revisions)
Jump to: navigation, 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.

Contents

[edit] 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:

[edit] 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 ^&.

[edit] 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 }

[edit] 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

[edit] 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.