If you want the old behavior, simply perform an alignment on the first diagram before combining. That is, replace <code>beside v d1 d2</code> by <code>beside v (align v d1) d2</code>. If <code>d1</code> and <code>d2</code> are the same width the same effect can be achieved by first combining and then centering.

If you want the old behavior, simply perform an alignment on the first diagram before combining. That is, replace <code>beside v d1 d2</code> by <code>beside v (align v d1) d2</code>. If <code>d1</code> and <code>d2</code> are the same width the same effect can be achieved by first combining and then centering.

+

+

== AnnDiagram renamed QDiagram ==

+

+

This change was made to be consistent with referring to the monoidal parameter as a "query" rather than an "annotation". Simply change <code>AnnDiagram</code> to <code>QDiagram</code> everywhere it occurs.

+

+

== Additional Semigroup constraints ==

+

+

In some places diagrams now requires a <code>Semigroup</code> constraint in addition to <code>Monoid</code> (ideally <code>Monoid</code> would have <code>Semigroup</code> as a superclass...). If you get an error about "could not deduce <code>Semigroup</code> constraint" you probably just need to add one.

Revision as of 03:27, 6 March 2012

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

Contents

1 R2 and P2 are now abstract

The biggest change to the API between versions 0.4 and 0.5 is that the R2 and P2 types (representing 2D vectors and points, respectively) are now abstract. R2 used to be a synonym for (Double, Double) but this is no longer the case. Also, the constructor P for points is no longer exported.

To convert a vector v to a point, use origin .+^ v. To convert a point p to a vector, use p .-. origin.

2 roundedRect

The roundedRect function now takes two Double arguments instead of an R2 argument, to be more consistent with rect. If you had something like roundedRect (2,3) 0.2, just change it to roundedRect 2 3 0.2.

3 circlePath

The circlePath function has been removed; you should be able to simply replace it with circle.

4 Semantics of beside

The semantics of beside---and hence also terms (|||) and (===), which are implemented in terms of beside---is now different. In particular, the local origin of beside v d1 d2 is now the local origin of d1 rather than the point of tangency between d1 and d2. This has several advantages, namely

beside v, (|||), and (===) are now associative

The new semantics is more consistent with the semantics of cat.

If you want the old behavior, simply perform an alignment on the first diagram before combining. That is, replace beside v d1 d2 by beside v (align v d1) d2. If d1 and d2 are the same width the same effect can be achieved by first combining and then centering.

5 AnnDiagram renamed QDiagram

This change was made to be consistent with referring to the monoidal parameter as a "query" rather than an "annotation". Simply change AnnDiagram to QDiagram everywhere it occurs.

6 Additional Semigroup constraints

In some places diagrams now requires a Semigroup constraint in addition to Monoid (ideally Monoid would have Semigroup as a superclass...). If you get an error about "could not deduce Semigroup constraint" you probably just need to add one.