linear-1.4: Linear Algebra

Portabilitynon-portable
Stabilityexperimental
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellSafe-Inferred

Linear.Core

Description

Corepresentable functors as vector spaces

Synopsis

Documentation

class Functor f => Core f whereSource

A Functor f is corepresentable if it is isomorphic to (x -> a) for some x. Nearly all such functors can be represented by choosing x to be the set of lenses that are polymorphic in the contents of the Functor, that is to say x = Rep f is a valid choice of x for (nearly) every Representable Functor.

Methods

core :: ((forall x. Lens' (f x) x) -> a) -> f aSource

Form a structure by applying the given function to lenses focused on its holes.

Instances

column :: Core f => LensLike (Context a b) s t a b -> Lens (f s) (f t) (f a) (f b)Source

This is a generalization of inside to work over any corepresentable Functor.

 column :: Core f => Lens s t a b -> Lens (f s) (f t) (f a) (f b)

In practice it is used to access a column of a matrix.

>>> V2 (V3 1 2 3) (V3 4 5 6) ^._x
V3 1 2 3
>>> V2 (V3 1 2 3) (V3 4 5 6) ^.column _x
V2 1 4