Maintainer | diagrams-discuss@googlegroups.com |
---|
This module defines a type of names which can be used for referring to locations within diagrams, and related types.
- data AName where
- newtype Name = Name [AName]
- class (Typeable a, Ord a, Show a) => IsName a where
- (.>) :: (IsName a1, IsName a2) => a1 -> a2 -> Name
- class Qualifiable q where
- newtype NameMap v = NameMap (Map Name [(Point v, TransInv (Bounds v))])
- fromNames :: (AdditiveGroup (Scalar v), Ord (Scalar v), IsName a) => [(a, Point v)] -> NameMap v
- fromNamesB :: IsName a => [(a, (Point v, Bounds v))] -> NameMap v
- rememberAs :: IsName a => a -> Point v -> Bounds v -> NameMap v -> NameMap v
- lookupN :: IsName n => n -> NameMap v -> Maybe [(Point v, Bounds v)]
Names
Atomic names
Names
A (qualified) name is a (possibly empty) sequence of atomic names.
(.>) :: (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.
Qualifiable Name | Of course, names can be qualified using |
Qualifiable (NameMap v) |
|
(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. |
Name maps
A NameMap
is a map associating names to pairs of points (local
origins) and bounding functions. There can be multiple (point,
bounding function) pairs associated with each name.
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) |
|
(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) |
|
Constructing name maps
fromNames :: (AdditiveGroup (Scalar v), Ord (Scalar v), IsName a) => [(a, Point v)] -> NameMap vSource
Construct a NameMap
from a list of (name, point) pairs. The
bounding functions will be empty.
fromNamesB :: IsName a => [(a, (Point v, Bounds v))] -> NameMap vSource
Construct a NameMap
from a list of associations between names
and (point, bounds) pairs.
rememberAs :: IsName a => a -> Point v -> Bounds v -> NameMap v -> NameMap vSource
Give a name to a point and bounding function.
Searching within name maps
lookupN :: IsName n => n -> NameMap v -> Maybe [(Point v, Bounds v)]Source
Look for the given name in a name map, returning a list of points and bounding regions 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.