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

From HaskellWiki
< Diagrams‎ | Dev
Jump to navigation Jump to search
(Start migration page to 1.0)
 
(finish -> 1.0 migration guide)
Line 37: Line 37:
 
foo with { _bar = 1, _baz = Nothing }
 
foo with { _bar = 1, _baz = Nothing }
 
</haskell>
 
</haskell>
  +
  +
== Functions no longer exported from <code>Diagrams.Prelude</code> ==
  +
  +
The following functions/modules are no longer exported from <code>Diagrams.Prelude</code>, because of frequent name clashes. However, they are still available with an explicit import:
  +
  +
* <code>e</code>. The alias <code>fromDirection</code> is still exported from <code>Diagrams.Prelude</code>. If you want <code>e</code> you can import <code>Diagrams.TwoD.Vector</code>.
  +
  +
* <code>Diagrams.BoundingBox</code>
  +
  +
== Reorganization ==
  +
  +
* Some of the contents of <code>Diagrams.Parametric</code> (relating to adjusting the length of segments and trails) have been moved to <code>Diagrams.Parametric.Adjust</code>.
  +
  +
* <code>ScaleInv</code> and related functions have been moved from <code>Diagrams.TwoD.Transform</code> to <code>Diagrams.TwoD.Transform.ScaleInv</code>.

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.

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.