Personal tools


From HaskellWiki

< Diagrams | Dev
Revision as of 01:43, 15 May 2014 by Byorgey (Talk | contribs)

Jump to: navigation, search

This page describes the motivation and design for a refactoring of diagrams, to give them a semantics based on computing fixed points of functions from "context" information to raw tree of primitives together with some summary information.


1 Reference

See the original "manifesto" and ensuing mailing list discussion here:

See also later IRC discussion beginning here:

2 Detailed design

Most of the changes should be in the diagrams-core package, though a few things in diagrams-lib may need to change as well.

2.1 diagrams-core

No changes should be necessary to the following modules (all prefixed by Diagrams.Core): Envelope, HasOrigin, Juxtapose, Names, Points, Query, Trace, Transform, V.

I'm not sure about Style yet.

2.1.1 Diagrams.Core.Compile

  • Change the name of UpAnnots to Summary.
  • Change the name of DownAnnots to Context, and change its definition to
 type Context b v m = Style v
                    ::: Name
                    ::: SubMap b v m
                    ::: ()

The addition of SubMap is so that we can use the positions of laid-out subdiagrams to compute the positions of others.

  • transfToAnnot and transfFromAnnot can be deleted.
  • QDiaLeaf and withQDiaLeaf can be deleted.
  • Create new definitions
 type ContextualT b v q m a = ReaderT (Context b v q) m a
 type Contextual b v q a = ContextualT b v q Identity a

One could imagine making ContextualT a newtype but that would necessitate writing lots of instances for things like MonadState, MonadReader, and so on.

  • The definition of QDiagram should be changed to something like
 type QDiagram b v m = Contextual b v m (RTree b v Annotation, Summary b v m) 

It's important that this is NOT a newtype, so we can freely use the Monad instance for Contextual when working with diagrams.

2.1.2 Diagrams.Core.Types

2.2 diagrams-lib