diagrams-core- Core libraries for diagrams EDSL

Safe HaskellNone




This module provides tools for compiling QDiagrams into a more convenient and optimized tree form, suitable for use by backends.


Tools for backends

data RNode b v a Source


RStyle (Style v)

A style node.

RFrozenTr (Transformation v)

A "frozen" transformation, i.e. one which was applied after a call to freeze. It applies to everything below it in the tree. Note that line width and other similar "scale invariant" attributes should be affected by this transformation. In the case of 2D, some backends may not support stroking in the context of an arbitrary transformation; such backends can instead use the avgScale function from Diagrams.TwoD.Transform (from the diagrams-lib package).

RAnnot a 
RPrim (Transformation v) (Prim b v)

A primitive, along with the (non-frozen) transformation which applies to it.


type RTree b v a = Tree (RNode b v a)Source

An RTree is a compiled and optimized representation of a QDiagram, which can be used by backends. They have several invariants which backends may rely upon:

  • All non-frozen transformations have been pushed all the way to the leaves.
  • RPrim nodes never have any children.

toRTree :: HasLinearMap v => QDiagram b v m -> RTree b v AnnotationSource

Compile a QDiagram into an RTree. Suitable for use by backends when implementing renderData.


toDTree :: HasLinearMap v => QDiagram b v m -> Maybe (DTree b v Annotation)Source

Convert a QDiagram into a raw tree.

fromDTree :: HasLinearMap v => DTree b v Annotation -> RTree b v AnnotationSource

Convert a DTree to an RTree which can be used dirctly by backends. A DTree includes nodes of type DTransform (Split (Transformation v)); in the RTree the frozen part of the transform is put in a node of type RFrozenTr (Transformation v) and the unfrozen part is pushed down until it is either frozen or reaches a primitive node.