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

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

Diagrams.Coordinates

Description

Nice syntax for constructing and pattern-matching on literal points and vectors.

Synopsis

- data a :& b = a :& b
- class Coordinates c where
  - type FinalCoord c
  - type PrevDim c
  - type Decomposition c
  - (^&) :: PrevDim c -> FinalCoord c -> c
  - pr :: PrevDim c -> FinalCoord c -> c
  - coords :: c -> Decomposition c

# Documentation

data a :& b infixl 7 Source #

A pair of values, with a convenient infix (left-associative) data constructor.

Constructors

a :& b infixl 7 |

#### Instances

Instances details

Coordinates (a :& b) Source # |

Instance details

Defined in Diagrams.Coordinates

Associated Types

type FinalCoord (a :& b) |
Instance details Defined in Diagrams.Coordinates type FinalCoord (a :& b) = b
type PrevDim (a :& b) |
Instance details Defined in Diagrams.Coordinates type PrevDim (a :& b) = a
type Decomposition (a :& b) |
Instance details Defined in Diagrams.Coordinates type Decomposition (a :& b) = a :& b

Methods

(^&) :: PrevDim (a :& b) -> FinalCoord (a :& b) -> a :& b Source #

pr :: PrevDim (a :& b) -> FinalCoord (a :& b) -> a :& b Source #

coords :: (a :& b) -> Decomposition (a :& b) Source #

(Show a, Show b) => Show (a :& b) Source # |
Instance details Defined in Diagrams.Coordinates Methods showsPrec :: Int -> (a :& b) -> ShowS Source # show :: (a :& b) -> String Source # showList :: [a :& b] -> ShowS Source #
(Eq a, Eq b) => Eq (a :& b) Source # |
Instance details Defined in Diagrams.Coordinates Methods (==) :: (a :& b) -> (a :& b) -> Bool Source # (/=) :: (a :& b) -> (a :& b) -> Bool Source #
(Ord a, Ord b) => Ord (a :& b) Source # |
Instance details Defined in Diagrams.Coordinates Methods compare :: (a :& b) -> (a :& b) -> Ordering Source # (<) :: (a :& b) -> (a :& b) -> Bool Source # (<=) :: (a :& b) -> (a :& b) -> Bool Source # (>) :: (a :& b) -> (a :& b) -> Bool Source # (>=) :: (a :& b) -> (a :& b) -> Bool Source # max :: (a :& b) -> (a :& b) -> a :& b Source # min :: (a :& b) -> (a :& b) -> a :& b Source #
type Decomposition (a :& b) Source # |
Instance details Defined in Diagrams.Coordinates type Decomposition (a :& b) = a :& b
type FinalCoord (a :& b) Source # |
Instance details Defined in Diagrams.Coordinates type FinalCoord (a :& b) = b
type PrevDim (a :& b) Source # |
Instance details Defined in Diagrams.Coordinates type PrevDim (a :& b) = a

class Coordinates c where Source #

Types which are instances of the `Coordinates` class can be constructed using `^&` (for example, a three-dimensional vector could be constructed by `1 ^& 6 ^& 3`), and deconstructed using `coords`. A common pattern is to use `coords` in conjunction with the `ViewPatterns` extension, like so:

    foo :: Vector3 -> ...
    foo (coords -> x :& y :& z) = ...

Minimal complete definition

(^&), coords

Associated Types

type FinalCoord c Source #

The type of the final coordinate.

type PrevDim c Source #

The type of everything other than the final coordinate.

type Decomposition c Source #

Decomposition of `c` into applications of `:&`.

Methods

(^&) :: PrevDim c -> FinalCoord c -> c infixl 7 Source #

Construct a value of type `c` by providing something of one less dimension (which is perhaps itself recursively constructed using `(^&)`) and a final coordinate. For example,

    2 ^& 3 :: P2
    3 ^& 5 ^& 6 :: V3

Note that `^&` is left-associative.

pr :: PrevDim c -> FinalCoord c -> c Source #

Prefix synonym for `^&`. pr stands for pair of `PrevDim`, `FinalCoord`

coords :: c -> Decomposition c Source #

Decompose a value of type `c` into its constituent coordinates, stored in a nested `(:&)` structure.

#### Instances

Instances details

Coordinates (V2 n) Source # |

Instance details

Defined in Diagrams.Coordinates

Associated Types

type FinalCoord (V2 n) |
Instance details Defined in Diagrams.Coordinates type FinalCoord (V2 n) = n
type PrevDim (V2 n) |
Instance details Defined in Diagrams.Coordinates type PrevDim (V2 n) = n
type Decomposition (V2 n) |
Instance details Defined in Diagrams.Coordinates type Decomposition (V2 n) = n :& n

Methods

(^&) :: PrevDim (V2 n) -> FinalCoord (V2 n) -> V2 n Source #

pr :: PrevDim (V2 n) -> FinalCoord (V2 n) -> V2 n Source #

coords :: V2 n -> Decomposition (V2 n) Source #

Coordinates (V3 n) Source # |

Instance details

Defined in Diagrams.Coordinates

Associated Types

type FinalCoord (V3 n) |
Instance details Defined in Diagrams.Coordinates type FinalCoord (V3 n) = n
type PrevDim (V3 n) |
Instance details Defined in Diagrams.Coordinates type PrevDim (V3 n) = V2 n
type Decomposition (V3 n) |
Instance details Defined in Diagrams.Coordinates type Decomposition (V3 n) = (n :& n) :& n

Methods

(^&) :: PrevDim (V3 n) -> FinalCoord (V3 n) -> V3 n Source #

pr :: PrevDim (V3 n) -> FinalCoord (V3 n) -> V3 n Source #

coords :: V3 n -> Decomposition (V3 n) Source #

Coordinates (V4 n) Source # |

Instance details

Defined in Diagrams.Coordinates

Associated Types

type FinalCoord (V4 n) |
Instance details Defined in Diagrams.Coordinates type FinalCoord (V4 n) = n
type PrevDim (V4 n) |
Instance details Defined in Diagrams.Coordinates type PrevDim (V4 n) = V3 n
type Decomposition (V4 n) |
Instance details Defined in Diagrams.Coordinates type Decomposition (V4 n) = ((n :& n) :& n) :& n

Methods

(^&) :: PrevDim (V4 n) -> FinalCoord (V4 n) -> V4 n Source #

pr :: PrevDim (V4 n) -> FinalCoord (V4 n) -> V4 n Source #

coords :: V4 n -> Decomposition (V4 n) Source #

Coordinates (a :& b) Source # |

Instance details

Defined in Diagrams.Coordinates

Associated Types

type FinalCoord (a :& b) |
Instance details Defined in Diagrams.Coordinates type FinalCoord (a :& b) = b
type PrevDim (a :& b) |
Instance details Defined in Diagrams.Coordinates type PrevDim (a :& b) = a
type Decomposition (a :& b) |
Instance details Defined in Diagrams.Coordinates type Decomposition (a :& b) = a :& b

Methods

(^&) :: PrevDim (a :& b) -> FinalCoord (a :& b) -> a :& b Source #

pr :: PrevDim (a :& b) -> FinalCoord (a :& b) -> a :& b Source #

coords :: (a :& b) -> Decomposition (a :& b) Source #

Coordinates (v n) => Coordinates (Point v n) Source # |

Instance details

Defined in Diagrams.Coordinates

Associated Types

type FinalCoord (Point v n) |
Instance details Defined in Diagrams.Coordinates type FinalCoord (Point v n) = FinalCoord (v n)
type PrevDim (Point v n) |
Instance details Defined in Diagrams.Coordinates type PrevDim (Point v n) = PrevDim (v n)
type Decomposition (Point v n) |
Instance details Defined in Diagrams.Coordinates type Decomposition (Point v n) = Decomposition (v n)

Methods

(^&) :: PrevDim (Point v n) -> FinalCoord (Point v n) -> Point v n Source #

pr :: PrevDim (Point v n) -> FinalCoord (Point v n) -> Point v n Source #

coords :: Point v n -> Decomposition (Point v n) Source #

Coordinates (a, b) Source # |

Instance details

Defined in Diagrams.Coordinates

Associated Types

type FinalCoord (a, b) |
Instance details Defined in Diagrams.Coordinates type FinalCoord (a, b) = b
type PrevDim (a, b) |
Instance details Defined in Diagrams.Coordinates type PrevDim (a, b) = a
type Decomposition (a, b) |
Instance details Defined in Diagrams.Coordinates type Decomposition (a, b) = a :& b

Methods

(^&) :: PrevDim (a, b) -> FinalCoord (a, b) -> (a, b) Source #

pr :: PrevDim (a, b) -> FinalCoord (a, b) -> (a, b) Source #

coords :: (a, b) -> Decomposition (a, b) Source #

Coordinates (a, b, c) Source # |

Instance details

Defined in Diagrams.Coordinates

Associated Types

type FinalCoord (a, b, c) |
Instance details Defined in Diagrams.Coordinates type FinalCoord (a, b, c) = c
type PrevDim (a, b, c) |
Instance details Defined in Diagrams.Coordinates type PrevDim (a, b, c) = (a, b)
type Decomposition (a, b, c) |
Instance details Defined in Diagrams.Coordinates type Decomposition (a, b, c) = Decomposition (a, b) :& c

Methods

(^&) :: PrevDim (a, b, c) -> FinalCoord (a, b, c) -> (a, b, c) Source #

pr :: PrevDim (a, b, c) -> FinalCoord (a, b, c) -> (a, b, c) Source #

coords :: (a, b, c) -> Decomposition (a, b, c) Source #

Coordinates (a, b, c, d) Source # |

Instance details

Defined in Diagrams.Coordinates

Associated Types

type FinalCoord (a, b, c, d) |
Instance details Defined in Diagrams.Coordinates type FinalCoord (a, b, c, d) = d
type PrevDim (a, b, c, d) |
Instance details Defined in Diagrams.Coordinates type PrevDim (a, b, c, d) = (a, b, c)
type Decomposition (a, b, c, d) |
Instance details Defined in Diagrams.Coordinates type Decomposition (a, b, c, d) = Decomposition (a, b, c) :& d

Methods

(^&) :: PrevDim (a, b, c, d) -> FinalCoord (a, b, c, d) -> (a, b, c, d) Source #

pr :: PrevDim (a, b, c, d) -> FinalCoord (a, b, c, d) -> (a, b, c, d) Source #

coords :: (a, b, c, d) -> Decomposition (a, b, c, d) Source #