Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Haskell
Wiki community
Recent changes
Random page
HaskellWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Diagrams/Dev/Arrows
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== DelayedLeaf === At the risk of stating the obvious, <code>Diagrams</code> (i.e. <code>DualTree</code>s) are created from the bottom (leaves) up, but <code>DTree</code>s and <code>RTrees</code> from the top (root) down. Suppose we are creating an arrow using diagrams functions and combinators. When we are finished we have essentially added a subtree to a diagram. That subtree cannot use any of the informtion about transforms and styles above it in the tree (they have not yet been created) so the arrow is unable to use its final size and location (i.e. accumulated transform) in its subtree. Brent's elegant solution was twofold: # To hold off on creating the arrow by creating a new type of leaf, the <code>DelayedLeaf</code> in addition to <code>Prim b v</code> that we already had. The <code>DelayedLeaf</code> contains a funtion <code>DownAnnots v -> QDiagram b v m</code>, in other words a set of instructions about how to create the arrow once its <code>DownAnnots</code> are known. # A modification of the <code>arrow'</code> function so that it returns a <code>DelayedLeaf</code>. The function wrapped in the <code>DelayedLeaf</code>, <code>delayedArrow</code> takes as parameter the <code>DownAnnots</code> and hence the styles and transforms. The upshot is that an arrow gets to know the accumulated <code>DownAnnots</code> above it to use it's conversion to a diagram. Since creation of a <code>DTree</code> is top down, by the time we reach a <code>DelayedLeaf</code> in the `DualTree` we already have all of the accumlated transforms and styles that will be applied to the arrow. So the <code>DelayedLeaf</code> can be expanded by running the function <code>DownAnnots v -> QDiagram b v m</code> on the accumulated <code>DownAnnots</code> and recursively calling <code>fromDTree</code> to insert the arrow into the <code>DTree</code>. It is import ant to note, though at this point the arrow is essentially finished, all transforms and style have been applied. By the way, I'm pretty sure that at this point we could have removed the <code>scaleInv</code> wrapper from the head. (As a side benefit, we are able to use all of the styles that are applied above the arrow in the tree to do things like change the color of the entire arrow with functions like <code>lc red</code>.) There were still some enhancements we wanted to make, https://github.com/diagrams/diagrams-lib/issues/162, but for the most part all was well in Arrow land until ...
Summary:
Please note that all contributions to HaskellWiki are considered to be released under simple permissive license (see
HaskellWiki:Copyrights
for details). If you don't want your writing to be edited mercilessly and redistributed at will, then don't submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!
Cancel
Editing help
(opens in new window)
Toggle limited content width