HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulelinear-1.22Haskell2010

Linear.V2

2-D Vectors

  • 1 type
  • 2 classes
  • 7 values
  • Packagelinear-1.22
  • Exports10
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceV2.hs
datadata V2 a
#

A 2-dimensional vector

Example1 expression
pure 1 :: V2 IntV2 1 1
Example1 expression
V2 1 2 + V2 3 4V2 4 6
Example1 expression
V2 1 2 * V2 3 4V2 3 8
Example1 expression
sum (V2 1 2)3

Constructors

Instances69Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
classclass R1 (t :: Type -> Type) where
#

A space that has at least 1 basis vector _x.

Methods

  • _x :: Lens' (t a) a
    Example1 expression
    V1 2 ^._x2
    Example1 expression
    V1 2 & _x .~ 3V1 3
Instances7R1, …
  • R1 IdentityDefined in linear-1.22 · Linear.V1
  • R1 QuaternionDefined in linear-1.22 · Linear.Quaternion
  • R1 V1Defined in linear-1.22 · Linear.V1
  • R1 V2Defined in linear-1.22 · Linear.V2
  • R1 V3Defined in linear-1.22 · Linear.V3
  • R1 V4Defined in linear-1.22 · Linear.V4
  • R1 f => R1 (Point f)Defined in linear-1.22 · Linear.Affine
classclass R1 t => R2 (t :: Type -> Type) where
#

A space that distinguishes 2 orthogonal basis vectors _x and _y, but may have more.

Methods

  • _y :: Lens' (t a) a
    Example1 expression
    V2 1 2 ^._y2
    Example1 expression
    V2 1 2 & _y .~ 3V2 1 3
  • _xy :: Lens' (t a) (V2 a)
Instances5R2
  • R2 QuaternionDefined in linear-1.22 · Linear.Quaternion
  • R2 V2Defined in linear-1.22 · Linear.V2
  • R2 V3Defined in linear-1.22 · Linear.V3
  • R2 V4Defined in linear-1.22 · Linear.V4
  • R2 f => R2 (Point f)Defined in linear-1.22 · Linear.Affine
value_yx :: R2 t => Lens' (t a) (V2 a)
#
Example1 expression
V2 1 2 ^. _yxV2 2 1
valueperp :: Num a => V2 a -> V2 a
#

the counter-clockwise perpendicular vector

Example1 expression
perp $ V2 10 20V2 (-20) 10
valuecrossZ :: Num a => V2 a -> V2 a -> a
#

The Z-component of the cross product of two vectors in the XY-plane.

Example1 expression
crossZ (V2 1 0) (V2 0 1)1