Some types that are very basic vectors. Most of the use that can be made of the vectors is in their type-class instances, which support a powerful set of operations. For example:
fmap (*3) v -- Scales vector v by 3 pure 0 -- Creates a vector filled with zeroes v + w -- Adds two vectors (there is a 'Num' instance, basically)
You will probably want to create more friendly type synonyms, such as:
type Vector2 = Pair Double type Vector3 = Triple Double type Line2 = LinePair Double type Line3 = LineTriple Double
A pair, which acts as a 2D vector.
|Pair (a, a)|
|IsomorphicVectors Pair Rel2'|
|IsomorphicVectors Pair Point2'|
|IsomorphicVectors Rel2' Pair|
|IsomorphicVectors Point2' Pair|
|Geometry Pair Pair LinePair|
|Eq a => Eq (Pair a)|
|(Show a, Eq a, Num a) => Num (Pair a)|
|Ord a => Ord (Pair a)|
|Read a => Read (Pair a)|
|Show a => Show (Pair a)|
A triple, which acts as a 3D vector.
|Triple (a, a, a)|
|IsomorphicVectors Triple Rel3'|
|IsomorphicVectors Triple Point3'|
|IsomorphicVectors Rel3' Triple|
|IsomorphicVectors Point3' Triple|
|Geometry Triple Triple LineTriple|
|Eq a => Eq (Triple a)|
|(Show a, Eq a, Num a) => Num (Triple a)|
|Ord a => Ord (Triple a)|
|Read a => Read (Triple a)|
|Show a => Show (Triple a)|
A quad, which acts as a 4D vector.
|Quad (a, a, a, a)|
A pair of (position vector, direction vector) to be used as a 2D line.