From HaskellWiki
< Diagrams‎ | Dev
Revision as of 21:23, 21 November 2013 by Byorgey (talk | contribs) (Start migration page to 1.0)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 }