Copyright | (c) 2012 diagrams-lib team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- type PrevDim c :: Type
- type Decomposition c :: Type
- (^&) :: PrevDim c -> FinalCoord c -> c
- pr :: PrevDim c -> FinalCoord c -> c
- coords :: c -> Decomposition c
Documentation
A pair of values, with a convenient infix (left-associative) data constructor.
a :& b infixl 7 |
Instances
(Show a, Show b) => Show (a :& b) Source # | |
Coordinates (a :& b) Source # | |
Defined in Diagrams.Coordinates | |
(Eq a, Eq b) => Eq (a :& b) Source # | |
(Ord a, Ord b) => Ord (a :& b) Source # | |
Defined in Diagrams.Coordinates | |
type Decomposition (a :& b) Source # | |
Defined in Diagrams.Coordinates | |
type FinalCoord (a :& b) Source # | |
Defined in Diagrams.Coordinates | |
type PrevDim (a :& b) Source # | |
Defined in Diagrams.Coordinates |
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 :: Type Source #
The type of the final coordinate.
type PrevDim c :: Type Source #
The type of everything other than the final coordinate.
type Decomposition c :: Type 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 :: 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
Coordinates (V2 n) Source # | |
Coordinates (V3 n) Source # | |
Coordinates (V4 n) Source # | |
Coordinates (a :& b) Source # | |
Defined in Diagrams.Coordinates | |
Coordinates (v n) => Coordinates (Point v n) Source # | |
Defined in Diagrams.Coordinates | |
Coordinates (a, b) Source # | |
Defined in Diagrams.Coordinates (^&) :: 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 # | |
Defined in Diagrams.Coordinates type FinalCoord (a, b, c) Source # type PrevDim (a, b, c) Source # type Decomposition (a, b, c) Source # (^&) :: 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 # | |
Defined in Diagrams.Coordinates type FinalCoord (a, b, c, d) Source # type PrevDim (a, b, c, d) Source # type Decomposition (a, b, c, d) Source # (^&) :: 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 # |