diagrams-core-0.5: Core libraries for diagrams EDSL

Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone

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

Atomic names

data AName whereSource

Atomic names. AName is just an existential wrapper around things which are Typeable, Ord and Show.

Constructors

AName :: (Typeable a, Ord a, Show a) => a -> AName 

Names

newtype Name Source

A (qualified) name is a (possibly empty) sequence of atomic names.

Constructors

Name [AName] 

Instances

Eq Name 
Ord Name 
Show Name 
Typeable Name 
Monoid Name 
Semigroup Name 
Qualifiable Name

Of course, names can be qualified using (.>).

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.

Newtype (NameMap v) (Map Name [LocatedEnvelope v]) 
Newtype (QDiagram b v m) (UDTree (UpAnnots v m) (DownAnnots v) (Prim b v)) 

class (Typeable a, Ord a, Show a) => IsName a whereSource

Class for those types which can be used as names. They must support Typeable (to facilitate extracting them from existential wrappers), Ord (for comparison and efficient storage) and Show.

Methods

toName :: a -> NameSource

(.>) :: (IsName a1, IsName a2) => a1 -> a2 -> NameSource

Convenient operator for writing qualified names with atomic components of different types. Instead of writing toName a1 <> toName a2 <> toName a3 you can just write a1 .> a2 .> a3.

Qualifiable

class Qualifiable q whereSource

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

Methods

(|>) :: IsName a => a -> q -> qSource

Qualify with the given name.

Instances

Qualifiable Name

Of course, names can be qualified using (.>).

Qualifiable (NameMap v)

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

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

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

Name maps

newtype NameMap v Source

A NameMap is a map associating names to located envelopes, i.e. envelopes with concrete locations for their base points. There can be multiple associations for any given name.

Constructors

NameMap (Map Name [LocatedEnvelope v]) 

Instances

Action Name (NameMap v)

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

Show v => Show (NameMap v) 
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 concatenation of the information associated with that name.

Semigroup (NameMap v) 
(AdditiveGroup (Scalar v), Fractional (Scalar v), InnerSpace v) => HasOrigin (NameMap v) 
(AdditiveGroup (Scalar v), InnerSpace v, Floating (Scalar v), HasLinearMap v) => Transformable (NameMap v) 
Qualifiable (NameMap v)

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

Newtype (NameMap v) (Map Name [LocatedEnvelope v]) 
Newtype (QDiagram b v m) (UDTree (UpAnnots v m) (DownAnnots v) (Prim b v)) 

Constructing name maps

fromNames :: (InnerSpace v, AdditiveGroup (Scalar v), Ord (Scalar v), Floating (Scalar v), IsName a) => [(a, Point v)] -> NameMap vSource

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

fromNamesB :: IsName a => [(a, LocatedEnvelope v)] -> NameMap vSource

Construct a NameMap from a list of associations between names and located envelopes.

rememberAs :: IsName a => a -> LocatedEnvelope v -> NameMap v -> NameMap vSource

Give a name to a located envelope.

Searching within name maps

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

Look for the given name in a name map, returning a list of located envelopes 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.