Copyright | (c) 2012 diagrams-lib team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | None |
Language | Haskell2010 |
Nice syntax for constructing and pattern-matching on literal points and vectors.
- 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
- class HasX t where
- class HasY t where
- class HasZ t where
Documentation
A pair of values, with a convenient infix (left-associative) data constructor.
a :& b infixl 7 |
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) = ...
type FinalCoord c :: * Source
The type of the final coordinate.
The type of everything other than the final coordinate.
type Decomposition c :: * Source
Decomposition of c
into applications of :&
.
(^&) :: 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 :: R3
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.
Coordinates R2 | |
Coordinates R3 | |
Coordinates v => Coordinates (Point v) | |
Coordinates (a, b) | |
Coordinates (a, b, c) | |
Coordinates (a, b, c, d) |
Lenses for particular axes
The class of types with at least one coordinate, called _x.
Nothing
The class of types with at least two coordinates, the second called _y.
Nothing