diagrams-core-1.5.1.1: Core libraries for diagrams EDSL

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

Diagrams.Core

Contents

- Associated vector spaces
- Points
- Transformations
  - Utilities
  - Invertible linear transformations
  - General transformations
  - Some specific transformations
  - The Transformable class
  - Translational invariance
- Names
  - Subdiagram maps
- Attributes and styles
- Envelopes
- Traces
- Things with local origins
- Juxtaposable things
- Queries
- Primitives
- Diagrams
  - Subdiagrams
  - Measurements
- Backends
  - The null backend
- Convenience classes

Description

The core library of primitives forming the basis of an embedded domain-specific language for describing and rendering diagrams. Normal users of the diagrams library should almost never need to import anything from this package directly; instead, import modules (especially `Diagrams.Prelude`) from the diagrams-lib package, which re-exports most things of value to users.

For most library code needing access to core internals, it should be sufficient to import this module, which simply re-exports useful functionality from other modules in the core library. Library writers needing finer-grained access or functionality may occasionally find it useful to directly import one of the constituent core modules.

The diagrams library relies heavily on custom types and classes. Many of the relevant definitions are in the Diagrams.Core.Types module. Indeed the definition of the diagram type `QDiagram` is contained in: `QDiagram`.

The best place to start when learning about diagrams' types is the user manual: https://diagrams.github.io/doc/manual.html#type-reference The following list shows which types are contained in each module of Diagrams.Core.

- Diagrams.Core.Types

  - ``Annotation``,
  - ``UpAnnots` b v n m`, ``DownAnnots` v n`,
  - ``QDiaLeaf` b v n m`, ``Measure` n`,
  - ``Subdiagram` b v n m`, ``SubMap` b v n m`,
  - ``Prim` b v n`, ``Backend` b v n`,
  - ``DNode` b v n a`, ``DTree` b v n a`,
  - ``RNode` b v n a`, ``RTree` b v n a`,
  - ``NullBackend``, ``Renderable` t b`,
  - ``D` v n`.

- Diagrams.Core.Envelope

  - ``Envelope` v n`, ``Enveloped` a`,
  - ``OrderedField` s`.

- Diagrams.Core.Juxtapose

  - ``Juxtaposable` a`.

- Diagrams.Core.Names

  - ``AName``, ``Name``, ``IsName` a`,
  - ``Qualifiable` q`.

- Diagrams.Core.HasOrigin

  - ``HasOrigin` t`.

- Diagrams.Core.Query

  - ``Query` v n m`.

- Diagrams.Core.Style

  - ``AttributeClass` a`, ``Attribute` v n`,
  - ``Style` v n`, ``HasStyle``.

- Diagrams.Core.Trace

  - ``SortedList` a`,
  - ``Trace` v n`, ``Traced` a`.

- Diagrams.Core.Transform

  - `u `:-:` v`, ``HasLinearMap``, ``HasBasis``
  - ``Transformation` v n`, ``Transformable` t`,
  - ``TransInv` t`.

- Diagrams.Core.V

  - ``V` a`,
  - ``N` a`,
  - ``Vn` a`,
  - ``InSpace` v n a`,
  - ``SameSpace` a b`.

Synopsis

- type family V a :: Type -> Type
- type family N a
- type Vn a = V a (N a)
- type InSpace (v :: Type -> Type) n a = (V a ~ v, N a ~ n, Additive v, Num n)
- type SameSpace a b = (V a ~ V b, N a ~ N b)
- data Point (f :: Type -> Type) a
- origin :: forall (f :: Type -> Type) a. (Additive f, Num a) => Point f a
- (*.) :: forall (v :: Type -> Type) n. (Functor v, Num n) => n -> Point v n -> Point v n
- relative :: forall (f :: Type -> Type) a. (Additive f, Num a) => Point f a -> Iso' (Point f a) (f a)
- basis :: (Additive t, Traversable t, Num a) => [t a]
- dimension :: (Additive (V a), Traversable (V a)) => a -> Int
- determinant :: forall (v :: Type -> Type) n. (Additive v, Traversable v, Num n) => Transformation v n -> n
- isReflection :: forall (v :: Type -> Type) n. (Additive v, Traversable v, Num n, Ord n) => Transformation v n -> Bool
- data u :-: v
- (<->) :: (u -> v) -> (v -> u) -> u :-: v
- linv :: (u :-: v) -> v :-: u
- lapp :: (u :-: v) -> u -> v
- data Transformation (v :: Type -> Type) n
- inv :: forall (v :: Type -> Type) n. (Functor v, Num n) => Transformation v n -> Transformation v n
- transp :: Transformation v n -> v n :-: v n
- transl :: Transformation v n -> v n
- dropTransl :: forall (v :: Type -> Type) n. (Additive v, Num n) => Transformation v n -> Transformation v n
- apply :: Transformation v n -> v n -> v n
- papply :: forall (v :: Type -> Type) n. (Additive v, Num n) => Transformation v n -> Point v n -> Point v n
- fromLinear :: (Additive v, Num n) => (v n :-: v n) -> (v n :-: v n) -> Transformation v n
- translation :: v n -> Transformation v n
- translate :: Transformable t => Vn t -> t -> t
- moveTo :: forall (v :: Type -> Type) n t. (InSpace v n t, HasOrigin t) => Point v n -> t -> t
- place :: forall (v :: Type -> Type) n t. (InSpace v n t, HasOrigin t) => t -> Point v n -> t
- scaling :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => n -> Transformation v n
- scale :: forall (v :: Type -> Type) n a. (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a
- avgScale :: forall (v :: Type -> Type) n. (Additive v, Traversable v, Floating n) => Transformation v n -> n
- class Transformable t where
  - transform :: Transformation (V t) (N t) -> t -> t
- newtype TransInv t = TransInv t
- eye :: (HasBasis v, Num n) => v (v n)
- data AName
- data Name
- class (Typeable a, Ord a, Show a) => IsName a where
  - toName :: a -> Name
- class Qualifiable q where
  - (.>>) :: IsName a => a -> q -> q
- (.>) :: (IsName a1, IsName a2) => a1 -> a2 -> Name
- eachName :: (Typeable a, Ord a, Show a) => Traversal' Name a
- newtype SubMap b (v :: Type -> Type) n m = SubMap (Map Name [Subdiagram b v n m])
- fromNames :: forall a b (v :: Type -> Type) n m. IsName a => [(a, Subdiagram b v n m)] -> SubMap b v n m
- rememberAs :: forall a b (v :: Type -> Type) n m. IsName a => a -> QDiagram b v n m -> SubMap b v n m -> SubMap b v n m
- lookupSub :: forall nm b (v :: Type -> Type) n m. IsName nm => nm -> SubMap b v n m -> Maybe [Subdiagram b v n m]
- class (Typeable a, Semigroup a) => AttributeClass a
- data Attribute (v :: Type -> Type) n where
  - Attribute :: forall a (v :: Type -> Type) n. AttributeClass a => a -> Attribute v n
  - MAttribute :: forall a n (v :: Type -> Type). AttributeClass a => Measured n a -> Attribute v n
  - TAttribute :: forall a (v :: Type -> Type) n. (AttributeClass a, Transformable a, V a ~ v, N a ~ n) => a -> Attribute v n
- data Style (v :: Type -> Type) n
- class HasStyle a where
  - applyStyle :: Style (V a) (N a) -> a -> a
- getAttr :: forall a (v :: Type -> Type) n. AttributeClass a => Style v n -> Maybe a
- atAttr :: forall a (v :: Type -> Type) n. AttributeClass a => Lens' (Style v n) (Maybe a)
- atMAttr :: forall a n (v :: Type -> Type). (AttributeClass a, Typeable n) => Lens' (Style v n) (Maybe (Measured n a))
- atTAttr :: forall a (v :: Type -> Type) n. (V a ~ v, N a ~ n, AttributeClass a, Transformable a) => Lens' (Style v n) (Maybe a)
- applyAttr :: (AttributeClass a, HasStyle d) => a -> d -> d
- applyMAttr :: (AttributeClass a, N d ~ n, HasStyle d) => Measured n a -> d -> d
- applyTAttr :: (AttributeClass a, Transformable a, V a ~ V d, N a ~ N d, HasStyle d) => a -> d -> d
- newtype Envelope (v :: Type -> Type) n = Envelope (Maybe (v n -> Max n))
- appEnvelope :: Envelope v n -> Maybe (v n -> n)
- onEnvelope :: ((v n -> n) -> v n -> n) -> Envelope v n -> Envelope v n
- mkEnvelope :: (v n -> n) -> Envelope v n
- class (Metric (V a), OrderedField (N a)) => Enveloped a where
  - getEnvelope :: a -> Envelope (V a) (N a)
- envelopeVMay :: Enveloped a => Vn a -> a -> Maybe (Vn a)
- envelopeV :: Enveloped a => Vn a -> a -> Vn a
- envelopePMay :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> Maybe (Point v n)
- envelopeP :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> Point v n
- diameter :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> n
- radius :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> n
- size :: (V a ~ v, N a ~ n, Enveloped a, HasBasis v) => a -> v n
- newtype Trace (v :: Type -> Type) n = Trace (Point v n -> v n -> SortedList n)
- data SortedList a
- mkSortedList :: Ord a => [a] -> SortedList a
- getSortedList :: SortedList a -> [a]
- appTrace :: Trace v n -> Point v n -> v n -> SortedList n
- mkTrace :: (Point v n -> v n -> SortedList n) -> Trace v n
- class (Additive (V a), Ord (N a)) => Traced a where
  - getTrace :: a -> Trace (V a) (N a)
- traceV :: (n ~ N a, Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (V a n)
- traceP :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n)
- maxTraceV :: (n ~ N a, Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (V a n)
- maxTraceP :: (n ~ N a, Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n)
- rayTraceV :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (V a n)
- rayTraceP :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n)
- maxRayTraceV :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (V a n)
- maxRayTraceP :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n)
- class HasOrigin t where
  - moveOriginTo :: Point (V t) (N t) -> t -> t
- moveOriginBy :: (V t ~ v, N t ~ n, HasOrigin t) => v n -> t -> t
- class Juxtaposable a where
  - juxtapose :: Vn a -> a -> a -> a
- juxtaposeDefault :: (Enveloped a, HasOrigin a) => Vn a -> a -> a -> a
- newtype Query (v :: Type -> Type) n m = Query {
  - runQuery :: Point v n -> m
  }
- data Prim b (v :: Type -> Type) n where
  - Prim :: forall p b. (Transformable p, Typeable p, Renderable p b) => p -> Prim b (V p) (N p)
- data QDiagram b (v :: Type -> Type) n m
- type Diagram b = QDiagram b (V b) (N b) Any
- mkQD :: forall b (v :: Type -> Type) n m. Prim b v n -> Envelope v n -> Trace v n -> SubMap b v n m -> Query v n m -> QDiagram b v n m
- pointDiagram :: forall (v :: Type -> Type) n b m. (Metric v, Fractional n) => Point v n -> QDiagram b v n m
- envelope :: forall n (v :: Type -> Type) m b. (OrderedField n, Metric v, Monoid' m) => Lens' (QDiagram b v n m) (Envelope v n)
- trace :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => Lens' (QDiagram b v n m) (Trace v n)
- subMap :: forall (v :: Type -> Type) m n b. (Metric v, Semigroup m, OrderedField n) => Lens' (QDiagram b v n m) (SubMap b v n m)
- names :: forall (v :: Type -> Type) m n b. (Metric v, Semigroup m, OrderedField n) => QDiagram b v n m -> [(Name, [Point v n])]
- query :: forall m b (v :: Type -> Type) n. Monoid m => QDiagram b v n m -> Query v n m
- nameSub :: forall nm (v :: Type -> Type) n m b. (IsName nm, Metric v, OrderedField n, Semigroup m) => (QDiagram b v n m -> Subdiagram b v n m) -> nm -> QDiagram b v n m -> QDiagram b v n m
- withName :: forall nm (v :: Type -> Type) m n b. (IsName nm, Metric v, Semigroup m, OrderedField n) => nm -> (Subdiagram b v n m -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m
- withNameAll :: forall nm (v :: Type -> Type) m n b. (IsName nm, Metric v, Semigroup m, OrderedField n) => nm -> ([Subdiagram b v n m] -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m
- withNames :: forall nm (v :: Type -> Type) m n b. (IsName nm, Metric v, Semigroup m, OrderedField n) => [nm] -> ([Subdiagram b v n m] -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m
- localize :: forall b (v :: Type -> Type) n m. (Metric v, OrderedField n, Semigroup m) => QDiagram b v n m -> QDiagram b v n m
- href :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => String -> QDiagram b v n m -> QDiagram b v n m
- opacityGroup :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => Double -> QDiagram b v n m -> QDiagram b v n m
- groupOpacity :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => Double -> QDiagram b v n m -> QDiagram b v n m
- setEnvelope :: forall b (v :: Type -> Type) n m. (OrderedField n, Metric v, Monoid' m) => Envelope v n -> QDiagram b v n m -> QDiagram b v n m
- setTrace :: forall b (v :: Type -> Type) n m. (OrderedField n, Metric v, Semigroup m) => Trace v n -> QDiagram b v n m -> QDiagram b v n m
- atop :: forall n (v :: Type -> Type) m b. (OrderedField n, Metric v, Semigroup m) => QDiagram b v n m -> QDiagram b v n m -> QDiagram b v n m
- data Subdiagram b (v :: Type -> Type) n m = Subdiagram (QDiagram b v n m) (DownAnnots v n)
- mkSubdiagram :: forall b (v :: Type -> Type) n m. QDiagram b v n m -> Subdiagram b v n m
- getSub :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => Subdiagram b v n m -> QDiagram b v n m
- rawSub :: forall b (v :: Type -> Type) n m. Subdiagram b v n m -> QDiagram b v n m
- location :: forall (v :: Type -> Type) n b m. (Additive v, Num n) => Subdiagram b v n m -> Point v n
- subPoint :: forall (v :: Type -> Type) n b m. (Metric v, OrderedField n) => Point v n -> Subdiagram b v n m
- data Measured n a
- type Measure n = Measured n n
- fromMeasured :: Num n => n -> n -> Measured n a -> a
- output :: n -> Measure n
- local :: Num n => n -> Measure n
- global :: Num n => n -> Measure n
- normalized :: Num n => n -> Measure n
- scaleLocal :: Num n => n -> Measured n a -> Measured n a
- atLeast :: Ord n => Measure n -> Measure n -> Measure n
- atMost :: Ord n => Measure n -> Measure n -> Measure n
- class Backend b (v :: Type -> Type) n where
  - data Render b (v :: Type -> Type) n
  - type Result b (v :: Type -> Type) n
  - data Options b (v :: Type -> Type) n
  - adjustDia :: (Additive v, Monoid' m, Num n) => b -> Options b v n -> QDiagram b v n m -> (Options b v n, Transformation v n, QDiagram b v n m)
  - renderRTree :: b -> Options b v n -> RTree b v n Annotation -> Result b v n
- class Transformable t => Renderable t b where
  - render :: b -> t -> Render b (V t) (N t)
- renderDia :: forall b (v :: Type -> Type) n m. (Backend b v n, HasLinearMap v, Metric v, Typeable n, OrderedField n, Monoid' m) => b -> Options b v n -> QDiagram b v n m -> Result b v n
- renderDiaT :: forall b (v :: Type -> Type) n m. (Backend b v n, HasLinearMap v, Metric v, Typeable n, OrderedField n, Monoid' m) => b -> Options b v n -> QDiagram b v n m -> (Transformation v n, Result b v n)
- data NullBackend
- type D (v :: Type -> Type) n = QDiagram NullBackend v n Any
- type HasLinearMap (v :: Type -> Type) = (HasBasis v, Traversable v)
- type HasBasis (v :: Type -> Type) = (Additive v, Representable v, Rep v ~ E v)
- type OrderedField s = (Floating s, Ord s)
- type TypeableFloat n = (Typeable n, RealFloat n)
- type Monoid' = Monoid

# Associated vector spaces

type family V a :: Type -> Type Source #

Many sorts of objects have an associated vector space in which they "live". The type function `V` maps from object types to the associated vector space. The resulting vector space has kind `* -> *` which means it takes another value (a number) and returns a concrete vector. For example `V2` has kind `* -> *` and `V2 Double` is a vector.

#### Instances

Instances details

type V (Set a) Source # |
Instance details Defined in Diagrams.Core.V type V (Set a) = V a
type V (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform type V (TransInv t) = V t
type V (Deletable m) Source # |
Instance details Defined in Diagrams.Core.V type V (Deletable m) = V m
type V (Split m) Source # |
Instance details Defined in Diagrams.Core.V type V (Split m) = V m
type V (Maybe a) Source # |
Instance details Defined in Diagrams.Core.V type V (Maybe a) = V a
type V [a] Source # |
Instance details Defined in Diagrams.Core.V type V [a] = V a
type V (Map k a) Source # |
Instance details Defined in Diagrams.Core.V type V (Map k a) = V a
type V (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Envelope type V (Envelope v n) = v
type V (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Measure type V (Measured n a) = V a
type V (Attribute v n) Source # |
Instance details Defined in Diagrams.Core.Style type V (Attribute v n) = v
type V (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style type V (Style v n) = v
type V (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace type V (Trace v n) = v
type V (Transformation v n) Source # |
Instance details Defined in Diagrams.Core.Transform type V (Transformation v n) = v
type V (Point v n) Source # |
Instance details Defined in Diagrams.Core.Points type V (Point v n) = v
type V (m :+: n) Source # |
Instance details Defined in Diagrams.Core.V type V (m :+: n) = V m
type V (a, b) Source # |
Instance details Defined in Diagrams.Core.V type V (a, b) = V a
type V (a -> b) Source # |
Instance details Defined in Diagrams.Core.V type V (a -> b) = V b
type V (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query type V (Query v n m) = v
type V (Prim b v n) Source # |
Instance details Defined in Diagrams.Core.Types type V (Prim b v n) = v
type V (a, b, c) Source # |
Instance details Defined in Diagrams.Core.V type V (a, b, c) = V a
type V (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type V (QDiagram b v n m) = v
type V (SubMap b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type V (SubMap b v n m) = v
type V (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type V (Subdiagram b v n m) = v

type family N a Source #

The numerical field for the object, the number type used for calculations.

#### Instances

Instances details

type N (Set a) Source # |
Instance details Defined in Diagrams.Core.V type N (Set a) = N a
type N (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform type N (TransInv t) = N t
type N (Deletable m) Source # |
Instance details Defined in Diagrams.Core.V type N (Deletable m) = N m
type N (Split m) Source # |
Instance details Defined in Diagrams.Core.V type N (Split m) = N m
type N (Maybe a) Source # |
Instance details Defined in Diagrams.Core.V type N (Maybe a) = N a
type N [a] Source # |
Instance details Defined in Diagrams.Core.V type N [a] = N a
type N (Map k a) Source # |
Instance details Defined in Diagrams.Core.V type N (Map k a) = N a
type N (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Envelope type N (Envelope v n) = n
type N (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Measure type N (Measured n a) = N a
type N (Attribute v n) Source # |
Instance details Defined in Diagrams.Core.Style type N (Attribute v n) = n
type N (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style type N (Style v n) = n
type N (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace type N (Trace v n) = n
type N (Transformation v n) Source # |
Instance details Defined in Diagrams.Core.Transform type N (Transformation v n) = n
type N (Point v n) Source # |
Instance details Defined in Diagrams.Core.Points type N (Point v n) = n
type N (m :+: n) Source # |
Instance details Defined in Diagrams.Core.V type N (m :+: n) = N m
type N (a, b) Source # |
Instance details Defined in Diagrams.Core.V type N (a, b) = N a
type N (a -> b) Source # |
Instance details Defined in Diagrams.Core.V type N (a -> b) = N b
type N (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query type N (Query v n m) = n
type N (Prim b v n) Source # |
Instance details Defined in Diagrams.Core.Types type N (Prim b v n) = n
type N (a, b, c) Source # |
Instance details Defined in Diagrams.Core.V type N (a, b, c) = N a
type N (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type N (QDiagram b v n m) = n
type N (SubMap b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type N (SubMap b v n m) = n
type N (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type N (Subdiagram b v n m) = n

type Vn a = V a (N a) Source #

Convenient type alias to retrieve the vector type associated with an object's vector space. This is usually used as `Vn a ~ v n` where `v` is the vector space and `n` is the numerical field.

type InSpace (v :: Type -> Type) n a = (V a ~ v, N a ~ n, Additive v, Num n) Source #

`InSpace v n a` means the type `a` belongs to the vector space `v n`, where `v` is `Additive` and `n` is a `Num`.

type SameSpace a b = (V a ~ V b, N a ~ N b) Source #

`SameSpace a b` means the types `a` and `b` belong to the same vector space `v n`.

# Points

data Point (f :: Type -> Type) a Source #

A handy wrapper to help distinguish points from vectors at the type level

#### Instances

Instances details

Generic1 (Point f :: Type -> Type) |

Instance details

Defined in Linear.Affine

Associated Types

type Rep1 (Point f :: Type -> Type) |
Instance details Defined in Linear.Affine type Rep1 (Point f :: Type -> Type) = D1 ('MetaData "Point" "Linear.Affine" "linear-1.23.2-5AqyVb8sK1m3MfzHCRCQd3" 'True) (C1 ('MetaCons "P" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))

Methods

from1 :: Point f a -> Rep1 (Point f) a Source #

to1 :: Rep1 (Point f) a -> Point f a Source #

Unbox (f a) => Vector Vector (Point f a) |

Instance details

Defined in Linear.Affine

Methods

basicUnsafeFreeze :: Mutable Vector s (Point f a) -> ST s (Vector (Point f a))

basicUnsafeThaw :: Vector (Point f a) -> ST s (Mutable Vector s (Point f a))

basicLength :: Vector (Point f a) -> Int

basicUnsafeSlice :: Int -> Int -> Vector (Point f a) -> Vector (Point f a)

basicUnsafeIndexM :: Vector (Point f a) -> Int -> Box (Point f a)

basicUnsafeCopy :: Mutable Vector s (Point f a) -> Vector (Point f a) -> ST s ()

elemseq :: Vector (Point f a) -> Point f a -> b -> b

Unbox (f a) => MVector MVector (Point f a) |

Instance details

Defined in Linear.Affine

Methods

basicLength :: MVector s (Point f a) -> Int

basicUnsafeSlice :: Int -> Int -> MVector s (Point f a) -> MVector s (Point f a)

basicOverlaps :: MVector s (Point f a) -> MVector s (Point f a) -> Bool

basicUnsafeNew :: Int -> ST s (MVector s (Point f a))

basicInitialize :: MVector s (Point f a) -> ST s ()

basicUnsafeReplicate :: Int -> Point f a -> ST s (MVector s (Point f a))

basicUnsafeRead :: MVector s (Point f a) -> Int -> ST s (Point f a)

basicUnsafeWrite :: MVector s (Point f a) -> Int -> Point f a -> ST s ()

basicClear :: MVector s (Point f a) -> ST s ()

basicSet :: MVector s (Point f a) -> Point f a -> ST s ()

basicUnsafeCopy :: MVector s (Point f a) -> MVector s (Point f a) -> ST s ()

basicUnsafeMove :: MVector s (Point f a) -> MVector s (Point f a) -> ST s ()

basicUnsafeGrow :: MVector s (Point f a) -> Int -> ST s (MVector s (Point f a))

Representable f => Representable (Point f) |

Instance details

Defined in Linear.Affine

Associated Types

type Rep (Point f) |
Instance details Defined in Linear.Affine type Rep (Point f) = Rep f

Methods

tabulate :: (Rep (Point f) -> a) -> Point f a Source #

index :: Point f a -> Rep (Point f) -> a Source #

Eq1 f => Eq1 (Point f) |
Instance details Defined in Linear.Affine Methods liftEq :: (a -> b -> Bool) -> Point f a -> Point f b -> Bool Source #
Ord1 f => Ord1 (Point f) |
Instance details Defined in Linear.Affine Methods liftCompare :: (a -> b -> Ordering) -> Point f a -> Point f b -> Ordering Source #
Read1 f => Read1 (Point f) |
Instance details Defined in Linear.Affine Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Point f a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Point f a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Point f a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Point f a] Source #
Show1 f => Show1 (Point f) |
Instance details Defined in Linear.Affine Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Point f a -> ShowS Source # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Point f a] -> ShowS Source #
Serial1 f => Serial1 (Point f) |
Instance details Defined in Linear.Affine Methods serializeWith :: MonadPut m => (a -> m ()) -> Point f a -> m () deserializeWith :: MonadGet m => m a -> m (Point f a)
Distributive f => Distributive (Point f) |
Instance details Defined in Linear.Affine Methods distribute :: Functor f0 => f0 (Point f a) -> Point f (f0 a) Source # collect :: Functor f0 => (a -> Point f b) -> f0 a -> Point f (f0 b) Source # distributeM :: Monad m => m (Point f a) -> Point f (m a) Source # collectM :: Monad m => (a -> Point f b) -> m a -> Point f (m b) Source #
Applicative f => Applicative (Point f) |
Instance details Defined in Linear.Affine Methods pure :: a -> Point f a Source # (<*>) :: Point f (a -> b) -> Point f a -> Point f b Source # liftA2 :: (a -> b -> c) -> Point f a -> Point f b -> Point f c Source # (*>) :: Point f a -> Point f b -> Point f b Source # (<*) :: Point f a -> Point f b -> Point f a Source #
Functor f => Functor (Point f) |
Instance details Defined in Linear.Affine Methods fmap :: (a -> b) -> Point f a -> Point f b Source # (<$) :: a -> Point f b -> Point f a Source #
Monad f => Monad (Point f) |
Instance details Defined in Linear.Affine Methods (>>=) :: Point f a -> (a -> Point f b) -> Point f b Source # (>>) :: Point f a -> Point f b -> Point f b Source # return :: a -> Point f a Source #
Foldable f => Foldable (Point f) |

Instance details

Defined in Linear.Affine

Methods

fold :: Monoid m => Point f m -> m Source #

foldMap :: Monoid m => (a -> m) -> Point f a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Point f a -> m Source #

foldr :: (a -> b -> b) -> b -> Point f a -> b Source #

foldr' :: (a -> b -> b) -> b -> Point f a -> b Source #

foldl :: (b -> a -> b) -> b -> Point f a -> b Source #

foldl' :: (b -> a -> b) -> b -> Point f a -> b Source #

foldr1 :: (a -> a -> a) -> Point f a -> a Source #

foldl1 :: (a -> a -> a) -> Point f a -> a Source #

toList :: Point f a -> [a] Source #

null :: Point f a -> Bool Source #

length :: Point f a -> Int Source #

elem :: Eq a => a -> Point f a -> Bool Source #

maximum :: Ord a => Point f a -> a Source #

minimum :: Ord a => Point f a -> a Source #

sum :: Num a => Point f a -> a Source #

product :: Num a => Point f a -> a Source #

Traversable f => Traversable (Point f) |
Instance details Defined in Linear.Affine Methods traverse :: Applicative f0 => (a -> f0 b) -> Point f a -> f0 (Point f b) Source # sequenceA :: Applicative f0 => Point f (f0 a) -> f0 (Point f a) Source # mapM :: Monad m => (a -> m b) -> Point f a -> m (Point f b) Source # sequence :: Monad m => Point f (m a) -> m (Point f a) Source #
Hashable1 f => Hashable1 (Point f) |
Instance details Defined in Linear.Affine Methods liftHashWithSalt :: (Int -> a -> Int) -> Int -> Point f a -> Int
Additive f => Affine (Point f) |

Instance details

Defined in Linear.Affine

Associated Types

type Diff (Point f) |
Instance details Defined in Linear.Affine type Diff (Point f) = f

Methods

(.-.) :: Num a => Point f a -> Point f a -> Diff (Point f) a Source #

(.+^) :: Num a => Point f a -> Diff (Point f) a -> Point f a Source #

(.-^) :: Num a => Point f a -> Diff (Point f) a -> Point f a Source #

Metric f => Metric (Point f) |
Instance details Defined in Linear.Affine Methods dot :: Num a => Point f a -> Point f a -> a Source # quadrance :: Num a => Point f a -> a Source # qd :: Num a => Point f a -> Point f a -> a Source # distance :: Floating a => Point f a -> Point f a -> a Source # norm :: Floating a => Point f a -> a Source # signorm :: Floating a => Point f a -> Point f a Source #
Finite f => Finite (Point f) |

Instance details

Defined in Linear.Affine

Associated Types

type Size (Point f) |
Instance details Defined in Linear.Affine type Size (Point f) = Size f

Methods

toV :: Point f a -> V (Size (Point f)) a Source #

fromV :: V (Size (Point f)) a -> Point f a Source #

R1 f => R1 (Point f) |
Instance details Defined in Linear.Affine Methods _x :: Lens' (Point f a) a Source #
R2 f => R2 (Point f) |
Instance details Defined in Linear.Affine Methods _y :: Lens' (Point f a) a Source # _xy :: Lens' (Point f a) (V2 a) Source #
R3 f => R3 (Point f) |
Instance details Defined in Linear.Affine Methods _z :: Lens' (Point f a) a Source # _xyz :: Lens' (Point f a) (V3 a) Source #
R4 f => R4 (Point f) |
Instance details Defined in Linear.Affine Methods _w :: Lens' (Point f a) a Source # _xyzw :: Lens' (Point f a) (V4 a) Source #
Additive f => Additive (Point f) |

Instance details

Defined in Linear.Affine

Methods

zero :: Num a => Point f a Source #

(^+^) :: Num a => Point f a -> Point f a -> Point f a Source #

(^-^) :: Num a => Point f a -> Point f a -> Point f a Source #

lerp :: Num a => a -> Point f a -> Point f a -> Point f a Source #

liftU2 :: (a -> a -> a) -> Point f a -> Point f a -> Point f a Source #

liftI2 :: (a -> b -> c) -> Point f a -> Point f b -> Point f c Source #

Apply f => Apply (Point f) |
Instance details Defined in Linear.Affine Methods (<.>) :: Point f (a -> b) -> Point f a -> Point f b (.>) :: Point f a -> Point f b -> Point f b (<.) :: Point f a -> Point f b -> Point f a liftF2 :: (a -> b -> c) -> Point f a -> Point f b -> Point f c
Bind f => Bind (Point f) |
Instance details Defined in Linear.Affine Methods (>>-) :: Point f a -> (a -> Point f b) -> Point f b join :: Point f (Point f a) -> Point f a
Functor v => Cosieve (Query v) (Point v) Source # |
Instance details Defined in Diagrams.Core.Query Methods cosieve :: Query v a b -> Point v a -> b Source #
Binary (f a) => Binary (Point f a) |
Instance details Defined in Linear.Affine Methods put :: Point f a -> Put Source # get :: Get (Point f a) Source # putList :: [Point f a] -> Put Source #
Serial (f a) => Serial (Point f a) |
Instance details Defined in Linear.Affine Methods serialize :: MonadPut m => Point f a -> m () deserialize :: MonadGet m => m (Point f a)
Serialize (f a) => Serialize (Point f a) |
Instance details Defined in Linear.Affine Methods put :: Putter (Point f a) get :: Get (Point f a)
NFData (f a) => NFData (Point f a) |
Instance details Defined in Linear.Affine Methods rnf :: Point f a -> () Source #
(OrderedField n, Metric v) => Enveloped (Point v n) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods getEnvelope :: Point v n -> Envelope (V (Point v n)) (N (Point v n)) Source #
(Additive v, Num n) => HasOrigin (Point v n) Source # |
Instance details Defined in Diagrams.Core.HasOrigin Methods moveOriginTo :: Point (V (Point v n)) (N (Point v n)) -> Point v n -> Point v n Source #

(Additive v, Ord n) => Traced (Point v n) Source #

The trace of a single point is the empty trace, i.e. the one which returns no intersection points for every query. Arguably it should return a single finite distance for vectors aimed directly at the given point, but due to floating-point inaccuracy this is problematic. Note that the envelope for a single point is not the empty envelope (see Diagrams.Core.Envelope).

Instance details Defined in Diagrams.Core.Trace Methods getTrace :: Point v n -> Trace (V (Point v n)) (N (Point v n)) Source #
(Additive v, Num n) => Transformable (Point v n) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (Point v n)) (N (Point v n)) -> Point v n -> Point v n Source #
Monoid (f a) => Monoid (Point f a) |
Instance details Defined in Linear.Affine Methods mempty :: Point f a Source # mappend :: Point f a -> Point f a -> Point f a Source # mconcat :: [Point f a] -> Point f a Source #
Semigroup (f a) => Semigroup (Point f a) |
Instance details Defined in Linear.Affine Methods (<>) :: Point f a -> Point f a -> Point f a Source # sconcat :: NonEmpty (Point f a) -> Point f a Source # stimes :: Integral b => b -> Point f a -> Point f a Source #
(Typeable f, Typeable a, Data (f a)) => Data (Point f a) |

Instance details

Defined in Linear.Affine

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Point f a -> c (Point f a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Point f a) Source #

toConstr :: Point f a -> Constr Source #

dataTypeOf :: Point f a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Point f a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Point f a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Point f a -> Point f a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Point f a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Point f a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Point f a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Point f a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Point f a -> m (Point f a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Point f a -> m (Point f a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Point f a -> m (Point f a) Source #

Storable (f a) => Storable (Point f a) |

Instance details

Defined in Linear.Affine

Methods

sizeOf :: Point f a -> Int Source #

alignment :: Point f a -> Int Source #

peekElemOff :: Ptr (Point f a) -> Int -> IO (Point f a) Source #

pokeElemOff :: Ptr (Point f a) -> Int -> Point f a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (Point f a) Source #

pokeByteOff :: Ptr b -> Int -> Point f a -> IO () Source #

peek :: Ptr (Point f a) -> IO (Point f a) Source #

poke :: Ptr (Point f a) -> Point f a -> IO () Source #

Generic (Point f a) |

Instance details

Defined in Linear.Affine

Associated Types

type Rep (Point f a) |
Instance details Defined in Linear.Affine type Rep (Point f a) = D1 ('MetaData "Point" "Linear.Affine" "linear-1.23.2-5AqyVb8sK1m3MfzHCRCQd3" 'True) (C1 ('MetaCons "P" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))

Methods

from :: Point f a -> Rep (Point f a) x Source #

to :: Rep (Point f a) x -> Point f a Source #

Ix (f a) => Ix (Point f a) |

Instance details

Defined in Linear.Affine

Methods

range :: (Point f a, Point f a) -> [Point f a] Source #

index :: (Point f a, Point f a) -> Point f a -> Int Source #

unsafeIndex :: (Point f a, Point f a) -> Point f a -> Int Source #

inRange :: (Point f a, Point f a) -> Point f a -> Bool Source #

rangeSize :: (Point f a, Point f a) -> Int Source #

unsafeRangeSize :: (Point f a, Point f a) -> Int Source #

Num (f a) => Num (Point f a) |
Instance details Defined in Linear.Affine Methods (+) :: Point f a -> Point f a -> Point f a Source # (-) :: Point f a -> Point f a -> Point f a Source # (*) :: Point f a -> Point f a -> Point f a Source # negate :: Point f a -> Point f a Source # abs :: Point f a -> Point f a Source # signum :: Point f a -> Point f a Source # fromInteger :: Integer -> Point f a Source #
Read (f a) => Read (Point f a) |
Instance details Defined in Linear.Affine Methods readsPrec :: Int -> ReadS (Point f a) Source # readList :: ReadS [Point f a] Source # readPrec :: ReadPrec (Point f a) Source # readListPrec :: ReadPrec [Point f a] Source #
Fractional (f a) => Fractional (Point f a) |
Instance details Defined in Linear.Affine Methods (/) :: Point f a -> Point f a -> Point f a Source # recip :: Point f a -> Point f a Source # fromRational :: Rational -> Point f a Source #
Show (f a) => Show (Point f a) |
Instance details Defined in Linear.Affine Methods showsPrec :: Int -> Point f a -> ShowS Source # show :: Point f a -> String Source # showList :: [Point f a] -> ShowS Source #
Eq (f a) => Eq (Point f a) |
Instance details Defined in Linear.Affine Methods (==) :: Point f a -> Point f a -> Bool Source # (/=) :: Point f a -> Point f a -> Bool Source #
Ord (f a) => Ord (Point f a) |
Instance details Defined in Linear.Affine Methods compare :: Point f a -> Point f a -> Ordering Source # (<) :: Point f a -> Point f a -> Bool Source # (<=) :: Point f a -> Point f a -> Bool Source # (>) :: Point f a -> Point f a -> Bool Source # (>=) :: Point f a -> Point f a -> Bool Source # max :: Point f a -> Point f a -> Point f a Source # min :: Point f a -> Point f a -> Point f a Source #
Hashable (f a) => Hashable (Point f a) |
Instance details Defined in Linear.Affine Methods hashWithSalt :: Int -> Point f a -> Int hash :: Point f a -> Int
Ixed (f a) => Ixed (Point f a) |
Instance details Defined in Linear.Affine Methods ix :: Index (Point f a) -> Traversal' (Point f a) (IxValue (Point f a)) Source #
Wrapped (Point f a) |

Instance details

Defined in Linear.Affine

Associated Types

type Unwrapped (Point f a) |
Instance details Defined in Linear.Affine type Unwrapped (Point f a) = f a

Methods

_Wrapped' :: Iso' (Point f a) (Unwrapped (Point f a)) Source #

Epsilon (f a) => Epsilon (Point f a) |
Instance details Defined in Linear.Affine Methods nearZero :: Point f a -> Bool Source #
Random (f a) => Random (Point f a) |
Instance details Defined in Linear.Affine Methods randomR :: RandomGen g => (Point f a, Point f a) -> g -> (Point f a, g) random :: RandomGen g => g -> (Point f a, g) randomRs :: RandomGen g => (Point f a, Point f a) -> g -> [Point f a] randoms :: RandomGen g => g -> [Point f a]
Unbox (f a) => Unbox (Point f a) |
Instance details Defined in Linear.Affine
t ~ Point g b => Rewrapped (Point f a) t |
Instance details Defined in Linear.Affine
Traversable f => Each (Point f a) (Point f b) a b |
Instance details Defined in Linear.Affine Methods each :: Traversal (Point f a) (Point f b) a b Source #
type Rep1 (Point f :: Type -> Type) |
Instance details Defined in Linear.Affine type Rep1 (Point f :: Type -> Type) = D1 ('MetaData "Point" "Linear.Affine" "linear-1.23.2-5AqyVb8sK1m3MfzHCRCQd3" 'True) (C1 ('MetaCons "P" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))
newtype MVector s (Point f a) |
Instance details Defined in Linear.Affine newtype MVector s (Point f a) = MV_P (MVector s (f a))
type Rep (Point f) |
Instance details Defined in Linear.Affine type Rep (Point f) = Rep f
type Diff (Point f) |
Instance details Defined in Linear.Affine type Diff (Point f) = f
type Size (Point f) |
Instance details Defined in Linear.Affine type Size (Point f) = Size f
type N (Point v n) Source # |
Instance details Defined in Diagrams.Core.Points type N (Point v n) = n
type V (Point v n) Source # |
Instance details Defined in Diagrams.Core.Points type V (Point v n) = v
type Rep (Point f a) |
Instance details Defined in Linear.Affine type Rep (Point f a) = D1 ('MetaData "Point" "Linear.Affine" "linear-1.23.2-5AqyVb8sK1m3MfzHCRCQd3" 'True) (C1 ('MetaCons "P" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))
type Index (Point f a) |
Instance details Defined in Linear.Affine type Index (Point f a) = Index (f a)
type IxValue (Point f a) |
Instance details Defined in Linear.Affine type IxValue (Point f a) = IxValue (f a)
type Unwrapped (Point f a) |
Instance details Defined in Linear.Affine type Unwrapped (Point f a) = f a
newtype Vector (Point f a) |
Instance details Defined in Linear.Affine newtype Vector (Point f a) = V_P (Vector (f a))

origin :: forall (f :: Type -> Type) a. (Additive f, Num a) => Point f a Source #

Vector spaces have origins.

(*.) :: forall (v :: Type -> Type) n. (Functor v, Num n) => n -> Point v n -> Point v n Source #

Scale a point by a scalar. Specialized version of `(*^)`.

relative :: forall (f :: Type -> Type) a. (Additive f, Num a) => Point f a -> Iso' (Point f a) (f a) Source #

An isomorphism between points and vectors, given a reference point.

# Transformations

## Utilities

basis :: (Additive t, Traversable t, Num a) => [t a] Source #

Produce a default basis for a vector space. If the dimensionality of the vector space is not statically known, see `basisFor`.

dimension :: (Additive (V a), Traversable (V a)) => a -> Int Source #

Get the dimension of an object whose vector space is an instance of `HasLinearMap`, e.g. transformations, paths, diagrams, etc.

determinant :: forall (v :: Type -> Type) n. (Additive v, Traversable v, Num n) => Transformation v n -> n Source #

The determinant of (the linear part of) a `Transformation`.

isReflection :: forall (v :: Type -> Type) n. (Additive v, Traversable v, Num n, Ord n) => Transformation v n -> Bool Source #

Determine whether a `Transformation` includes a reflection component, that is, whether it reverses orientation.

## Invertible linear transformations

data u :-: v infixr 7 Source #

`(v1 :-: v2)` is a linear map paired with its inverse.

#### Instances

Instances details

Monoid (v :-: v) Source # | Invertible linear maps from a vector space to itself form a monoid under composition.
Instance details Defined in Diagrams.Core.Transform Methods mempty :: v :-: v Source # mappend :: (v :-: v) -> (v :-: v) -> v :-: v Source # mconcat :: [v :-: v] -> v :-: v Source #
Semigroup (a :-: a) Source # |
Instance details Defined in Diagrams.Core.Transform Methods (<>) :: (a :-: a) -> (a :-: a) -> a :-: a Source # sconcat :: NonEmpty (a :-: a) -> a :-: a Source # stimes :: Integral b => b -> (a :-: a) -> a :-: a Source #

(<->) :: (u -> v) -> (v -> u) -> u :-: v Source #

Create an invertible linear map from two functions which are assumed to be linear inverses.

linv :: (u :-: v) -> v :-: u Source #

Invert a linear map.

lapp :: (u :-: v) -> u -> v Source #

Apply a linear map to a vector.

## General transformations

data Transformation (v :: Type -> Type) n Source #

General (affine) transformations, represented by an invertible linear map, its transpose, and a vector representing a translation component.

By the transpose of a linear map we mean simply the linear map corresponding to the transpose of the map's matrix representation. For example, any scale is its own transpose, since scales are represented by matrices with zeros everywhere except the diagonal. The transpose of a rotation is the same as its inverse.

The reason we need to keep track of transposes is because it turns out that when transforming a shape according to some linear map L, the shape's normal vectors transform according to L's inverse transpose. (For a more detailed explanation and proof, see https://wiki.haskell.org/Diagrams/Dev/Transformations.) This is exactly what we need when transforming bounding functions, which are defined in terms of perpendicular (i.e. normal) hyperplanes.

For more general, non-invertible transformations, see `Diagrams.Deform` (in `diagrams-lib`).

#### Instances

Instances details

(Additive v, Num n) => HasOrigin (Transformation v n) Source # |
Instance details Defined in Diagrams.Core.Transform Methods moveOriginTo :: Point (V (Transformation v n)) (N (Transformation v n)) -> Transformation v n -> Transformation v n Source #
(Additive v, Num n) => Transformable (Transformation v n) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (Transformation v n)) (N (Transformation v n)) -> Transformation v n -> Transformation v n Source #
(Additive v, Num n) => Monoid (Transformation v n) Source # |
Instance details Defined in Diagrams.Core.Transform Methods mempty :: Transformation v n Source # mappend :: Transformation v n -> Transformation v n -> Transformation v n Source # mconcat :: [Transformation v n] -> Transformation v n Source #
(Additive v, Num n) => Semigroup (Transformation v n) Source # | Transformations are closed under composition; `t1 <> t2` is the transformation which performs first `t2`, then `t1`.
Instance details Defined in Diagrams.Core.Transform Methods (<>) :: Transformation v n -> Transformation v n -> Transformation v n Source # sconcat :: NonEmpty (Transformation v n) -> Transformation v n Source # stimes :: Integral b => b -> Transformation v n -> Transformation v n Source #
(Transformable a, V a ~ v, N a ~ n) => Action (Transformation v n) a Source # | Transformations can act on transformable things.
Instance details Defined in Diagrams.Core.Transform Methods act :: Transformation v n -> a -> a Source #
type N (Transformation v n) Source # |
Instance details Defined in Diagrams.Core.Transform type N (Transformation v n) = n
type V (Transformation v n) Source # |
Instance details Defined in Diagrams.Core.Transform type V (Transformation v n) = v

inv :: forall (v :: Type -> Type) n. (Functor v, Num n) => Transformation v n -> Transformation v n Source #

Invert a transformation.

transp :: Transformation v n -> v n :-: v n Source #

Get the transpose of a transformation (ignoring the translation component).

transl :: Transformation v n -> v n Source #

Get the translational component of a transformation.

dropTransl :: forall (v :: Type -> Type) n. (Additive v, Num n) => Transformation v n -> Transformation v n Source #

Drop the translational component of a transformation, leaving only the linear part.

apply :: Transformation v n -> v n -> v n Source #

Apply a transformation to a vector. Note that any translational component of the transformation will not affect the vector, since vectors are invariant under translation.

papply :: forall (v :: Type -> Type) n. (Additive v, Num n) => Transformation v n -> Point v n -> Point v n Source #

Apply a transformation to a point.

fromLinear :: (Additive v, Num n) => (v n :-: v n) -> (v n :-: v n) -> Transformation v n Source #

Create a general affine transformation from an invertible linear transformation and its transpose. The translational component is assumed to be zero.

## Some specific transformations

translation :: v n -> Transformation v n Source #

Create a translation.

translate :: Transformable t => Vn t -> t -> t Source #

Translate by a vector.

moveTo :: forall (v :: Type -> Type) n t. (InSpace v n t, HasOrigin t) => Point v n -> t -> t Source #

Translate the object by the translation that sends the origin to the given point. Note that this is dual to `moveOriginTo`, i.e. we should have

      moveTo (origin .^+ v) === moveOriginTo (origin .^- v)

For types which are also `Transformable`, this is essentially the same as `translate`, i.e.

      moveTo (origin .^+ v) === translate v

place :: forall (v :: Type -> Type) n t. (InSpace v n t, HasOrigin t) => t -> Point v n -> t Source #

A flipped variant of `moveTo`, provided for convenience. Useful when writing a function which takes a point as an argument, such as when using `withName` and friends.

scaling :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => n -> Transformation v n Source #

Create a uniform scaling transformation.

scale :: forall (v :: Type -> Type) n a. (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a Source #

Scale uniformly in every dimension by the given scalar.

avgScale :: forall (v :: Type -> Type) n. (Additive v, Traversable v, Floating n) => Transformation v n -> n Source #

Compute the "average" amount of scaling performed by a transformation. Satisfies the properties

      avgScale (scaling k) == k
      avgScale (t1 <> t2)  == avgScale t1 * avgScale t2

## The Transformable class

class Transformable t where Source #

Type class for things `t` which can be transformed.

Methods

transform :: Transformation (V t) (N t) -> t -> t Source #

Apply a transformation to an object.

#### Instances

Instances details

(Transformable t, Ord t) => Transformable (Set t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (Set t)) (N (Set t)) -> Set t -> Set t Source #
(Num (N t), Additive (V t), Transformable t) => Transformable (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (TransInv t)) (N (TransInv t)) -> TransInv t -> TransInv t Source #
Transformable m => Transformable (Deletable m) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (Deletable m)) (N (Deletable m)) -> Deletable m -> Deletable m Source #
Transformable t => Transformable [t] Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V [t]) (N [t]) -> [t] -> [t] Source #
Transformable t => Transformable (Map k t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (Map k t)) (N (Map k t)) -> Map k t -> Map k t Source #
(Metric v, Floating n) => Transformable (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods transform :: Transformation (V (Envelope v n)) (N (Envelope v n)) -> Envelope v n -> Envelope v n Source #
(InSpace v n t, Transformable t, HasLinearMap v, Floating n) => Transformable (Measured n t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (Measured n t)) (N (Measured n t)) -> Measured n t -> Measured n t Source #
(Additive v, Traversable v, Floating n) => Transformable (Attribute v n) Source # | `TAttribute`s are transformed directly, `MAttribute`s have their local scale multiplied by the average scale of the transform. Plain `Attribute`s are unaffected.
Instance details Defined in Diagrams.Core.Style Methods transform :: Transformation (V (Attribute v n)) (N (Attribute v n)) -> Attribute v n -> Attribute v n Source #
(Additive v, Traversable v, Floating n) => Transformable (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style Methods transform :: Transformation (V (Style v n)) (N (Style v n)) -> Style v n -> Style v n Source #
(Additive v, Num n) => Transformable (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace Methods transform :: Transformation (V (Trace v n)) (N (Trace v n)) -> Trace v n -> Trace v n Source #
(Additive v, Num n) => Transformable (Transformation v n) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (Transformation v n)) (N (Transformation v n)) -> Transformation v n -> Transformation v n Source #
(Additive v, Num n) => Transformable (Point v n) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (Point v n)) (N (Point v n)) -> Point v n -> Point v n Source #
(Transformable t, Transformable s, V t ~ V s, N t ~ N s) => Transformable (t, s) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (t, s)) (N (t, s)) -> (t, s) -> (t, s) Source #
(V t ~ v, N t ~ n, V t ~ V s, N t ~ N s, Functor v, Num n, Transformable t, Transformable s) => Transformable (s -> t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (s -> t)) (N (s -> t)) -> (s -> t) -> s -> t Source #
(Additive v, Num n) => Transformable (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query Methods transform :: Transformation (V (Query v n m)) (N (Query v n m)) -> Query v n m -> Query v n m Source #
Transformable (Prim b v n) Source # | The `Transformable` instance for `Prim` just pushes calls to `transform` down through the `Prim` constructor.
Instance details Defined in Diagrams.Core.Types Methods transform :: Transformation (V (Prim b v n)) (N (Prim b v n)) -> Prim b v n -> Prim b v n Source #
(Transformable t, Transformable s, Transformable u, V s ~ V t, N s ~ N t, V s ~ V u, N s ~ N u) => Transformable (t, s, u) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (t, s, u)) (N (t, s, u)) -> (t, s, u) -> (t, s, u) Source #
(OrderedField n, Metric v, Semigroup m) => Transformable (QDiagram b v n m) Source # | Diagrams can be transformed by transforming each of their components appropriately.
Instance details Defined in Diagrams.Core.Types Methods transform :: Transformation (V (QDiagram b v n m)) (N (QDiagram b v n m)) -> QDiagram b v n m -> QDiagram b v n m Source #
Transformable (SubMap b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods transform :: Transformation (V (SubMap b v n m)) (N (SubMap b v n m)) -> SubMap b v n m -> SubMap b v n m Source #
Transformable (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods transform :: Transformation (V (Subdiagram b v n m)) (N (Subdiagram b v n m)) -> Subdiagram b v n m -> Subdiagram b v n m Source #

## Translational invariance

newtype TransInv t Source #

`TransInv` is a wrapper which makes a transformable type translationally invariant; the translational component of transformations will no longer affect things wrapped in `TransInv`.

Constructors

TransInv t |

#### Instances

Instances details

Enveloped t => Enveloped (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods getEnvelope :: TransInv t -> Envelope (V (TransInv t)) (N (TransInv t)) Source #
HasOrigin (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods moveOriginTo :: Point (V (TransInv t)) (N (TransInv t)) -> TransInv t -> TransInv t Source #
Qualifiable a => Qualifiable (TransInv a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> TransInv a -> TransInv a Source #
Traced t => Traced (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Trace Methods getTrace :: TransInv t -> Trace (V (TransInv t)) (N (TransInv t)) Source #
(Num (N t), Additive (V t), Transformable t) => Transformable (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (TransInv t)) (N (TransInv t)) -> TransInv t -> TransInv t Source #
Monoid t => Monoid (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods mempty :: TransInv t Source # mappend :: TransInv t -> TransInv t -> TransInv t Source # mconcat :: [TransInv t] -> TransInv t Source #
Semigroup t => Semigroup (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods (<>) :: TransInv t -> TransInv t -> TransInv t Source # sconcat :: NonEmpty (TransInv t) -> TransInv t Source # stimes :: Integral b => b -> TransInv t -> TransInv t Source #
Show t => Show (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods showsPrec :: Int -> TransInv t -> ShowS Source # show :: TransInv t -> String Source # showList :: [TransInv t] -> ShowS Source #
Eq t => Eq (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods (==) :: TransInv t -> TransInv t -> Bool Source # (/=) :: TransInv t -> TransInv t -> Bool Source #
Ord t => Ord (TransInv t) Source # |

Instance details

Defined in Diagrams.Core.Transform

Methods

compare :: TransInv t -> TransInv t -> Ordering Source #

(<) :: TransInv t -> TransInv t -> Bool Source #

(<=) :: TransInv t -> TransInv t -> Bool Source #

(>) :: TransInv t -> TransInv t -> Bool Source #

(>=) :: TransInv t -> TransInv t -> Bool Source #

max :: TransInv t -> TransInv t -> TransInv t Source #

min :: TransInv t -> TransInv t -> TransInv t Source #

Wrapped (TransInv t) Source # |

Instance details

Defined in Diagrams.Core.Transform

Associated Types

type Unwrapped (TransInv t) |
Instance details Defined in Diagrams.Core.Transform type Unwrapped (TransInv t) = t

Methods

_Wrapped' :: Iso' (TransInv t) (Unwrapped (TransInv t)) Source #

Rewrapped (TransInv t) (TransInv t') Source # |
Instance details Defined in Diagrams.Core.Transform
type N (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform type N (TransInv t) = N t
type V (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform type V (TransInv t) = V t
type Unwrapped (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform type Unwrapped (TransInv t) = t

eye :: (HasBasis v, Num n) => v (v n) Source #

Identity matrix.

# Names

data AName Source #

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

#### Instances

Instances details

IsName AName Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: AName -> Name Source #
Show AName Source # |
Instance details Defined in Diagrams.Core.Names Methods showsPrec :: Int -> AName -> ShowS Source # show :: AName -> String Source # showList :: [AName] -> ShowS Source #
Eq AName Source # |
Instance details Defined in Diagrams.Core.Names Methods (==) :: AName -> AName -> Bool Source # (/=) :: AName -> AName -> Bool Source #
Ord AName Source # |
Instance details Defined in Diagrams.Core.Names Methods compare :: AName -> AName -> Ordering Source # (<) :: AName -> AName -> Bool Source # (<=) :: AName -> AName -> Bool Source # (>) :: AName -> AName -> Bool Source # (>=) :: AName -> AName -> Bool Source # max :: AName -> AName -> AName Source # min :: AName -> AName -> AName Source #
Each Name Name AName AName Source # |
Instance details Defined in Diagrams.Core.Names Methods each :: Traversal Name Name AName AName Source #

data Name Source #

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

#### Instances

Instances details

IsName Name Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Name -> Name Source #
Qualifiable Name Source # | Of course, names can be qualified using `(.>)`.
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a => a -> Name -> Name Source #
Monoid Name Source # |
Instance details Defined in Diagrams.Core.Names Methods mempty :: Name Source # mappend :: Name -> Name -> Name Source # mconcat :: [Name] -> Name Source #
Semigroup Name Source # |
Instance details Defined in Diagrams.Core.Names Methods (<>) :: Name -> Name -> Name Source # sconcat :: NonEmpty Name -> Name Source # stimes :: Integral b => b -> Name -> Name Source #
Show Name Source # |
Instance details Defined in Diagrams.Core.Names Methods showsPrec :: Int -> Name -> ShowS Source # show :: Name -> String Source # showList :: [Name] -> ShowS Source #
Eq Name Source # |
Instance details Defined in Diagrams.Core.Names Methods (==) :: Name -> Name -> Bool Source # (/=) :: Name -> Name -> Bool Source #
Ord Name Source # |
Instance details Defined in Diagrams.Core.Names Methods compare :: Name -> Name -> Ordering Source # (<) :: Name -> Name -> Bool Source # (<=) :: Name -> Name -> Bool Source # (>) :: Name -> Name -> Bool Source # (>=) :: Name -> Name -> Bool Source # max :: Name -> Name -> Name Source # min :: Name -> Name -> Name Source #
Wrapped Name Source # |

Instance details

Defined in Diagrams.Core.Names

Associated Types

type Unwrapped Name |
Instance details Defined in Diagrams.Core.Names type Unwrapped Name = [AName]

Methods

_Wrapped' :: Iso' Name (Unwrapped Name) Source #

Rewrapped Name Name Source # |
Instance details Defined in Diagrams.Core.Names
Each Name Name AName AName Source # |
Instance details Defined in Diagrams.Core.Names Methods each :: Traversal Name Name AName AName Source #
Action Name a => Action Name (Deletable a) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Deletable a -> Deletable a Source #
Action Name (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Envelope v n -> Envelope v n Source #
Action Name (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Trace v n -> Trace v n Source #
Action Name (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Query v n m -> Query v n m Source #
Action Name (SubMap b v n m) Source # | A name acts on a name map by qualifying every name in it.
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> SubMap b v n m -> SubMap b v n m Source #
type Unwrapped Name Source # |
Instance details Defined in Diagrams.Core.Names type Unwrapped Name = [AName]

class (Typeable a, Ord a, Show a) => IsName a where Source #

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`.

To make an instance of `IsName`, you need not define any methods, just declare it.

WARNING: it is not recommended to use `GeneralizedNewtypeDeriving` in conjunction with `IsName`, since in that case the underlying type and the `newtype` will be considered equivalent when comparing names. For example:

        newtype WordN = WordN Int deriving (Show, Ord, Eq, Typeable, IsName)

is unlikely to work as intended, since `(1 :: Int)` and `(WordN 1)` will be considered equal as names. Instead, use

        newtype WordN = WordN Int deriving (Show, Ord, Eq, Typeable, IsName)
        instance IsName WordN

Minimal complete definition

Nothing

Methods

toName :: a -> Name Source #

#### Instances

Instances details

IsName AName Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: AName -> Name Source #
IsName Name Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Name -> Name Source #
IsName Integer Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Integer -> Name Source #
IsName () Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: () -> Name Source #
IsName Bool Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Bool -> Name Source #
IsName Char Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Char -> Name Source #
IsName Double Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Double -> Name Source #
IsName Float Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Float -> Name Source #
IsName Int Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Int -> Name Source #
IsName a => IsName (Maybe a) Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Maybe a -> Name Source #
IsName a => IsName [a] Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: [a] -> Name Source #
(IsName a, IsName b) => IsName (a, b) Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: (a, b) -> Name Source #
(IsName a, IsName b, IsName c) => IsName (a, b, c) Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: (a, b, c) -> Name Source #

class Qualifiable q where Source #

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

Methods

(.>>) :: IsName a => a -> q -> q infixr 5 Source #

Qualify with the given name.

#### Instances

Instances details

Qualifiable Name Source # | Of course, names can be qualified using `(.>)`.
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a => a -> Name -> Name Source #
(Ord a, Qualifiable a) => Qualifiable (Set a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> Set a -> Set a Source #
Qualifiable a => Qualifiable (TransInv a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> TransInv a -> TransInv a Source #
Qualifiable a => Qualifiable [a] Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> [a] -> [a] Source #
Qualifiable a => Qualifiable (Map k a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> Map k a -> Map k a Source #
Qualifiable a => Qualifiable (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> Measured n a -> Measured n a Source #
(Qualifiable a, Qualifiable b) => Qualifiable (a, b) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> (a, b) -> (a, b) Source #
Qualifiable a => Qualifiable (b -> a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> (b -> a) -> b -> a Source #
(Qualifiable a, Qualifiable b, Qualifiable c) => Qualifiable (a, b, c) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> (a, b, c) -> (a, b, c) Source #
(Metric v, OrderedField n, Semigroup m) => Qualifiable (QDiagram b v n m) Source # | Diagrams can be qualified so that all their named points can now be referred to using the qualification prefix.
Instance details Defined in Diagrams.Core.Types Methods (.>>) :: IsName a => a -> QDiagram b v n m -> QDiagram b v n m Source #
Qualifiable (SubMap b v n m) Source # | `SubMap`s are qualifiable: if `ns` is a `SubMap`, then `a |> ns` is the same `SubMap` except with every name qualified by `a`.
Instance details Defined in Diagrams.Core.Types Methods (.>>) :: IsName a => a -> SubMap b v n m -> SubMap b v n m Source #

(.>) :: (IsName a1, IsName a2) => a1 -> a2 -> Name infixr 5 Source #

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`.

eachName :: (Typeable a, Ord a, Show a) => Traversal' Name a Source #

Traversal over each name in a `Name` that matches the target type.

    >>> toListOf eachName (a .> False .> b) :: String
    "ab"
    >>> a .> True .> b & eachName %~ not
    a .> False .> b

Note that the type of the name is very important.

    >>> sumOf eachName ((1::Int) .> (2 :: Integer) .> (3 :: Int)) :: Int
    4
    >>> sumOf eachName ((1::Int) .> (2 :: Integer) .> (3 :: Int)) :: Integer
    2

## Subdiagram maps

newtype SubMap b (v :: Type -> Type) n m Source #

A `SubMap` is a map associating names to subdiagrams. There can be multiple associations for any given name.

Constructors

SubMap (Map Name [Subdiagram b v n m]) |

#### Instances

Instances details

Action Name (SubMap b v n m) Source # | A name acts on a name map by qualifying every name in it.
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> SubMap b v n m -> SubMap b v n m Source #
Functor (SubMap b v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods fmap :: (a -> b0) -> SubMap b v n a -> SubMap b v n b0 Source # (<$) :: a -> SubMap b v n b0 -> SubMap b v n a Source #
(OrderedField n, Metric v) => HasOrigin (SubMap b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods moveOriginTo :: Point (V (SubMap b v n m)) (N (SubMap b v n m)) -> SubMap b v n m -> SubMap b v n m Source #
Qualifiable (SubMap b v n m) Source # | `SubMap`s are qualifiable: if `ns` is a `SubMap`, then `a |> ns` is the same `SubMap` except with every name qualified by `a`.
Instance details Defined in Diagrams.Core.Types Methods (.>>) :: IsName a => a -> SubMap b v n m -> SubMap b v n m Source #
Transformable (SubMap b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods transform :: Transformation (V (SubMap b v n m)) (N (SubMap b v n m)) -> SubMap b v n m -> SubMap b v n m Source #
Monoid (SubMap b v n m) Source # | `SubMap`s 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.
Instance details Defined in Diagrams.Core.Types Methods mempty :: SubMap b v n m Source # mappend :: SubMap b v n m -> SubMap b v n m -> SubMap b v n m Source # mconcat :: [SubMap b v n m] -> SubMap b v n m Source #
Semigroup (SubMap b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods (<>) :: SubMap b v n m -> SubMap b v n m -> SubMap b v n m Source # sconcat :: NonEmpty (SubMap b v n m) -> SubMap b v n m Source # stimes :: Integral b0 => b0 -> SubMap b v n m -> SubMap b v n m Source #
Wrapped (SubMap b v n m) Source # |

Instance details

Defined in Diagrams.Core.Types

Associated Types

type Unwrapped (SubMap b v n m) |
Instance details Defined in Diagrams.Core.Types type Unwrapped (SubMap b v n m) = Map Name [Subdiagram b v n m]

Methods

_Wrapped' :: Iso' (SubMap b v n m) (Unwrapped (SubMap b v n m)) Source #

Rewrapped (SubMap b v n m) (SubMap b' v' n' m') Source # |
Instance details Defined in Diagrams.Core.Types
type N (SubMap b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type N (SubMap b v n m) = n
type V (SubMap b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type V (SubMap b v n m) = v
type Unwrapped (SubMap b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type Unwrapped (SubMap b v n m) = Map Name [Subdiagram b v n m]

fromNames :: forall a b (v :: Type -> Type) n m. IsName a => [(a, Subdiagram b v n m)] -> SubMap b v n m Source #

Construct a `SubMap` from a list of associations between names and subdiagrams.

rememberAs :: forall a b (v :: Type -> Type) n m. IsName a => a -> QDiagram b v n m -> SubMap b v n m -> SubMap b v n m Source #

Add a name/diagram association to a submap.

lookupSub :: forall nm b (v :: Type -> Type) n m. IsName nm => nm -> SubMap b v n m -> Maybe [Subdiagram b v n m] Source #

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

# Attributes and styles

class (Typeable a, Semigroup a) => AttributeClass a Source #

Every attribute must be an instance of `AttributeClass`, which simply guarantees `Typeable` and `Semigroup` constraints. The `Semigroup` instance for an attribute determines how it will combine with other attributes of the same type.

data Attribute (v :: Type -> Type) n where Source #

An existential wrapper type to hold attributes. Some attributes are simply inert/static; some are affected by transformations; and some are affected by transformations and can be modified generically.

Constructors

Attribute :: forall a (v :: Type -> Type) n. AttributeClass a => a -> Attribute v n |
MAttribute :: forall a n (v :: Type -> Type). AttributeClass a => Measured n a -> Attribute v n |
TAttribute :: forall a (v :: Type -> Type) n. (AttributeClass a, Transformable a, V a ~ v, N a ~ n) => a -> Attribute v n |

#### Instances

Instances details

(Additive v, Traversable v, Floating n) => Transformable (Attribute v n) Source # | `TAttribute`s are transformed directly, `MAttribute`s have their local scale multiplied by the average scale of the transform. Plain `Attribute`s are unaffected.
Instance details Defined in Diagrams.Core.Style Methods transform :: Transformation (V (Attribute v n)) (N (Attribute v n)) -> Attribute v n -> Attribute v n Source #
Typeable n => Semigroup (Attribute v n) Source # | Attributes form a semigroup, where the semigroup operation simply returns the right-hand attribute when the types do not match, and otherwise uses the semigroup operation specific to the (matching) types.
Instance details Defined in Diagrams.Core.Style Methods (<>) :: Attribute v n -> Attribute v n -> Attribute v n Source # sconcat :: NonEmpty (Attribute v n) -> Attribute v n Source # stimes :: Integral b => b -> Attribute v n -> Attribute v n Source #
Show (Attribute v n) Source # | Shows the kind of attribute and the type contained in the attribute.
Instance details Defined in Diagrams.Core.Style Methods showsPrec :: Int -> Attribute v n -> ShowS Source # show :: Attribute v n -> String Source # showList :: [Attribute v n] -> ShowS Source #
Each (Style v n) (Style v' n') (Attribute v n) (Attribute v' n') Source # |
Instance details Defined in Diagrams.Core.Style Methods each :: Traversal (Style v n) (Style v' n') (Attribute v n) (Attribute v' n') Source #
type N (Attribute v n) Source # |
Instance details Defined in Diagrams.Core.Style type N (Attribute v n) = n
type V (Attribute v n) Source # |
Instance details Defined in Diagrams.Core.Style type V (Attribute v n) = v

data Style (v :: Type -> Type) n Source #

A `Style` is a heterogeneous collection of attributes, containing at most one attribute of any given type.

#### Instances

Instances details

Typeable n => HasStyle (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style Methods applyStyle :: Style (V (Style v n)) (N (Style v n)) -> Style v n -> Style v n Source #
(Additive v, Traversable v, Floating n) => Transformable (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style Methods transform :: Transformation (V (Style v n)) (N (Style v n)) -> Style v n -> Style v n Source #
Typeable n => Monoid (Style v n) Source # | The empty style contains no attributes.
Instance details Defined in Diagrams.Core.Style Methods mempty :: Style v n Source # mappend :: Style v n -> Style v n -> Style v n Source # mconcat :: [Style v n] -> Style v n Source #
Typeable n => Semigroup (Style v n) Source # | Combine a style by combining the attributes; if the two styles have attributes of the same type they are combined according to their semigroup structure.
Instance details Defined in Diagrams.Core.Style Methods (<>) :: Style v n -> Style v n -> Style v n Source # sconcat :: NonEmpty (Style v n) -> Style v n Source # stimes :: Integral b => b -> Style v n -> Style v n Source #
Show (Style v n) Source # | Show the attributes in the style.
Instance details Defined in Diagrams.Core.Style Methods showsPrec :: Int -> Style v n -> ShowS Source # show :: Style v n -> String Source # showList :: [Style v n] -> ShowS Source #
At (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style Methods at :: Index (Style v n) -> Lens' (Style v n) (Maybe (IxValue (Style v n))) Source #
Ixed (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style Methods ix :: Index (Style v n) -> Traversal' (Style v n) (IxValue (Style v n)) Source #
Wrapped (Style v n) Source # |

Instance details

Defined in Diagrams.Core.Style

Associated Types

type Unwrapped (Style v n) |
Instance details Defined in Diagrams.Core.Style type Unwrapped (Style v n) = HashMap TypeRep (Attribute v n)

Methods

_Wrapped' :: Iso' (Style v n) (Unwrapped (Style v n)) Source #

Action (Style v n) m Source # | Styles have no action on other monoids.
Instance details Defined in Diagrams.Core.Style Methods act :: Style v n -> m -> m Source #
Rewrapped (Style v n) (Style v' n') Source # |
Instance details Defined in Diagrams.Core.Style
Each (Style v n) (Style v' n') (Attribute v n) (Attribute v' n') Source # |
Instance details Defined in Diagrams.Core.Style Methods each :: Traversal (Style v n) (Style v' n') (Attribute v n) (Attribute v' n') Source #
type N (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style type N (Style v n) = n
type V (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style type V (Style v n) = v
type Index (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style type Index (Style v n) = TypeRep
type IxValue (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style type IxValue (Style v n) = Attribute v n
type Unwrapped (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style type Unwrapped (Style v n) = HashMap TypeRep (Attribute v n)

class HasStyle a where Source #

Type class for things which have a style.

Methods

applyStyle :: Style (V a) (N a) -> a -> a Source #

Apply a style by combining it (on the left) with the existing style.

#### Instances

Instances details

(HasStyle a, Ord a) => HasStyle (Set a) Source # |
Instance details Defined in Diagrams.Core.Style Methods applyStyle :: Style (V (Set a)) (N (Set a)) -> Set a -> Set a Source #
HasStyle a => HasStyle [a] Source # |
Instance details Defined in Diagrams.Core.Style Methods applyStyle :: Style (V [a]) (N [a]) -> [a] -> [a] Source #
HasStyle a => HasStyle (Map k a) Source # |
Instance details Defined in Diagrams.Core.Style Methods applyStyle :: Style (V (Map k a)) (N (Map k a)) -> Map k a -> Map k a Source #
HasStyle b => HasStyle (Measured n b) Source # |
Instance details Defined in Diagrams.Core.Style Methods applyStyle :: Style (V (Measured n b)) (N (Measured n b)) -> Measured n b -> Measured n b Source #
Typeable n => HasStyle (Style v n) Source # |
Instance details Defined in Diagrams.Core.Style Methods applyStyle :: Style (V (Style v n)) (N (Style v n)) -> Style v n -> Style v n Source #
(HasStyle a, HasStyle b, V a ~ V b, N a ~ N b) => HasStyle (a, b) Source # |
Instance details Defined in Diagrams.Core.Style Methods applyStyle :: Style (V (a, b)) (N (a, b)) -> (a, b) -> (a, b) Source #
HasStyle b => HasStyle (a -> b) Source # |
Instance details Defined in Diagrams.Core.Style Methods applyStyle :: Style (V (a -> b)) (N (a -> b)) -> (a -> b) -> a -> b Source #
(Metric v, OrderedField n, Semigroup m) => HasStyle (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods applyStyle :: Style (V (QDiagram b v n m)) (N (QDiagram b v n m)) -> QDiagram b v n m -> QDiagram b v n m Source #

getAttr :: forall a (v :: Type -> Type) n. AttributeClass a => Style v n -> Maybe a Source #

Extract an attribute from a style of a particular type. If the style contains an attribute of the requested type, it will be returned wrapped in `Just`; otherwise, `Nothing` is returned.

Trying to extract a measured attibute will fail. It either has to be unmeasured with `unmeasureAttrs` or use the `atMAttr` lens.

atAttr :: forall a (v :: Type -> Type) n. AttributeClass a => Lens' (Style v n) (Maybe a) Source #

Lens onto a plain attribute of a style.

atMAttr :: forall a n (v :: Type -> Type). (AttributeClass a, Typeable n) => Lens' (Style v n) (Maybe (Measured n a)) Source #

Lens onto a measured attribute of a style.

atTAttr :: forall a (v :: Type -> Type) n. (V a ~ v, N a ~ n, AttributeClass a, Transformable a) => Lens' (Style v n) (Maybe a) Source #

Lens onto a transformable attribute of a style.

applyAttr :: (AttributeClass a, HasStyle d) => a -> d -> d Source #

Apply an attribute to an instance of `HasStyle` (such as a diagram or a style). If the object already has an attribute of the same type, the new attribute is combined on the left with the existing attribute, according to their semigroup structure.

applyMAttr :: (AttributeClass a, N d ~ n, HasStyle d) => Measured n a -> d -> d Source #

Apply a measured attribute to an instance of `HasStyle` (such as a diagram or a style). If the object already has an attribute of the same type, the new attribute is combined on the left with the existing attribute, according to their semigroup structure.

applyTAttr :: (AttributeClass a, Transformable a, V a ~ V d, N a ~ N d, HasStyle d) => a -> d -> d Source #

Apply a transformable attribute to an instance of `HasStyle` (such as a diagram or a style). If the object already has an attribute of the same type, the new attribute is combined on the left with the existing attribute, according to their semigroup structure.

# Envelopes

newtype Envelope (v :: Type -> Type) n Source #

Every diagram comes equipped with an envelope. What is an envelope?

Consider first the idea of a bounding box. A bounding box expresses the distance to a bounding plane in every direction parallel to an axis. That is, a bounding box can be thought of as the intersection of a collection of half-planes, two perpendicular to each axis.

More generally, the intersection of half-planes in every direction would give a tight "bounding region", or convex hull. However, representing such a thing intensionally would be impossible; hence bounding boxes are often used as an approximation.

An envelope is an extensional representation of such a "bounding region". Instead of storing some sort of direct representation, we store a function which takes a direction as input and gives a distance to a bounding half-plane as output. The important point is that envelopes can be composed, and transformed by any affine transformation.

Formally, given a vector `v`, the envelope computes a scalar `s` such that

- for every point `u` inside the diagram, if the projection of `(u - origin)` onto `v` is `s' *^ v`, then `s' <= s`.
- `s` is the smallest such scalar.

There is also a special "empty envelope".

The idea for envelopes came from Sebastian Setzer; see http://byorgey.wordpress.com/2009/10/28/collecting-attributes/#comment-2030. See also Brent Yorgey, Monoids: Theme and Variations, published in the 2012 Haskell Symposium: http://ozark.hendrix.edu/~yorgey/pub/monoid-pearl.pdf; video: http://www.youtube.com/watch?v=X-8NCkD2vOw.

Constructors

Envelope (Maybe (v n -> Max n)) |

#### Instances

Instances details

Action Name (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Envelope v n -> Envelope v n Source #
(Metric v, OrderedField n) => Enveloped (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods getEnvelope :: Envelope v n -> Envelope (V (Envelope v n)) (N (Envelope v n)) Source #
(Metric v, Fractional n) => HasOrigin (Envelope v n) Source # | The local origin of an envelope is the point with respect to which bounding queries are made, i.e. the point from which the input vectors are taken to originate.
Instance details Defined in Diagrams.Core.Envelope Methods moveOriginTo :: Point (V (Envelope v n)) (N (Envelope v n)) -> Envelope v n -> Envelope v n Source #
(Metric v, OrderedField n) => Juxtaposable (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Juxtapose Methods juxtapose :: Vn (Envelope v n) -> Envelope v n -> Envelope v n -> Envelope v n Source #
(Metric v, Floating n) => Transformable (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods transform :: Transformation (V (Envelope v n)) (N (Envelope v n)) -> Envelope v n -> Envelope v n Source #
Ord n => Monoid (Envelope v n) Source # | The special empty envelope is the identity for the `Monoid` instance.
Instance details Defined in Diagrams.Core.Envelope Methods mempty :: Envelope v n Source # mappend :: Envelope v n -> Envelope v n -> Envelope v n Source # mconcat :: [Envelope v n] -> Envelope v n Source #
Ord n => Semigroup (Envelope v n) Source # | Envelopes form a semigroup with pointwise maximum as composition. Hence, if `e1` is the envelope for diagram `d1`, and `e2` is the envelope for `d2`, then `e1 `mappend` e2` is the envelope for `d1 `atop` d2`.
Instance details Defined in Diagrams.Core.Envelope Methods (<>) :: Envelope v n -> Envelope v n -> Envelope v n Source # sconcat :: NonEmpty (Envelope v n) -> Envelope v n Source # stimes :: Integral b => b -> Envelope v n -> Envelope v n Source #
Show (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods showsPrec :: Int -> Envelope v n -> ShowS Source # show :: Envelope v n -> String Source # showList :: [Envelope v n] -> ShowS Source #
Wrapped (Envelope v n) Source # |

Instance details

Defined in Diagrams.Core.Envelope

Associated Types

type Unwrapped (Envelope v n) |
Instance details Defined in Diagrams.Core.Envelope type Unwrapped (Envelope v n) = Maybe (v n -> Max n)

Methods

_Wrapped' :: Iso' (Envelope v n) (Unwrapped (Envelope v n)) Source #

Rewrapped (Envelope v n) (Envelope v' n') Source # |
Instance details Defined in Diagrams.Core.Envelope
type N (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Envelope type N (Envelope v n) = n
type V (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Envelope type V (Envelope v n) = v
type Unwrapped (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Envelope type Unwrapped (Envelope v n) = Maybe (v n -> Max n)

appEnvelope :: Envelope v n -> Maybe (v n -> n) Source #

"Apply" an envelope by turning it into a function. `Nothing` is returned iff the envelope is empty.

onEnvelope :: ((v n -> n) -> v n -> n) -> Envelope v n -> Envelope v n Source #

A convenient way to transform an envelope, by specifying a transformation on the underlying `v n -> n` function. The empty envelope is unaffected.

mkEnvelope :: (v n -> n) -> Envelope v n Source #

Create an envelope from a `v n -> n` function.

class (Metric (V a), OrderedField (N a)) => Enveloped a where Source #

`Enveloped` abstracts over things which have an envelope.

Methods

getEnvelope :: a -> Envelope (V a) (N a) Source #

Compute the envelope of an object. For types with an intrinsic notion of "local origin", the envelope will be based there. Other types (e.g. `Trail`) may have some other default reference point at which the envelope will be based; their instances should document what it is.

#### Instances

Instances details

Enveloped b => Enveloped (Set b) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods getEnvelope :: Set b -> Envelope (V (Set b)) (N (Set b)) Source #
Enveloped t => Enveloped (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods getEnvelope :: TransInv t -> Envelope (V (TransInv t)) (N (TransInv t)) Source #
Enveloped b => Enveloped [b] Source # |
Instance details Defined in Diagrams.Core.Envelope Methods getEnvelope :: [b] -> Envelope (V [b]) (N [b]) Source #
Enveloped b => Enveloped (Map k b) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods getEnvelope :: Map k b -> Envelope (V (Map k b)) (N (Map k b)) Source #
(Metric v, OrderedField n) => Enveloped (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods getEnvelope :: Envelope v n -> Envelope (V (Envelope v n)) (N (Envelope v n)) Source #
(OrderedField n, Metric v) => Enveloped (Point v n) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods getEnvelope :: Point v n -> Envelope (V (Point v n)) (N (Point v n)) Source #
(Enveloped a, Enveloped b, V a ~ V b, N a ~ N b) => Enveloped (a, b) Source # |
Instance details Defined in Diagrams.Core.Envelope Methods getEnvelope :: (a, b) -> Envelope (V (a, b)) (N (a, b)) Source #
(Metric v, OrderedField n, Monoid' m) => Enveloped (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods getEnvelope :: QDiagram b v n m -> Envelope (V (QDiagram b v n m)) (N (QDiagram b v n m)) Source #
(OrderedField n, Metric v, Monoid' m) => Enveloped (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods getEnvelope :: Subdiagram b v n m -> Envelope (V (Subdiagram b v n m)) (N (Subdiagram b v n m)) Source #

envelopeVMay :: Enveloped a => Vn a -> a -> Maybe (Vn a) Source #

Compute the vector from the local origin to a separating hyperplane in the given direction, or `Nothing` for the empty envelope.

envelopeV :: Enveloped a => Vn a -> a -> Vn a Source #

Compute the vector from the local origin to a separating hyperplane in the given direction. Returns the zero vector for the empty envelope.

envelopePMay :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> Maybe (Point v n) Source #

Compute the point on a separating hyperplane in the given direction, or `Nothing` for the empty envelope.

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

Compute the point on a separating hyperplane in the given direction. Returns the origin for the empty envelope.

diameter :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> n Source #

Compute the diameter of a enveloped object along a particular vector. Returns zero for the empty envelope.

radius :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> n Source #

Compute the "radius" (1/2 the diameter) of an enveloped object along a particular vector.

size :: (V a ~ v, N a ~ n, Enveloped a, HasBasis v) => a -> v n Source #

The smallest positive axis-parallel vector that bounds the envelope of an object.

# Traces

newtype Trace (v :: Type -> Type) n Source #

Every diagram comes equipped with a trace. Intuitively, the trace for a diagram is like a raytracer: given a line (represented as a base point and a direction vector), the trace computes a sorted list of signed distances from the base point to all intersections of the line with the boundary of the diagram.

Note that the outputs are not absolute distances, but multipliers relative to the input vector. That is, if the base point is `p` and direction vector is `v`, and one of the output scalars is `s`, then there is an intersection at the point `p .+^ (s *^ v)`.

Constructors

Trace (Point v n -> v n -> SortedList n) |

#### Instances

Instances details

Action Name (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Trace v n -> Trace v n Source #
(Additive v, Num n) => HasOrigin (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace Methods moveOriginTo :: Point (V (Trace v n)) (N (Trace v n)) -> Trace v n -> Trace v n Source #
(Additive v, Ord n) => Traced (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace Methods getTrace :: Trace v n -> Trace (V (Trace v n)) (N (Trace v n)) Source #
(Additive v, Num n) => Transformable (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace Methods transform :: Transformation (V (Trace v n)) (N (Trace v n)) -> Trace v n -> Trace v n Source #
Ord n => Monoid (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace Methods mempty :: Trace v n Source # mappend :: Trace v n -> Trace v n -> Trace v n Source # mconcat :: [Trace v n] -> Trace v n Source #
Ord n => Semigroup (Trace v n) Source # | Traces form a semigroup with pointwise minimum as composition. Hence, if `t1` is the trace for diagram `d1`, and `e2` is the trace for `d2`, then `e1 `mappend` e2` is the trace for `d1 `atop` d2`.
Instance details Defined in Diagrams.Core.Trace Methods (<>) :: Trace v n -> Trace v n -> Trace v n Source # sconcat :: NonEmpty (Trace v n) -> Trace v n Source # stimes :: Integral b => b -> Trace v n -> Trace v n Source #
Show (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace Methods showsPrec :: Int -> Trace v n -> ShowS Source # show :: Trace v n -> String Source # showList :: [Trace v n] -> ShowS Source #
Wrapped (Trace v n) Source # |

Instance details

Defined in Diagrams.Core.Trace

Associated Types

type Unwrapped (Trace v n) |
Instance details Defined in Diagrams.Core.Trace type Unwrapped (Trace v n) = Point v n -> v n -> SortedList n

Methods

_Wrapped' :: Iso' (Trace v n) (Unwrapped (Trace v n)) Source #

Rewrapped (Trace v n) (Trace v' n') Source # |
Instance details Defined in Diagrams.Core.Trace
type N (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace type N (Trace v n) = n
type V (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace type V (Trace v n) = v
type Unwrapped (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace type Unwrapped (Trace v n) = Point v n -> v n -> SortedList n

data SortedList a Source #

A newtype wrapper around a list which maintains the invariant that the list is sorted. The constructor is not exported; use the smart constructor `mkSortedList` (which sorts the given list) instead.

#### Instances

Instances details

Ord a => Monoid (SortedList a) Source # | `SortedList` forms a monoid with `merge` and the empty list.
Instance details Defined in Diagrams.Core.Trace Methods mempty :: SortedList a Source # mappend :: SortedList a -> SortedList a -> SortedList a Source # mconcat :: [SortedList a] -> SortedList a Source #
Ord a => Semigroup (SortedList a) Source # | `SortedList` forms a semigroup with `merge` as composition.
Instance details Defined in Diagrams.Core.Trace Methods (<>) :: SortedList a -> SortedList a -> SortedList a Source # sconcat :: NonEmpty (SortedList a) -> SortedList a Source # stimes :: Integral b => b -> SortedList a -> SortedList a Source #

mkSortedList :: Ord a => [a] -> SortedList a Source #

A smart constructor for the `SortedList` type, which sorts the input to ensure the `SortedList` invariant.

getSortedList :: SortedList a -> [a] Source #

Project the (guaranteed sorted) list out of a `SortedList` wrapper.

appTrace :: Trace v n -> Point v n -> v n -> SortedList n Source #

mkTrace :: (Point v n -> v n -> SortedList n) -> Trace v n Source #

class (Additive (V a), Ord (N a)) => Traced a where Source #

`Traced` abstracts over things which have a trace.

Methods

getTrace :: a -> Trace (V a) (N a) Source #

Compute the trace of an object.

#### Instances

Instances details

Traced b => Traced (Set b) Source # |
Instance details Defined in Diagrams.Core.Trace Methods getTrace :: Set b -> Trace (V (Set b)) (N (Set b)) Source #
Traced t => Traced (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Trace Methods getTrace :: TransInv t -> Trace (V (TransInv t)) (N (TransInv t)) Source #
Traced b => Traced [b] Source # |
Instance details Defined in Diagrams.Core.Trace Methods getTrace :: [b] -> Trace (V [b]) (N [b]) Source #
Traced b => Traced (Map k b) Source # |
Instance details Defined in Diagrams.Core.Trace Methods getTrace :: Map k b -> Trace (V (Map k b)) (N (Map k b)) Source #
(Additive v, Ord n) => Traced (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace Methods getTrace :: Trace v n -> Trace (V (Trace v n)) (N (Trace v n)) Source #

(Additive v, Ord n) => Traced (Point v n) Source #

The trace of a single point is the empty trace, i.e. the one which returns no intersection points for every query. Arguably it should return a single finite distance for vectors aimed directly at the given point, but due to floating-point inaccuracy this is problematic. Note that the envelope for a single point is not the empty envelope (see Diagrams.Core.Envelope).

Instance details Defined in Diagrams.Core.Trace Methods getTrace :: Point v n -> Trace (V (Point v n)) (N (Point v n)) Source #
(Traced a, Traced b, SameSpace a b) => Traced (a, b) Source # |
Instance details Defined in Diagrams.Core.Trace Methods getTrace :: (a, b) -> Trace (V (a, b)) (N (a, b)) Source #
(Metric v, OrderedField n, Semigroup m) => Traced (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods getTrace :: QDiagram b v n m -> Trace (V (QDiagram b v n m)) (N (QDiagram b v n m)) Source #
(OrderedField n, Metric v, Semigroup m) => Traced (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods getTrace :: Subdiagram b v n m -> Trace (V (Subdiagram b v n m)) (N (Subdiagram b v n m)) Source #

traceV :: (n ~ N a, Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (V a n) Source #

Compute the vector from the given point `p` to the "smallest" boundary intersection along the given vector `v`. The "smallest" boundary intersection is defined as the one given by `p .+^ (s *^ v)` for the smallest (most negative) value of `s`. Return `Nothing` if there is no intersection. See also `traceP`.

See also `rayTraceV` which uses the smallest positive intersection, which is often more intuitive behavior.

traceP :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n) Source #

Compute the "smallest" boundary point along the line determined by the given point `p` and vector `v`. The "smallest" boundary point is defined as the one given by `p .+^ (s *^ v)` for the smallest (most negative) value of `s`. Return `Nothing` if there is no such boundary point. See also `traceV`.

See also `rayTraceP` which uses the smallest positive intersection, which is often more intuitive behavior.

maxTraceV :: (n ~ N a, Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (V a n) Source #

Like `traceV`, but computes a vector to the "largest" boundary point instead of the smallest. (Note, however, the "largest" boundary point may still be in the opposite direction from the given vector, if all the boundary points are, as in the third example shown below.)

maxTraceP :: (n ~ N a, Num n, Traced a) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n) Source #

Like `traceP`, but computes the "largest" boundary point instead of the smallest. (Note, however, the "largest" boundary point may still be in the opposite direction from the given vector, if all the boundary points are.)

rayTraceV :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (V a n) Source #

Compute the vector from the given point to the closest boundary point of the given object in the given direction, or `Nothing` if there is no such boundary point (as in the third example below). Note that unlike `traceV`, only positive boundary points are considered, i.e. boundary points corresponding to a positive scalar multiple of the direction vector. This is intuitively the "usual" behavior of a raytracer, which only considers intersections "in front of" the camera. Compare the second example diagram below with the second example shown for `traceV`.

rayTraceP :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n) Source #

Compute the boundary point on an object which is closest to the given base point in the given direction, or `Nothing` if there is no such boundary point. Note that unlike `traceP`, only positive boundary points are considered, i.e. boundary points corresponding to a positive scalar multiple of the direction vector. This is intuitively the "usual" behavior of a raytracer, which only considers intersection points "in front of" the camera.

maxRayTraceV :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (V a n) Source #

Like `rayTraceV`, but computes a vector to the "largest" boundary point instead of the smallest. Considers only positive boundary points.

maxRayTraceP :: (n ~ N a, Traced a, Num n) => Point (V a) n -> V a n -> a -> Maybe (Point (V a) n) Source #

Like `rayTraceP`, but computes the "largest" boundary point instead of the smallest. Considers only positive boundary points.

# Things with local origins

class HasOrigin t where Source #

Class of types which have an intrinsic notion of a "local origin", i.e. things which are not invariant under translation, and which allow the origin to be moved.

One might wonder why not just use `Transformable` instead of having a separate class for `HasOrigin`; indeed, for types which are instances of both we should have the identity

      moveOriginTo (origin .^+ v) === translate (negated v)

The reason is that some things (e.g. vectors, `Trail`s) are transformable but are translationally invariant, i.e. have no origin.

Methods

moveOriginTo :: Point (V t) (N t) -> t -> t Source #

Move the local origin to another point.

Note that this function is in some sense dual to `translate` (for types which are also `Transformable`); moving the origin itself while leaving the object "fixed" is dual to fixing the origin and translating the diagram.

#### Instances

Instances details

(HasOrigin t, Ord t) => HasOrigin (Set t) Source # |
Instance details Defined in Diagrams.Core.HasOrigin Methods moveOriginTo :: Point (V (Set t)) (N (Set t)) -> Set t -> Set t Source #
HasOrigin (TransInv t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods moveOriginTo :: Point (V (TransInv t)) (N (TransInv t)) -> TransInv t -> TransInv t Source #
HasOrigin t => HasOrigin [t] Source # |
Instance details Defined in Diagrams.Core.HasOrigin Methods moveOriginTo :: Point (V [t]) (N [t]) -> [t] -> [t] Source #
HasOrigin t => HasOrigin (Map k t) Source # |
Instance details Defined in Diagrams.Core.HasOrigin Methods moveOriginTo :: Point (V (Map k t)) (N (Map k t)) -> Map k t -> Map k t Source #
(Metric v, Fractional n) => HasOrigin (Envelope v n) Source # | The local origin of an envelope is the point with respect to which bounding queries are made, i.e. the point from which the input vectors are taken to originate.
Instance details Defined in Diagrams.Core.Envelope Methods moveOriginTo :: Point (V (Envelope v n)) (N (Envelope v n)) -> Envelope v n -> Envelope v n Source #
HasOrigin t => HasOrigin (Measured n t) Source # |
Instance details Defined in Diagrams.Core.HasOrigin Methods moveOriginTo :: Point (V (Measured n t)) (N (Measured n t)) -> Measured n t -> Measured n t Source #
(Additive v, Num n) => HasOrigin (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Trace Methods moveOriginTo :: Point (V (Trace v n)) (N (Trace v n)) -> Trace v n -> Trace v n Source #
(Additive v, Num n) => HasOrigin (Transformation v n) Source # |
Instance details Defined in Diagrams.Core.Transform Methods moveOriginTo :: Point (V (Transformation v n)) (N (Transformation v n)) -> Transformation v n -> Transformation v n Source #
(Additive v, Num n) => HasOrigin (Point v n) Source # |
Instance details Defined in Diagrams.Core.HasOrigin Methods moveOriginTo :: Point (V (Point v n)) (N (Point v n)) -> Point v n -> Point v n Source #
(HasOrigin t, HasOrigin s, SameSpace s t) => HasOrigin (s, t) Source # |
Instance details Defined in Diagrams.Core.HasOrigin Methods moveOriginTo :: Point (V (s, t)) (N (s, t)) -> (s, t) -> (s, t) Source #
(Additive v, Num n) => HasOrigin (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query Methods moveOriginTo :: Point (V (Query v n m)) (N (Query v n m)) -> Query v n m -> Query v n m Source #
(Metric v, OrderedField n, Semigroup m) => HasOrigin (QDiagram b v n m) Source # | Every diagram has an intrinsic "local origin" which is the basis for all combining operations.
Instance details Defined in Diagrams.Core.Types Methods moveOriginTo :: Point (V (QDiagram b v n m)) (N (QDiagram b v n m)) -> QDiagram b v n m -> QDiagram b v n m Source #
(OrderedField n, Metric v) => HasOrigin (SubMap b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods moveOriginTo :: Point (V (SubMap b v n m)) (N (SubMap b v n m)) -> SubMap b v n m -> SubMap b v n m Source #
(Metric v, OrderedField n) => HasOrigin (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods moveOriginTo :: Point (V (Subdiagram b v n m)) (N (Subdiagram b v n m)) -> Subdiagram b v n m -> Subdiagram b v n m Source #

moveOriginBy :: (V t ~ v, N t ~ n, HasOrigin t) => v n -> t -> t Source #

Move the local origin by a relative vector.

# Juxtaposable things

class Juxtaposable a where Source #

Class of things which can be placed "next to" other things, for some appropriate notion of "next to".

Methods

juxtapose :: Vn a -> a -> a -> a Source #

`juxtapose v a1 a2` positions `a2` next to `a1` in the direction of `v`. In particular, place `a2` so that `v` points from the local origin of `a1` towards the old local origin of `a2`; `a1`'s local origin becomes `a2`'s new local origin. The result is just a translated version of `a2`. (In particular, this operation does not combine `a1` and `a2` in any way.)

#### Instances

Instances details

(Enveloped b, HasOrigin b, Ord b) => Juxtaposable (Set b) Source # |
Instance details Defined in Diagrams.Core.Juxtapose Methods juxtapose :: Vn (Set b) -> Set b -> Set b -> Set b Source #
(Enveloped b, HasOrigin b) => Juxtaposable [b] Source # |
Instance details Defined in Diagrams.Core.Juxtapose Methods juxtapose :: Vn [b] -> [b] -> [b] -> [b] Source #
(Enveloped b, HasOrigin b) => Juxtaposable (Map k b) Source # |
Instance details Defined in Diagrams.Core.Juxtapose Methods juxtapose :: Vn (Map k b) -> Map k b -> Map k b -> Map k b Source #
(Metric v, OrderedField n) => Juxtaposable (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Juxtapose Methods juxtapose :: Vn (Envelope v n) -> Envelope v n -> Envelope v n -> Envelope v n Source #
Juxtaposable a => Juxtaposable (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Juxtapose Methods juxtapose :: Vn (Measured n a) -> Measured n a -> Measured n a -> Measured n a Source #
(Enveloped a, HasOrigin a, Enveloped b, HasOrigin b, V a ~ V b, N a ~ N b) => Juxtaposable (a, b) Source # |
Instance details Defined in Diagrams.Core.Juxtapose Methods juxtapose :: Vn (a, b) -> (a, b) -> (a, b) -> (a, b) Source #
Juxtaposable a => Juxtaposable (b -> a) Source # |
Instance details Defined in Diagrams.Core.Juxtapose Methods juxtapose :: Vn (b -> a) -> (b -> a) -> (b -> a) -> b -> a Source #
(Metric v, OrderedField n, Monoid' m) => Juxtaposable (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods juxtapose :: Vn (QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m -> QDiagram b v n m Source #

juxtaposeDefault :: (Enveloped a, HasOrigin a) => Vn a -> a -> a -> a Source #

Default implementation of `juxtapose` for things which are instances of `Enveloped` and `HasOrigin`. If either envelope is empty, the second object is returned unchanged.

# Queries

newtype Query (v :: Type -> Type) n m Source #

A query is a function that maps points in a vector space to values in some monoid. Queries naturally form a monoid, with two queries being combined pointwise.

The idea for annotating diagrams with monoidal queries came from the graphics-drawingcombinators package, http://hackage.haskell.org/package/graphics-drawingcombinators.

Constructors

Query |

Fields

- runQuery :: Point v n -> m

#### Instances

Instances details

Action Name (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Query v n m -> Query v n m Source #
Functor v => Closed (Query v) Source # |
Instance details Defined in Diagrams.Core.Query Methods closed :: Query v a b -> Query v (x -> a) (x -> b) Source #
Functor v => Corepresentable (Query v) Source # |

Instance details

Defined in Diagrams.Core.Query

Associated Types

type Corep (Query v) |
Instance details Defined in Diagrams.Core.Query type Corep (Query v) = Point v

Methods

cotabulate :: (Corep (Query v) d -> c) -> Query v d c Source #

Functor v => Costrong (Query v) Source # |
Instance details Defined in Diagrams.Core.Query Methods unfirst :: Query v (a, d) (b, d) -> Query v a b Source # unsecond :: Query v (d, a) (d, b) -> Query v a b Source #
Functor v => Profunctor (Query v) Source # |

Instance details

Defined in Diagrams.Core.Query

Methods

dimap :: (a -> b) -> (c -> d) -> Query v b c -> Query v a d Source #

lmap :: (a -> b) -> Query v b c -> Query v a c Source #

rmap :: (b -> c) -> Query v a b -> Query v a c Source #

(#.) :: forall a b c q. Coercible c b => q b c -> Query v a b -> Query v a c Source #

(.#) :: forall a b c q. Coercible b a => Query v b c -> q a b -> Query v a c Source #

Functor v => Cosieve (Query v) (Point v) Source # |
Instance details Defined in Diagrams.Core.Query Methods cosieve :: Query v a b -> Point v a -> b Source #
Representable (Query v n) Source # |

Instance details

Defined in Diagrams.Core.Query

Associated Types

type Rep (Query v n) |
Instance details Defined in Diagrams.Core.Query type Rep (Query v n) = Point v n

Methods

tabulate :: (Rep (Query v n) -> a) -> Query v n a Source #

index :: Query v n a -> Rep (Query v n) -> a Source #

Distributive (Query v n) Source # |
Instance details Defined in Diagrams.Core.Query Methods distribute :: Functor f => f (Query v n a) -> Query v n (f a) Source # collect :: Functor f => (a -> Query v n b) -> f a -> Query v n (f b) Source # distributeM :: Monad m => m (Query v n a) -> Query v n (m a) Source # collectM :: Monad m => (a -> Query v n b) -> m a -> Query v n (m b) Source #
Applicative (Query v n) Source # |
Instance details Defined in Diagrams.Core.Query Methods pure :: a -> Query v n a Source # (<*>) :: Query v n (a -> b) -> Query v n a -> Query v n b Source # liftA2 :: (a -> b -> c) -> Query v n a -> Query v n b -> Query v n c Source # (*>) :: Query v n a -> Query v n b -> Query v n b Source # (<*) :: Query v n a -> Query v n b -> Query v n a Source #
Functor (Query v n) Source # |
Instance details Defined in Diagrams.Core.Query Methods fmap :: (a -> b) -> Query v n a -> Query v n b Source # (<$) :: a -> Query v n b -> Query v n a Source #
Monad (Query v n) Source # |
Instance details Defined in Diagrams.Core.Query Methods (>>=) :: Query v n a -> (a -> Query v n b) -> Query v n b Source # (>>) :: Query v n a -> Query v n b -> Query v n b Source # return :: a -> Query v n a Source #
(Additive v, Num n) => HasOrigin (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query Methods moveOriginTo :: Point (V (Query v n m)) (N (Query v n m)) -> Query v n m -> Query v n m Source #
(Additive v, Num n) => Transformable (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query Methods transform :: Transformation (V (Query v n m)) (N (Query v n m)) -> Query v n m -> Query v n m Source #
Monoid m => Monoid (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query Methods mempty :: Query v n m Source # mappend :: Query v n m -> Query v n m -> Query v n m Source # mconcat :: [Query v n m] -> Query v n m Source #
Semigroup m => Semigroup (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query Methods (<>) :: Query v n m -> Query v n m -> Query v n m Source # sconcat :: NonEmpty (Query v n m) -> Query v n m Source # stimes :: Integral b => b -> Query v n m -> Query v n m Source #
Wrapped (Query v n m) Source # |

Instance details

Defined in Diagrams.Core.Query

Associated Types

type Unwrapped (Query v n m) |
Instance details Defined in Diagrams.Core.Query type Unwrapped (Query v n m) = Point v n -> m

Methods

_Wrapped' :: Iso' (Query v n m) (Unwrapped (Query v n m)) Source #

Rewrapped (Query v a m) (Query v' a' m') Source # |
Instance details Defined in Diagrams.Core.Query
type Corep (Query v) Source # |
Instance details Defined in Diagrams.Core.Query type Corep (Query v) = Point v
type Rep (Query v n) Source # |
Instance details Defined in Diagrams.Core.Query type Rep (Query v n) = Point v n
type N (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query type N (Query v n m) = n
type V (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query type V (Query v n m) = v
type Unwrapped (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Query type Unwrapped (Query v n m) = Point v n -> m

# Primitives

data Prim b (v :: Type -> Type) n where Source #

A value of type `Prim b v n` is an opaque (existentially quantified) primitive which backend `b` knows how to render in vector space `v`.

Constructors

Prim :: forall p b. (Transformable p, Typeable p, Renderable p b) => p -> Prim b (V p) (N p) |

#### Instances

Instances details

Transformable (Prim b v n) Source # | The `Transformable` instance for `Prim` just pushes calls to `transform` down through the `Prim` constructor.
Instance details Defined in Diagrams.Core.Types Methods transform :: Transformation (V (Prim b v n)) (N (Prim b v n)) -> Prim b v n -> Prim b v n Source #
Renderable (Prim b v n) b Source # | The `Renderable` instance for `Prim` just pushes calls to `render` down through the `Prim` constructor.
Instance details Defined in Diagrams.Core.Types Methods render :: b -> Prim b v n -> Render b (V (Prim b v n)) (N (Prim b v n)) Source #
type N (Prim b v n) Source # |
Instance details Defined in Diagrams.Core.Types type N (Prim b v n) = n
type V (Prim b v n) Source # |
Instance details Defined in Diagrams.Core.Types type V (Prim b v n) = v

# Diagrams

data QDiagram b (v :: Type -> Type) n m Source #

The fundamental diagram type. The type variables are as follows:

- `b` represents the backend, such as `SVG` or `Cairo`. Note that each backend also exports a type synonym `B` for itself, so the type variable `b` may also typically be instantiated by `B`, meaning "use whatever backend is in scope".
- `v` represents the vector space of the diagram. Typical instantiations include `V2` (for a two-dimensional diagram) or `V3` (for a three-dimensional diagram).
- `n` represents the numerical field the diagram uses. Typically this will be a concrete numeric type like `Double`.
- `m` is the monoidal type of "query annotations": each point in the diagram has a value of type `m` associated to it, and these values are combined according to the `Monoid` instance for `m`. Most often, `m` is simply instantiated to `Any`, associating a simple `Bool` value to each point indicating whether the point is inside the diagram; `Diagram` is a synonym for `QDiagram` with `m` thus instantiated to `Any`.

Diagrams can be combined via their `Monoid` instance, transformed via their `Transformable` instance, and assigned attributes via their `HasStyle` instance.

Note that the `Q` in `QDiagram` stands for "Queriable", as distinguished from `Diagram`, where `m` is fixed to `Any`. This is not really a very good name, but it's probably not worth changing it at this point.

#### Instances

Instances details

Functor (QDiagram b v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods fmap :: (a -> b0) -> QDiagram b v n a -> QDiagram b v n b0 Source # (<$) :: a -> QDiagram b v n b0 -> QDiagram b v n a Source #
(Metric v, OrderedField n, Monoid' m) => Enveloped (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods getEnvelope :: QDiagram b v n m -> Envelope (V (QDiagram b v n m)) (N (QDiagram b v n m)) Source #
(Metric v, OrderedField n, Semigroup m) => HasOrigin (QDiagram b v n m) Source # | Every diagram has an intrinsic "local origin" which is the basis for all combining operations.
Instance details Defined in Diagrams.Core.Types Methods moveOriginTo :: Point (V (QDiagram b v n m)) (N (QDiagram b v n m)) -> QDiagram b v n m -> QDiagram b v n m Source #
(Metric v, OrderedField n, Monoid' m) => Juxtaposable (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods juxtapose :: Vn (QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m -> QDiagram b v n m Source #
(Metric v, OrderedField n, Semigroup m) => Qualifiable (QDiagram b v n m) Source # | Diagrams can be qualified so that all their named points can now be referred to using the qualification prefix.
Instance details Defined in Diagrams.Core.Types Methods (.>>) :: IsName a => a -> QDiagram b v n m -> QDiagram b v n m Source #
(Metric v, OrderedField n, Semigroup m) => HasStyle (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods applyStyle :: Style (V (QDiagram b v n m)) (N (QDiagram b v n m)) -> QDiagram b v n m -> QDiagram b v n m Source #
(Metric v, OrderedField n, Semigroup m) => Traced (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods getTrace :: QDiagram b v n m -> Trace (V (QDiagram b v n m)) (N (QDiagram b v n m)) Source #
(OrderedField n, Metric v, Semigroup m) => Transformable (QDiagram b v n m) Source # | Diagrams can be transformed by transforming each of their components appropriately.
Instance details Defined in Diagrams.Core.Types Methods transform :: Transformation (V (QDiagram b v n m)) (N (QDiagram b v n m)) -> QDiagram b v n m -> QDiagram b v n m Source #

(Metric v, OrderedField n, Semigroup m) => Monoid (QDiagram b v n m) Source #

Diagrams form a monoid since each of their components do: the empty diagram has no primitives, an empty envelope, an empty trace, no named subdiagrams, and a constantly empty query function.

Diagrams compose by aligning their respective local origins. The new diagram has all the primitives and all the names from the two diagrams combined, and query functions are combined pointwise. The first diagram goes on top of the second. "On top of" probably only makes sense in vector spaces of dimension lower than 3, but in theory it could make sense for, say, 3-dimensional diagrams when viewed by 4-dimensional beings.

Instance details Defined in Diagrams.Core.Types Methods mempty :: QDiagram b v n m Source # mappend :: QDiagram b v n m -> QDiagram b v n m -> QDiagram b v n m Source # mconcat :: [QDiagram b v n m] -> QDiagram b v n m Source #
(Metric v, OrderedField n, Semigroup m) => Semigroup (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods (<>) :: QDiagram b v n m -> QDiagram b v n m -> QDiagram b v n m Source # sconcat :: NonEmpty (QDiagram b v n m) -> QDiagram b v n m Source # stimes :: Integral b0 => b0 -> QDiagram b v n m -> QDiagram b v n m Source #
Wrapped (QDiagram b v n m) Source # |

Instance details

Defined in Diagrams.Core.Types

Associated Types

type Unwrapped (QDiagram b v n m) |
Instance details Defined in Diagrams.Core.Types type Unwrapped (QDiagram b v n m) = DUALTree (DownAnnots v n) (UpAnnots b v n m) Annotation (QDiaLeaf b v n m)

Methods

_Wrapped' :: Iso' (QDiagram b v n m) (Unwrapped (QDiagram b v n m)) Source #

Rewrapped (QDiagram b v n m) (QDiagram b' v' n' m') Source # |
Instance details Defined in Diagrams.Core.Types
type N (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type N (QDiagram b v n m) = n
type V (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type V (QDiagram b v n m) = v
type Unwrapped (QDiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type Unwrapped (QDiagram b v n m) = DUALTree (DownAnnots v n) (UpAnnots b v n m) Annotation (QDiaLeaf b v n m)

type Diagram b = QDiagram b (V b) (N b) Any Source #

`Diagram b` is a synonym for ``QDiagram` b (V b) (N b) `Any``. That is, the default sort of diagram is one where querying at a point simply tells you whether the diagram contains that point or not. Transforming a default diagram into one with a more interesting query can be done via the `Functor` instance of ``QDiagram` b v n` or the `value` function.

mkQD :: forall b (v :: Type -> Type) n m. Prim b v n -> Envelope v n -> Trace v n -> SubMap b v n m -> Query v n m -> QDiagram b v n m Source #

Create a diagram from a single primitive, along with an envelope, trace, subdiagram map, and query function.

pointDiagram :: forall (v :: Type -> Type) n b m. (Metric v, Fractional n) => Point v n -> QDiagram b v n m Source #

Create a "point diagram", which has no content, no trace, an empty query, and a point envelope.

envelope :: forall n (v :: Type -> Type) m b. (OrderedField n, Metric v, Monoid' m) => Lens' (QDiagram b v n m) (Envelope v n) Source #

Lens onto the `Envelope` of a `QDiagram`.

trace :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => Lens' (QDiagram b v n m) (Trace v n) Source #

Lens onto the `Trace` of a `QDiagram`.

subMap :: forall (v :: Type -> Type) m n b. (Metric v, Semigroup m, OrderedField n) => Lens' (QDiagram b v n m) (SubMap b v n m) Source #

Lens onto the `SubMap` of a `QDiagram` (i.e. an association from names to subdiagrams).

names :: forall (v :: Type -> Type) m n b. (Metric v, Semigroup m, OrderedField n) => QDiagram b v n m -> [(Name, [Point v n])] Source #

Get a list of names of subdiagrams and their locations.

query :: forall m b (v :: Type -> Type) n. Monoid m => QDiagram b v n m -> Query v n m Source #

Get the query function associated with a diagram.

nameSub :: forall nm (v :: Type -> Type) n m b. (IsName nm, Metric v, OrderedField n, Semigroup m) => (QDiagram b v n m -> Subdiagram b v n m) -> nm -> QDiagram b v n m -> QDiagram b v n m Source #

Attach an atomic name to a certain subdiagram, computed from the given diagram /with the mapping from name to subdiagram included/. The upshot of this knot-tying is that if `d' = d # named x`, then `lookupName x d' == Just d'` (instead of `Just d`).

withName :: forall nm (v :: Type -> Type) m n b. (IsName nm, Metric v, Semigroup m, OrderedField n) => nm -> (Subdiagram b v n m -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m Source #

Given a name and a diagram transformation indexed by a subdiagram, perform the transformation using the most recent subdiagram associated with (some qualification of) the name, or perform the identity transformation if the name does not exist.

withNameAll :: forall nm (v :: Type -> Type) m n b. (IsName nm, Metric v, Semigroup m, OrderedField n) => nm -> ([Subdiagram b v n m] -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m Source #

Given a name and a diagram transformation indexed by a list of subdiagrams, perform the transformation using the collection of all such subdiagrams associated with (some qualification of) the given name.

withNames :: forall nm (v :: Type -> Type) m n b. (IsName nm, Metric v, Semigroup m, OrderedField n) => [nm] -> ([Subdiagram b v n m] -> QDiagram b v n m -> QDiagram b v n m) -> QDiagram b v n m -> QDiagram b v n m Source #

Given a list of names and a diagram transformation indexed by a list of subdiagrams, perform the transformation using the list of most recent subdiagrams associated with (some qualification of) each name. Do nothing (the identity transformation) if any of the names do not exist.

localize :: forall b (v :: Type -> Type) n m. (Metric v, OrderedField n, Semigroup m) => QDiagram b v n m -> QDiagram b v n m Source #

"Localize" a diagram by hiding all the names, so they are no longer visible to the outside.

href :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => String -> QDiagram b v n m -> QDiagram b v n m Source #

Make a diagram into a hyperlink. Note that only some backends will honor hyperlink annotations.

opacityGroup :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => Double -> QDiagram b v n m -> QDiagram b v n m Source #

Change the transparency of a `Diagram` as a group.

groupOpacity :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => Double -> QDiagram b v n m -> QDiagram b v n m Source #

Change the transparency of a `Diagram` as a group.

setEnvelope :: forall b (v :: Type -> Type) n m. (OrderedField n, Metric v, Monoid' m) => Envelope v n -> QDiagram b v n m -> QDiagram b v n m Source #

Replace the envelope of a diagram.

setTrace :: forall b (v :: Type -> Type) n m. (OrderedField n, Metric v, Semigroup m) => Trace v n -> QDiagram b v n m -> QDiagram b v n m Source #

Replace the trace of a diagram.

atop :: forall n (v :: Type -> Type) m b. (OrderedField n, Metric v, Semigroup m) => QDiagram b v n m -> QDiagram b v n m -> QDiagram b v n m infixl 6 Source #

A convenient synonym for `mappend` on diagrams, designed to be used infix (to help remember which diagram goes on top of which when combining them, namely, the first on top of the second).

## Subdiagrams

data Subdiagram b (v :: Type -> Type) n m Source #

A `Subdiagram` represents a diagram embedded within the context of a larger diagram. Essentially, it consists of a diagram paired with any accumulated information from the larger context (transformations, attributes, etc.).

Constructors

Subdiagram (QDiagram b v n m) (DownAnnots v n) |

#### Instances

Instances details

Functor (Subdiagram b v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods fmap :: (a -> b0) -> Subdiagram b v n a -> Subdiagram b v n b0 Source # (<$) :: a -> Subdiagram b v n b0 -> Subdiagram b v n a Source #
(OrderedField n, Metric v, Monoid' m) => Enveloped (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods getEnvelope :: Subdiagram b v n m -> Envelope (V (Subdiagram b v n m)) (N (Subdiagram b v n m)) Source #
(Metric v, OrderedField n) => HasOrigin (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods moveOriginTo :: Point (V (Subdiagram b v n m)) (N (Subdiagram b v n m)) -> Subdiagram b v n m -> Subdiagram b v n m Source #
(OrderedField n, Metric v, Semigroup m) => Traced (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods getTrace :: Subdiagram b v n m -> Trace (V (Subdiagram b v n m)) (N (Subdiagram b v n m)) Source #
Transformable (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods transform :: Transformation (V (Subdiagram b v n m)) (N (Subdiagram b v n m)) -> Subdiagram b v n m -> Subdiagram b v n m Source #
type N (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type N (Subdiagram b v n m) = n
type V (Subdiagram b v n m) Source # |
Instance details Defined in Diagrams.Core.Types type V (Subdiagram b v n m) = v

mkSubdiagram :: forall b (v :: Type -> Type) n m. QDiagram b v n m -> Subdiagram b v n m Source #

Turn a diagram into a subdiagram with no accumulated context.

getSub :: forall (v :: Type -> Type) n m b. (Metric v, OrderedField n, Semigroup m) => Subdiagram b v n m -> QDiagram b v n m Source #

Turn a subdiagram into a normal diagram, including the enclosing context. Concretely, a subdiagram is a pair of (1) a diagram and (2) a "context" consisting of an extra transformation and attributes. `getSub` simply applies the transformation and attributes to the diagram to get the corresponding "top-level" diagram.

rawSub :: forall b (v :: Type -> Type) n m. Subdiagram b v n m -> QDiagram b v n m Source #

Extract the "raw" content of a subdiagram, by throwing away the context.

location :: forall (v :: Type -> Type) n b m. (Additive v, Num n) => Subdiagram b v n m -> Point v n Source #

Get the location of a subdiagram; that is, the location of its local origin with respect to the vector space of its parent diagram. In other words, the point where its local origin "ended up".

subPoint :: forall (v :: Type -> Type) n b m. (Metric v, OrderedField n) => Point v n -> Subdiagram b v n m Source #

Create a "point subdiagram", that is, a `pointDiagram` (with no content and a point envelope) treated as a subdiagram with local origin at the given point. Note this is not the same as `mkSubdiagram . pointDiagram`, which would result in a subdiagram with local origin at the parent origin, rather than at the given point.

## Measurements

data Measured n a Source #

'Measured n a' is an object that depends on `local`, `normalized` and `global` scales. The `normalized` and `global` scales are calculated when rendering a diagram.

For attributes, the `local` scale gets multiplied by the average scale of the transform.

#### Instances

Instances details

Profunctor Measured Source # |

Instance details

Defined in Diagrams.Core.Measure

Methods

dimap :: (a -> b) -> (c -> d) -> Measured b c -> Measured a d Source #

lmap :: (a -> b) -> Measured b c -> Measured a c Source #

rmap :: (b -> c) -> Measured a b -> Measured a c Source #

(#.) :: forall a b c q. Coercible c b => q b c -> Measured a b -> Measured a c Source #

(.#) :: forall a b c q. Coercible b a => Measured b c -> q a b -> Measured a c Source #

Representable (Measured n) Source # |

Instance details

Defined in Diagrams.Core.Measure

Associated Types

type Rep (Measured n) |
Instance details Defined in Diagrams.Core.Measure type Rep (Measured n) = (n, n, n)

Methods

tabulate :: (Rep (Measured n) -> a) -> Measured n a Source #

index :: Measured n a -> Rep (Measured n) -> a Source #

Distributive (Measured n) Source # |
Instance details Defined in Diagrams.Core.Measure Methods distribute :: Functor f => f (Measured n a) -> Measured n (f a) Source # collect :: Functor f => (a -> Measured n b) -> f a -> Measured n (f b) Source # distributeM :: Monad m => m (Measured n a) -> Measured n (m a) Source # collectM :: Monad m => (a -> Measured n b) -> m a -> Measured n (m b) Source #
Applicative (Measured n) Source # |
Instance details Defined in Diagrams.Core.Measure Methods pure :: a -> Measured n a Source # (<*>) :: Measured n (a -> b) -> Measured n a -> Measured n b Source # liftA2 :: (a -> b -> c) -> Measured n a -> Measured n b -> Measured n c Source # (*>) :: Measured n a -> Measured n b -> Measured n b Source # (<*) :: Measured n a -> Measured n b -> Measured n a Source #
Functor (Measured n) Source # |
Instance details Defined in Diagrams.Core.Measure Methods fmap :: (a -> b) -> Measured n a -> Measured n b Source # (<$) :: a -> Measured n b -> Measured n a Source #
Monad (Measured n) Source # |
Instance details Defined in Diagrams.Core.Measure Methods (>>=) :: Measured n a -> (a -> Measured n b) -> Measured n b Source # (>>) :: Measured n a -> Measured n b -> Measured n b Source # return :: a -> Measured n a Source #
Additive (Measured n) Source # |

Instance details

Defined in Diagrams.Core.Measure

Methods

zero :: Num a => Measured n a Source #

(^+^) :: Num a => Measured n a -> Measured n a -> Measured n a Source #

(^-^) :: Num a => Measured n a -> Measured n a -> Measured n a Source #

lerp :: Num a => a -> Measured n a -> Measured n a -> Measured n a Source #

liftU2 :: (a -> a -> a) -> Measured n a -> Measured n a -> Measured n a Source #

liftI2 :: (a -> b -> c) -> Measured n a -> Measured n b -> Measured n c Source #

HasOrigin t => HasOrigin (Measured n t) Source # |
Instance details Defined in Diagrams.Core.HasOrigin Methods moveOriginTo :: Point (V (Measured n t)) (N (Measured n t)) -> Measured n t -> Measured n t Source #
Juxtaposable a => Juxtaposable (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Juxtapose Methods juxtapose :: Vn (Measured n a) -> Measured n a -> Measured n a -> Measured n a Source #
Qualifiable a => Qualifiable (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> Measured n a -> Measured n a Source #
HasStyle b => HasStyle (Measured n b) Source # |
Instance details Defined in Diagrams.Core.Style Methods applyStyle :: Style (V (Measured n b)) (N (Measured n b)) -> Measured n b -> Measured n b Source #
(InSpace v n t, Transformable t, HasLinearMap v, Floating n) => Transformable (Measured n t) Source # |
Instance details Defined in Diagrams.Core.Transform Methods transform :: Transformation (V (Measured n t)) (N (Measured n t)) -> Measured n t -> Measured n t Source #
Monoid a => Monoid (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Measure Methods mempty :: Measured n a Source # mappend :: Measured n a -> Measured n a -> Measured n a Source # mconcat :: [Measured n a] -> Measured n a Source #
Semigroup a => Semigroup (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Measure Methods (<>) :: Measured n a -> Measured n a -> Measured n a Source # sconcat :: NonEmpty (Measured n a) -> Measured n a Source # stimes :: Integral b => b -> Measured n a -> Measured n a Source #
Floating a => Floating (Measured n a) Source # |

Instance details

Defined in Diagrams.Core.Measure

Methods

pi :: Measured n a Source #

exp :: Measured n a -> Measured n a Source #

log :: Measured n a -> Measured n a Source #

sqrt :: Measured n a -> Measured n a Source #

(**) :: Measured n a -> Measured n a -> Measured n a Source #

logBase :: Measured n a -> Measured n a -> Measured n a Source #

sin :: Measured n a -> Measured n a Source #

cos :: Measured n a -> Measured n a Source #

tan :: Measured n a -> Measured n a Source #

asin :: Measured n a -> Measured n a Source #

acos :: Measured n a -> Measured n a Source #

atan :: Measured n a -> Measured n a Source #

sinh :: Measured n a -> Measured n a Source #

cosh :: Measured n a -> Measured n a Source #

tanh :: Measured n a -> Measured n a Source #

asinh :: Measured n a -> Measured n a Source #

acosh :: Measured n a -> Measured n a Source #

atanh :: Measured n a -> Measured n a Source #

log1p :: Measured n a -> Measured n a Source #

expm1 :: Measured n a -> Measured n a Source #

log1pexp :: Measured n a -> Measured n a Source #

log1mexp :: Measured n a -> Measured n a Source #

Num a => Num (Measured n a) Source # |

Instance details

Defined in Diagrams.Core.Measure

Methods

(+) :: Measured n a -> Measured n a -> Measured n a Source #

(-) :: Measured n a -> Measured n a -> Measured n a Source #

(*) :: Measured n a -> Measured n a -> Measured n a Source #

negate :: Measured n a -> Measured n a Source #

abs :: Measured n a -> Measured n a Source #

signum :: Measured n a -> Measured n a Source #

fromInteger :: Integer -> Measured n a Source #

Fractional a => Fractional (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Measure Methods (/) :: Measured n a -> Measured n a -> Measured n a Source # recip :: Measured n a -> Measured n a Source # fromRational :: Rational -> Measured n a Source #
MonadReader (n, n, n) (Measured n) Source # |
Instance details Defined in Diagrams.Core.Measure Methods ask :: Measured n (n, n, n) Source # local :: ((n, n, n) -> (n, n, n)) -> Measured n a -> Measured n a Source # reader :: ((n, n, n) -> a) -> Measured n a Source #
type Rep (Measured n) Source # |
Instance details Defined in Diagrams.Core.Measure type Rep (Measured n) = (n, n, n)
type N (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Measure type N (Measured n a) = N a
type V (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Measure type V (Measured n a) = V a

type Measure n = Measured n n Source #

A measure is a `Measured` number.

fromMeasured :: Num n => n -> n -> Measured n a -> a Source #

    fromMeasured globalScale normalizedScale measure -> a

output :: n -> Measure n Source #

Output units don't change.

local :: Num n => n -> Measure n Source #

Local units are scaled by the average scale of a transform.

global :: Num n => n -> Measure n Source #

Global units are scaled so that they are interpreted relative to the size of the final rendered diagram.

normalized :: Num n => n -> Measure n Source #

Normalized units get scaled so that one normalized unit is the size of the final diagram.

scaleLocal :: Num n => n -> Measured n a -> Measured n a Source #

Scale the local units of a `Measured` thing.

atLeast :: Ord n => Measure n -> Measure n -> Measure n Source #

Calculate the larger of two measures.

atMost :: Ord n => Measure n -> Measure n -> Measure n Source #

Calculate the smaller of two measures.

# Backends

class Backend b (v :: Type -> Type) n where Source #

Abstract diagrams are rendered to particular formats by backends. Each backend/vector space combination must be an instance of the `Backend` class.

A minimal complete definition consists of `Render`, `Result`, `Options`, and `renderRTree`. However, most backends will want to implement `adjustDia` as well; the default definition does nothing. Some useful standard definitions are provided in the `Diagrams.TwoD.Adjust` module from the `diagrams-lib` package.

Minimal complete definition

renderRTree

Associated Types

data Render b (v :: Type -> Type) n Source #

An intermediate representation used for rendering primitives. (Typically, this will be some sort of monad, but it need not be.) The `Renderable` class guarantees that a backend will be able to convert primitives into this type; how these rendered primitives are combined into an ultimate `Result` is completely up to the backend.

type Result b (v :: Type -> Type) n Source #

The result of running/interpreting a rendering operation.

data Options b (v :: Type -> Type) n Source #

Backend-specific rendering options.

Methods

adjustDia :: (Additive v, Monoid' m, Num n) => b -> Options b v n -> QDiagram b v n m -> (Options b v n, Transformation v n, QDiagram b v n m) Source #

`adjustDia` allows the backend to make adjustments to the final diagram (e.g. to adjust the size based on the options) before rendering it. It returns a modified options record, the transformation applied to the diagram (which can be used to convert attributes whose value is `Measure`, or transform e.g. screen coordinates back into local diagram coordinates), and the adjusted diagram itself.

See the diagrams-lib package (particularly the `Diagrams.TwoD.Adjust` module) for some useful implementations.

renderRTree :: b -> Options b v n -> RTree b v n Annotation -> Result b v n Source #

Given some options, take a representation of a diagram as a tree and render it. The `RTree` has already been simplified and has all measurements converted to `Output` units.

#### Instances

Instances details

Backend NullBackend v n Source # |

Instance details

Defined in Diagrams.Core.Types

Associated Types

data Render NullBackend v n |
Instance details Defined in Diagrams.Core.Types data Render NullBackend v n = NullBackendRender
type Result NullBackend v n |
Instance details Defined in Diagrams.Core.Types type Result NullBackend v n = ()
data Options NullBackend v n |
Instance details Defined in Diagrams.Core.Types data Options NullBackend v n

Methods

adjustDia :: (Additive v, Monoid' m, Num n) => NullBackend -> Options NullBackend v n -> QDiagram NullBackend v n m -> (Options NullBackend v n, Transformation v n, QDiagram NullBackend v n m) Source #

renderRTree :: NullBackend -> Options NullBackend v n -> RTree NullBackend v n Annotation -> Result NullBackend v n Source #

class Transformable t => Renderable t b where Source #

The Renderable type class connects backends to primitives which they know how to render.

Methods

render :: b -> t -> Render b (V t) (N t) Source #

Given a token representing the backend and a transformable object, render it in the appropriate rendering context.

#### Instances

Instances details

Renderable (Prim b v n) b Source # | The `Renderable` instance for `Prim` just pushes calls to `render` down through the `Prim` constructor.
Instance details Defined in Diagrams.Core.Types Methods render :: b -> Prim b v n -> Render b (V (Prim b v n)) (N (Prim b v n)) Source #

renderDia :: forall b (v :: Type -> Type) n m. (Backend b v n, HasLinearMap v, Metric v, Typeable n, OrderedField n, Monoid' m) => b -> Options b v n -> QDiagram b v n m -> Result b v n Source #

Render a diagram.

renderDiaT :: forall b (v :: Type -> Type) n m. (Backend b v n, HasLinearMap v, Metric v, Typeable n, OrderedField n, Monoid' m) => b -> Options b v n -> QDiagram b v n m -> (Transformation v n, Result b v n) Source #

Render a diagram, returning also the transformation which was used to convert the diagram from its ("global") coordinate system into the output coordinate system. The inverse of this transformation can be used, for example, to convert output/screen coordinates back into diagram coordinates. See also `adjustDia`.

## The null backend

data NullBackend Source #

A null backend which does no actual rendering. It is provided mainly for convenience in situations where you must give a diagram a concrete, monomorphic type, but don't actually care which one. See `D` for more explanation and examples.

It is courteous, when defining a new primitive `P`, to make an instance

    instance Renderable P NullBackend where
      render _ _ = mempty

This ensures that the trick with `D` annotations can be used for diagrams containing your primitive.

#### Instances

Instances details

Backend NullBackend v n Source # |

Instance details

Defined in Diagrams.Core.Types

Associated Types

data Render NullBackend v n |
Instance details Defined in Diagrams.Core.Types data Render NullBackend v n = NullBackendRender
type Result NullBackend v n |
Instance details Defined in Diagrams.Core.Types type Result NullBackend v n = ()
data Options NullBackend v n |
Instance details Defined in Diagrams.Core.Types data Options NullBackend v n

Methods

adjustDia :: (Additive v, Monoid' m, Num n) => NullBackend -> Options NullBackend v n -> QDiagram NullBackend v n m -> (Options NullBackend v n, Transformation v n, QDiagram NullBackend v n m) Source #

renderRTree :: NullBackend -> Options NullBackend v n -> RTree NullBackend v n Annotation -> Result NullBackend v n Source #

Monoid (Render NullBackend v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods mempty :: Render NullBackend v n Source # mappend :: Render NullBackend v n -> Render NullBackend v n -> Render NullBackend v n Source # mconcat :: [Render NullBackend v n] -> Render NullBackend v n Source #
Semigroup (Render NullBackend v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods (<>) :: Render NullBackend v n -> Render NullBackend v n -> Render NullBackend v n Source # sconcat :: NonEmpty (Render NullBackend v n) -> Render NullBackend v n Source # stimes :: Integral b => b -> Render NullBackend v n -> Render NullBackend v n Source #
data Options NullBackend v n Source # |
Instance details Defined in Diagrams.Core.Types data Options NullBackend v n
data Render NullBackend v n Source # |
Instance details Defined in Diagrams.Core.Types data Render NullBackend v n = NullBackendRender
type Result NullBackend v n Source # |
Instance details Defined in Diagrams.Core.Types type Result NullBackend v n = ()

type D (v :: Type -> Type) n = QDiagram NullBackend v n Any Source #

The `D` type is provided for convenience in situations where you must give a diagram a concrete, monomorphic type, but don't care which one. Such situations arise when you pass a diagram to a function which is polymorphic in its input but monomorphic in its output, such as `width`, `height`, `phantom`, or `names`. Such functions compute some property of the diagram, or use it to accomplish some other purpose, but do not result in the diagram being rendered. If the diagram does not have a monomorphic type, GHC complains that it cannot determine the diagram's type.

For example, here is the error we get if we try to compute the width of an image (this example requires `diagrams-lib`):

      ghci> width (image (uncheckedImageRef "foo.png" 200 200))
      <interactive>:11:8:
          No instance for (Renderable (DImage n0 External) b0)
            arising from a use of image
          The type variables n0, b0 are ambiguous
          Possible fix: add a type signature that fixes these type variable(s)
          Note: there is a potential instance available:
            instance Fractional n => Renderable (DImage n a) NullBackend
              -- Defined in Image
          Possible fix:
            add an instance declaration for
            (Renderable (DImage n0 External) b0)
          In the first argument of width, namely
            `(image (uncheckedImageRef "foo.png" 200 200))'
          In the expression:
            width (image (uncheckedImageRef "foo.png" 200 200))
          In an equation for it:
              it = width (image (uncheckedImageRef "foo.png" 200 200))

GHC complains that there is no instance for `Renderable (DImage n0 External) b0`; what is really going on is that it does not have enough information to decide what backend to use (hence the uninstantiated `n0` and `b0`). This is annoying because we know that the choice of backend cannot possibly affect the width of the image (it's 200! it's right there in the code!); but there is no way for GHC to know that.

The solution is to annotate the call to `image` with the type ``D` `V2` `Double``, like so:

      ghci> width (image (uncheckedImageRef "foo.png" 200 200) :: D V2 Double)
      200.00000000000006

(It turns out the width wasn't 200 after all...)

As another example, here is the error we get if we try to compute the width of a radius-1 circle:

      ghci> width (circle 1)
      <interactive>:12:1:
          Couldn't match expected type V2 with actual type `V a0'
          The type variable a0 is ambiguous
          Possible fix: add a type signature that fixes these type variable(s)
          In the expression: width (circle 1)
          In an equation for it: it = width (circle 1)

There's even more ambiguity here. Whereas `image` always returns a `Diagram`, the `circle` function can produce any `TrailLike` type, and the `width` function can consume any `Enveloped` type, so GHC has no idea what type to pick to go in the middle. However, the solution is the same:

      ghci> width (circle 1 :: D V2 Double)
      1.9999999999999998

# Convenience classes

type HasLinearMap (v :: Type -> Type) = (HasBasis v, Traversable v) Source #

`HasLinearMap` is a constraint synonym, just to help shorten some of the ridiculously long constraint sets.

type HasBasis (v :: Type -> Type) = (Additive v, Representable v, Rep v ~ E v) Source #

An `Additive` vector space whose representation is made up of basis elements.

type OrderedField s = (Floating s, Ord s) Source #

When dealing with envelopes we often want scalars to be an ordered field (i.e. support all four arithmetic operations and be totally ordered) so we introduce this constraint as a convenient shorthand.

type TypeableFloat n = (Typeable n, RealFloat n) Source #

Constraint for numeric types that are `RealFloat` and `Typeable`, which often occur together. This is used to shorten shorten type constraint contexts.

type Monoid' = Monoid Source #

For base < 4.11, the `Monoid'` constraint is a synonym for things which are instances of both `Semigroup` and `Monoid`. For base version 4.11 and onwards, `Monoid` has `Semigroup` as a superclass already, so for backwards compatibility `Monoid'` is provided as a synonym for `Monoid`.