diagrams-lib-1.3.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 a, Eq b) => Eq ((:&) a b) 
(Ord a, Ord b) => Ord ((:&) a b) 
(Show a, Show b) => Show ((:&) a b) 
Coordinates ((:&) a b) 
type FinalCoord ((:&) a b) = b 
type PrevDim ((:&) a b) = a 
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) 
Coordinates (V3 n) 
Coordinates (V2 n) 
Coordinates (a, b) 
Coordinates (v n) => Coordinates (Point v n) 
Coordinates ((:&) a b) 
Coordinates (a, b, c) 
Coordinates (a, b, c, d)