diagrams-lib-1.4.3: Embedded domain-specific language for declarative graphics

Copyright | (c) 2013-2015 diagrams-lib team (see LICENSE)
License | BSD-style (see LICENSE)
Maintainer | diagrams-discuss@googlegroups.com
Safe Haskell | None
Language | Haskell2010

Diagrams.Located

Description

"Located" things, i.e. things with a concrete location: intuitively, `Located a ~ (a, Point)`. Wrapping a translationally invariant thing (e.g. a `Segment` or `Trail`) in `Located` pins it down to a particular location and makes it no longer translationally invariant.

Synopsis

- data Located a = Loc {
  - loc :: Point (V a) (N a)
  - unLoc :: a
  }
- at :: a -> Point (V a) (N a) -> Located a
- viewLoc :: Located a -> (Point (V a) (N a), a)
- mapLoc :: SameSpace a b => (a -> b) -> Located a -> Located b
- located :: SameSpace a b => Lens (Located a) (Located b) a b
- _loc :: Lens' (Located a) (Point (V a) (N a))

# Documentation

data Located a Source #

"Located" things, i.e. things with a concrete location: intuitively, `Located a ~ (Point, a)`. Wrapping a translationally invariant thing (e.g. a `Segment` or `Trail`) in `Located` pins it down to a particular location and makes it no longer translationally invariant.

`Located` is intentionally abstract. To construct `Located` values, use `at`. To destruct, use `viewLoc`, `unLoc`, or `loc`. To map, use `mapLoc`.

Much of the utility of having a concrete type for the `Located` concept lies in the type class instances we can give it. The `HasOrigin`, `Transformable`, `Enveloped`, `Traced`, and `TrailLike` instances are particularly useful; see the documented instances below for more information.

Constructors

Loc |

Fields

- loc :: Point (V a) (N a)

  Project out the location of a `Located` value.

- unLoc :: a

  Project the value of type `a` out of a `Located a`, discarding the location.

#### Instances

Instances details

(Eq (V a (N a)), Eq a) => Eq (Located a) Source # |
Instance details Defined in Diagrams.Located Methods (==) :: Located a -> Located a -> Bool (/=) :: Located a -> Located a -> Bool
(Ord (V a (N a)), Ord a) => Ord (Located a) Source # |
Instance details Defined in Diagrams.Located Methods compare :: Located a -> Located a -> Ordering (<) :: Located a -> Located a -> Bool (<=) :: Located a -> Located a -> Bool (>) :: Located a -> Located a -> Bool (>=) :: Located a -> Located a -> Bool max :: Located a -> Located a -> Located a min :: Located a -> Located a -> Located a
(Read (V a (N a)), Read a) => Read (Located a) Source # |
Instance details Defined in Diagrams.Located Methods readsPrec :: Int -> ReadS (Located a) readList :: ReadS [Located a] readPrec :: ReadPrec (Located a) readListPrec :: ReadPrec [Located a]
(Show (V a (N a)), Show a) => Show (Located a) Source # |
Instance details Defined in Diagrams.Located Methods showsPrec :: Int -> Located a -> ShowS show :: Located a -> String showList :: [Located a] -> ShowS
Generic (Located a) Source # |
Instance details Defined in Diagrams.Located Associated Types type Rep (Located a) :: Type -> Type Methods from :: Located a -> Rep (Located a) x to :: Rep (Located a) x -> Located a
(Serialize a, Serialize (V a (N a))) => Serialize (Located a) Source # |
Instance details Defined in Diagrams.Located Methods put :: Putter (Located a) Source # get :: Get (Located a) Source #
Enveloped a => Juxtaposable (Located a) Source # |
Instance details Defined in Diagrams.Located Methods juxtapose :: Vn (Located a) -> Located a -> Located a -> Located a Source #
Enveloped a => Enveloped (Located a) Source # | The envelope of a `Located a` is the envelope of the `a`, translated to the location.
Instance details Defined in Diagrams.Located Methods getEnvelope :: Located a -> Envelope (V (Located a)) (N (Located a)) Source #
(Traced a, Num (N a)) => Traced (Located a) Source # | The trace of a `Located a` is the trace of the `a`, translated to the location.
Instance details Defined in Diagrams.Located Methods getTrace :: Located a -> Trace (V (Located a)) (N (Located a)) Source #
Qualifiable a => Qualifiable (Located a) Source # |
Instance details Defined in Diagrams.Located Methods (.>>) :: IsName a0 => a0 -> Located a -> Located a Source #
(Additive (V a), Num (N a), Transformable a) => Transformable (Located a) Source # | Applying a transformation `t` to a `Located a` results in the transformation being applied to the location, and the linear portion of `t` being applied to the value of type `a` (i.e. it is not translated).
Instance details Defined in Diagrams.Located Methods transform :: Transformation (V (Located a)) (N (Located a)) -> Located a -> Located a Source #
(Num (N a), Additive (V a)) => HasOrigin (Located a) Source # | `Located a` is an instance of `HasOrigin` whether `a` is or not. In particular, translating a `Located a` simply translates the associated point (and does not affect the value of type `a`).
Instance details Defined in Diagrams.Located Methods moveOriginTo :: Point (V (Located a)) (N (Located a)) -> Located a -> Located a Source #
(Metric v, OrderedField n) => Reversing (Located (Trail v n)) Source # | Same as `reverseLocTrail`.
Instance details Defined in Diagrams.Trail Methods reversing :: Located (Trail v n) -> Located (Trail v n) Source #
(Metric v, OrderedField n) => Reversing (Located (Trail' l v n)) Source # | Same as `reverseLocLine` or `reverseLocLoop`.
Instance details Defined in Diagrams.Trail Methods reversing :: Located (Trail' l v n) -> Located (Trail' l v n) Source #
(InSpace v n a, Fractional n, HasArcLength a, Codomain a ~ v) => HasArcLength (Located a) Source # |

Instance details

Defined in Diagrams.Located

Methods

arcLengthBounded :: N (Located a) -> Located a -> Interval (N (Located a)) Source #

arcLength :: N (Located a) -> Located a -> N (Located a) Source #

stdArcLength :: Located a -> N (Located a) Source #

arcLengthToParam :: N (Located a) -> Located a -> N (Located a) -> N (Located a) Source #

stdArcLengthToParam :: Located a -> N (Located a) -> N (Located a) Source #

(InSpace v n a, Fractional n, Parametric a, Sectionable a, Codomain a ~ v) => Sectionable (Located a) Source # |
Instance details Defined in Diagrams.Located Methods splitAtParam :: Located a -> N (Located a) -> (Located a, Located a) Source # section :: Located a -> N (Located a) -> N (Located a) -> Located a Source # reverseDomain :: Located a -> Located a Source #
(InSpace v n a, EndValues a, Codomain a ~ v) => EndValues (Located a) Source # |
Instance details Defined in Diagrams.Located Methods atStart :: Located a -> Codomain (Located a) (N (Located a)) Source # atEnd :: Located a -> Codomain (Located a) (N (Located a)) Source #
(DomainBounds t, EndValues (Tangent t)) => EndValues (Tangent (Located t)) Source # |
Instance details Defined in Diagrams.Tangent Methods atStart :: Tangent (Located t) -> Codomain (Tangent (Located t)) (N (Tangent (Located t))) Source # atEnd :: Tangent (Located t) -> Codomain (Tangent (Located t)) (N (Tangent (Located t))) Source #
DomainBounds a => DomainBounds (Located a) Source # |
Instance details Defined in Diagrams.Located Methods domainLower :: Located a -> N (Located a) Source # domainUpper :: Located a -> N (Located a) Source #
(InSpace v n a, Parametric a, Codomain a ~ v) => Parametric (Located a) Source # |
Instance details Defined in Diagrams.Located Methods atParam :: Located a -> N (Located a) -> Codomain (Located a) (N (Located a)) Source #
Parametric (Tangent t) => Parametric (Tangent (Located t)) Source # |
Instance details Defined in Diagrams.Tangent Methods atParam :: Tangent (Located t) -> N (Tangent (Located t)) -> Codomain (Tangent (Located t)) (N (Tangent (Located t))) Source #
Alignable a => Alignable (Located a) Source # |

Instance details

Defined in Diagrams.Located

Methods

alignBy' :: (InSpace v n (Located a), Fractional n, HasOrigin (Located a)) => (v n -> Located a -> Point v n) -> v n -> n -> Located a -> Located a Source #

defaultBoundary :: (V (Located a) ~ v, N (Located a) ~ n) => v n -> Located a -> Point v n Source #

alignBy :: (InSpace v n (Located a), Fractional n, HasOrigin (Located a)) => v n -> n -> Located a -> Located a Source #

TrailLike t => TrailLike (Located t) Source # | `Located` things are trail-like as long as the underlying type is. The location is taken to be the location of the input located trail.
Instance details Defined in Diagrams.TrailLike Methods trailLike :: Located (Trail (V (Located t)) (N (Located t))) -> Located t Source #
ToPath (Located [Segment Closed v n]) Source # |
Instance details Defined in Diagrams.Path Methods toPath :: Located [Segment Closed v n] -> Path (V (Located [Segment Closed v n])) (N (Located [Segment Closed v n])) Source #
ToPath (Located (Segment Closed v n)) Source # |
Instance details Defined in Diagrams.Path Methods toPath :: Located (Segment Closed v n) -> Path (V (Located (Segment Closed v n))) (N (Located (Segment Closed v n))) Source #
ToPath (Located (Trail v n)) Source # |
Instance details Defined in Diagrams.Path Methods toPath :: Located (Trail v n) -> Path (V (Located (Trail v n))) (N (Located (Trail v n))) Source #
ToPath (Located (Trail' l v n)) Source # |
Instance details Defined in Diagrams.Path Methods toPath :: Located (Trail' l v n) -> Path (V (Located (Trail' l v n))) (N (Located (Trail' l v n))) Source #
RealFloat n => HasQuery (Located (Trail V2 n)) Crossings Source # |
Instance details Defined in Diagrams.TwoD.Path Methods getQuery :: Located (Trail V2 n) -> Query (V (Located (Trail V2 n))) (N (Located (Trail V2 n))) Crossings Source #
RealFloat n => HasQuery (Located (Trail' l V2 n)) Crossings Source # |
Instance details Defined in Diagrams.TwoD.Path Methods getQuery :: Located (Trail' l V2 n) -> Query (V (Located (Trail' l V2 n))) (N (Located (Trail' l V2 n))) Crossings Source #
(LinearMappable a b, N a ~ N b, r ~ Located b) => AffineMappable (Located a) r Source # |
Instance details Defined in Diagrams.LinearMap Methods amap :: AffineMap (V (Located a)) (V r) (N r) -> Located a -> r Source #
(LinearMappable a b, r ~ Located b) => LinearMappable (Located a) r Source # |
Instance details Defined in Diagrams.LinearMap Methods vmap :: (Vn (Located a) -> Vn r) -> Located a -> r Source #
(Metric v, Metric u, OrderedField n, r ~ Located (Trail u n)) => Deformable (Located (Trail v n)) r Source # |
Instance details Defined in Diagrams.Deform Methods deform' :: N (Located (Trail v n)) -> Deformation (V (Located (Trail v n))) (V r) (N (Located (Trail v n))) -> Located (Trail v n) -> r Source # deform :: Deformation (V (Located (Trail v n))) (V r) (N (Located (Trail v n))) -> Located (Trail v n) -> r Source #
Each (Path v n) (Path v' n') (Located (Trail v n)) (Located (Trail v' n')) Source # |
Instance details Defined in Diagrams.Path Methods each :: Traversal (Path v n) (Path v' n') (Located (Trail v n)) (Located (Trail v' n')) Source #
Cons (Path v n) (Path v' n') (Located (Trail v n)) (Located (Trail v' n')) Source # |
Instance details Defined in Diagrams.Path Methods _Cons :: Prism (Path v n) (Path v' n') (Located (Trail v n), Path v n) (Located (Trail v' n'), Path v' n') Source #
Snoc (Path v n) (Path v' n') (Located (Trail v n)) (Located (Trail v' n')) Source # |
Instance details Defined in Diagrams.Path Methods _Snoc :: Prism (Path v n) (Path v' n') (Path v n, Located (Trail v n)) (Path v' n', Located (Trail v' n')) Source #
type Rep (Located a) Source # |

Instance details

Defined in Diagrams.Located

type Rep (Located a) = D1 ('MetaData "Located" "Diagrams.Located" "diagrams-lib-1.4.3-2MCK5qL1oJEzpDikibpBu" 'False) (C1 ('MetaCons "Loc" 'PrefixI 'True) (S1 ('MetaSel ('Just "loc") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Point (V a) (N a))) :*: S1 ('MetaSel ('Just "unLoc") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

type V (Located a) Source # |
Instance details Defined in Diagrams.Located type V (Located a) = V a
type N (Located a) Source # |
Instance details Defined in Diagrams.Located type N (Located a) = N a
type Codomain (Located a) Source # |
Instance details Defined in Diagrams.Located type Codomain (Located a) = Point (Codomain a)

at :: a -> Point (V a) (N a) -> Located a infix 5 Source #

Construct a `Located a` from a value of type `a` and a location. `at` is intended to be used infix, like `x `at` origin`.

viewLoc :: Located a -> (Point (V a) (N a), a) Source #

Deconstruct a `Located a` into a location and a value of type `a`. `viewLoc` can be especially useful in conjunction with the `ViewPatterns` extension.

mapLoc :: SameSpace a b => (a -> b) -> Located a -> Located b Source #

`Located` is not a `Functor`, since changing the type could change the type of the associated vector space, in which case the associated location would no longer have the right type. `mapLoc` has an extra constraint specifying that the vector space must stay the same.

(Technically, one can say that for every vector space `v`, `Located` is a little-f (endo)functor on the category of types with associated vector space `v`; but that is not covered by the standard `Functor` class.)

located :: SameSpace a b => Lens (Located a) (Located b) a b Source #

A lens giving access to the object within a `Located` wrapper.

_loc :: Lens' (Located a) (Point (V a) (N a)) Source #

Lens onto the location of something `Located`.