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

Copyright(c) 2012 diagrams-lib team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.Coordinates

Description

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

Synopsis

Documentation

data a :& b infixl 7 #

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

Constructors

a :& b infixl 7 

Instances

(Eq b, Eq a) => Eq ((:&) a b) # 

Methods

(==) :: (a :& b) -> (a :& b) -> Bool #

(/=) :: (a :& b) -> (a :& b) -> Bool #

(Ord b, Ord a) => Ord ((:&) a b) # 

Methods

compare :: (a :& b) -> (a :& b) -> Ordering #

(<) :: (a :& b) -> (a :& b) -> Bool #

(<=) :: (a :& b) -> (a :& b) -> Bool #

(>) :: (a :& b) -> (a :& b) -> Bool #

(>=) :: (a :& b) -> (a :& b) -> Bool #

max :: (a :& b) -> (a :& b) -> a :& b #

min :: (a :& b) -> (a :& b) -> a :& b #

(Show b, Show a) => Show ((:&) a b) # 

Methods

showsPrec :: Int -> (a :& b) -> ShowS #

show :: (a :& b) -> String #

showList :: [a :& b] -> ShowS #

Coordinates ((:&) a b) # 

Associated Types

type FinalCoord ((:&) a b) :: * #

type PrevDim ((:&) a b) :: * #

type Decomposition ((:&) a b) :: * #

Methods

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

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

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

type FinalCoord ((:&) a b) # 
type FinalCoord ((:&) a b) = b
type PrevDim ((:&) a b) # 
type PrevDim ((:&) a b) = a
type Decomposition ((:&) a b) # 
type Decomposition ((:&) a b) = (:&) a b

class Coordinates c where #

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 :: * #

The type of the final coordinate.

type PrevDim c :: * #

The type of everything other than the final coordinate.

type Decomposition c :: * #

Decomposition of c into applications of :&.

Methods

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

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 #

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

coords :: c -> Decomposition c #

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

Instances

Coordinates (V4 n) # 

Associated Types

type FinalCoord (V4 n) :: * #

type PrevDim (V4 n) :: * #

type Decomposition (V4 n) :: * #

Methods

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

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

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

Coordinates (V3 n) # 

Associated Types

type FinalCoord (V3 n) :: * #

type PrevDim (V3 n) :: * #

type Decomposition (V3 n) :: * #

Methods

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

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

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

Coordinates (V2 n) # 

Associated Types

type FinalCoord (V2 n) :: * #

type PrevDim (V2 n) :: * #

type Decomposition (V2 n) :: * #

Methods

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

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

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

Coordinates (a, b) # 

Associated Types

type FinalCoord (a, b) :: * #

type PrevDim (a, b) :: * #

type Decomposition (a, b) :: * #

Methods

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

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

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

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

Associated Types

type FinalCoord (Point v n) :: * #

type PrevDim (Point v n) :: * #

type Decomposition (Point v n) :: * #

Methods

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

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

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

Coordinates ((:&) a b) # 

Associated Types

type FinalCoord ((:&) a b) :: * #

type PrevDim ((:&) a b) :: * #

type Decomposition ((:&) a b) :: * #

Methods

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

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

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

Coordinates (a, b, c) # 

Associated Types

type FinalCoord (a, b, c) :: * #

type PrevDim (a, b, c) :: * #

type Decomposition (a, b, c) :: * #

Methods

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

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

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

Coordinates (a, b, c, d) # 

Associated Types

type FinalCoord (a, b, c, d) :: * #

type PrevDim (a, b, c, d) :: * #

type Decomposition (a, b, c, d) :: * #

Methods

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

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

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