diagrams-core-0.2: Core libraries for diagrams EDSL

Maintainerdiagrams-discuss@googlegroups.com

Graphics.Rendering.Diagrams.Names

Contents

Description

This module defines a type of names which can be used for referring to locations within diagrams, and related types.

Synopsis

Names

data AName Source

An atomic name is either a number or a string. Numeric names are provided for convenience in naming lists of things, such as a row of ten squares, or the vertices of a path.

Constructors

IName Integer 
SName String 

Instances

Eq AName

Note that equality on names does not distinguish between integers and their String representations.

Ord AName 
Show AName 

newtype Name Source

A (qualified) name is a (possibly empty) sequence of atomic names. Atomic names can be either numbers or arbitrary strings. Numeric names are provided for convenience in naming lists of things, such as a row of ten squares, or the vertices of a path.

Constructors

Name [AName] 

Instances

Eq Name 
Ord Name 
Show Name 
Monoid Name 
Qualifiable Name

Names can be qualified by prefixing them with other names.

IsName Name 
Action Name a

Names don't act on anything else.

Action Name (NameMap v)

A name acts on a name map by qualifying every name in it.

class IsName n whereSource

Instaces of IsName are things which can be converted to names.

Methods

toName :: n -> NameSource

class Qualifiable a whereSource

Instances of Qualifiable are things which can be qualified by prefixing them with a name.

Methods

(|>) :: IsName n => n -> a -> aSource

Qualify with the given name.

Instances

Qualifiable Name

Names can be qualified by prefixing them with other names.

Qualifiable (NameMap v)

NameMaps are qualifiable: if ns is a NameMap, then n |> ns is the same NameMap except with every name qualified by n.

(HasLinearMap v, InnerSpace v, OrderedField (Scalar v), Monoid m) => Qualifiable (AnnDiagram b v m)

Diagrams can be qualified so that all their named points can now be referred to using the qualification prefix.

(||>) :: (IsName n, IsName m) => n -> m -> NameSource

Convenient operator for writing complete names in the form a1 |> a2 |> a3 ||> a4. In particular, n1 ||> n2 is equivalent to n1 |> toName n2.

Name maps

newtype NameMap v Source

A NameMap is a map from names to points, possibly with multiple points associated with each name.

Constructors

NameMap (Map Name [Point v]) 

Instances

Action Name (NameMap v)

A name acts on a name map by qualifying every name in it.

Monoid (NameMap v)

NameMaps form a monoid with the empty map as the identity, and map union as the binary operation. No information is ever lost: if two maps have the same name in their domain, the resulting map will associate that name to the union of the two sets of points associated with that name.

VectorSpace v => HasOrigin (NameMap v) 
Qualifiable (NameMap v)

NameMaps are qualifiable: if ns is a NameMap, then n |> ns is the same NameMap except with every name qualified by n.

HasLinearMap v => Transformable (NameMap v) 

Constructing name maps

fromNames :: IsName n => [(n, Point v)] -> NameMap vSource

Construct a NameMap from a list of (name, point) pairs.

rememberAs :: Name -> Point v -> NameMap v -> NameMap vSource

Give a name to a point.

Searching within name maps

lookupN :: IsName n => n -> NameMap v -> Maybe [Point v]Source

Look for the given name in a name map, returning a list of points associated with that name. If no names match the given name exactly, return all the points associated with names of which the given name is a suffix.