Personal tools

Diagrams/Dev/Migrate0.6

From HaskellWiki

< Diagrams | Dev(Difference between revisions)
Jump to: navigation, search
(start filling in 0.5 -> 0.6 migration info)
(Subdiagrams)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
This page describes API changes between diagrams 0.5 and 0.6, along with explanations of how to migrate to the new 0.6 API.
+
This page describes breaking API changes between diagrams 0.5 and 0.6, along with explanations of how to migrate to the new 0.6 API.
   
 
== Reorganizations to diagrams-core ==
 
== Reorganizations to diagrams-core ==
Line 10: Line 10:
 
== Subdiagrams ==
 
== Subdiagrams ==
   
TODO: write me
+
Previous versions of diagrams-core had a mechanism for associating names with a <code>LocatedEnvelope</code>. Now, names are associated with <code>Subdiagram</code>s. For example, the type of <code>withName</code> changed from
   
Proper support for subdiagrams: previous versions of diagrams-core had a mechanism for associating names with a pair of a location and an envelope. Now, names are associated with actual subdiagrams (including their location and envelope, along with all the other information stored by a diagram).
+
<pre>
  +
withName ::
  +
(IsName n,
  +
AdditiveGroup (Scalar v), Floating (Scalar v), InnerSpace v, HasLinearMap v)
  +
=>
  +
n -> (LocatedEnvelope v -> QDiagram b v m -> QDiagram b v m)
  +
-> QDiagram b v m -> QDiagram b v m
  +
</pre>
   
== Other diagrams-core API changes ==
+
to
   
TODO: write me
+
<pre>
  +
withName ::
  +
IsName n
  +
=>
  +
n -> (Subdiagram b v m -> QDiagram b v m -> QDiagram b v m)
  +
-> QDiagram b v m -> QDiagram b v m
  +
</pre>
   
- 'Graphics.Rendering.Diagrams.UDTree' has been split out into a
+
(As you can see, some type class constraints also disappeared, due to the refactoring of the underlying data structure.)
separate 'dual-tree' package (which has also been substantially
 
rewritten).
 
   
- 'Graphics.Rendering.Diagrams.{Monoids,MList}' have been split
+
The types of <code>withNameAll</code> and <code>withNames</code> changed similarly.
out into a separate 'monoid-extras' package.
 
   
- The 'names' function now returns a list of names and their
+
For more information on subdiagrams and their API, see [http://projects.haskell.org/diagrams/manual/diagrams-manual.html#named-subdiagrams the user manual]. The API for working with subdiagrams is not quite as convenient as the old API for LocatedEnvelopes, but that is being worked on. If you had some code using LocatedEnvelopes, please feel free to write to the [http://groups.google.com/group/diagrams-discuss mailing list] for help porting it.
associated locations, instead of the associated subdiagrams. In
+
particular the output is suitable to be rendered to a String
+
== Other diagrams-core API changes ==
using 'show'.
 
   
- The new 'subMap' function fills a similar role that 'names' used
+
* <code>Graphics.Rendering.Diagrams.UDTree</code> has been split out into a separate [http://hackage.haskell.org/package/dual-tree <code>dual-tree</code> package] (which has also been substantially rewritten). If you were making direct use of <code>UDTree</code> before, tough luck!
to play, returning the entire mapping from names to subdiagrams.
 
   
- 'juxtaposeDefault' is now the identity on the second object if
+
* <code>Graphics.Rendering.Diagrams.{Monoids,MList}</code> have been split out into a separate [http://hackage.haskell.org/package/monoid-extras <code>monoid-extras</code> package].
either one has an empty envelope. In particular this means that
 
'mempty' is now an identity element for 'beside' and friends.
 
   
  +
* The <code>names</code> function now returns a list of names and their associated locations, instead of the associated subdiagrams. In particular the output is suitable to be rendered to a <code>String</code> using <code>show</code> (subdiagrams have no <code>Show</code> instance). The new <code>subMap</code> function fills a similar role to what <code>names</code> used to play, returning the entire mapping from names to subdiagrams.
   
 
== StyleParam deleted from Diagrams.Backend.Cairo.Text ==
 
== StyleParam deleted from Diagrams.Backend.Cairo.Text ==

Latest revision as of 18:50, 11 December 2012

This page describes breaking API changes between diagrams 0.5 and 0.6, along with explanations of how to migrate to the new 0.6 API.

Contents

[edit] 1 Reorganizations to diagrams-core

  • The modules in diagrams-core have all been renamed to be more consistent with the module naming scheme in the rest of the diagrams universe. For most users this should make no different, unless you are affected by diagrams-core#17 and have explicitly imported Graphics.Rendering.Diagrams.Points. In particular:
    • Graphics.Rendering.Diagrams --> Diagrams.Core
    • Grahpics.Rendering.Diagrams.Core --> Diagrams.Core.Types
    • Graphics.Rendering.Diagrams.* --> Diagrams.Core.*

[edit] 2 Subdiagrams

Previous versions of diagrams-core had a mechanism for associating names with a LocatedEnvelope. Now, names are associated with Subdiagrams. For example, the type of withName changed from

withName :: 
  (IsName n, 
   AdditiveGroup (Scalar v), Floating (Scalar v), InnerSpace v, HasLinearMap v)
  => 
  n -> (LocatedEnvelope v -> QDiagram b v m -> QDiagram b v m) 
    -> QDiagram b v m -> QDiagram b v m

to

withName :: 
  IsName n 
  => 
  n -> (Subdiagram b v m -> QDiagram b v m -> QDiagram b v m) 
    -> QDiagram b v m -> QDiagram b v m

(As you can see, some type class constraints also disappeared, due to the refactoring of the underlying data structure.)

The types of withNameAll and withNames changed similarly.

For more information on subdiagrams and their API, see the user manual. The API for working with subdiagrams is not quite as convenient as the old API for LocatedEnvelopes, but that is being worked on. If you had some code using LocatedEnvelopes, please feel free to write to the mailing list for help porting it.

[edit] 3 Other diagrams-core API changes

  • Graphics.Rendering.Diagrams.UDTree has been split out into a separate dual-tree package (which has also been substantially rewritten). If you were making direct use of UDTree before, tough luck!
  • The names function now returns a list of names and their associated locations, instead of the associated subdiagrams. In particular the output is suitable to be rendered to a String using show (subdiagrams have no Show instance). The new subMap function fills a similar role to what names used to play, returning the entire mapping from names to subdiagrams.

[edit] 4 StyleParam deleted from Diagrams.Backend.Cairo.Text

The StyleParam type has been removed from Diagrams.Backend.Cairo.Text. Functions that used to take a StyleParam argument now take a Style R2 parameter, determining the style to apply to the text before rendering/querying information about the text. These parameters can be created a variety of ways, but the most direct will likely be by applying style-transforming functions such as font, fontSize, fontSlant, and fontWeight to mempty. This works because there are instances of HasStyle and Monoid for Style v.