concat-examples-0.3.0.0: Some examples of compiling to categories
Safe HaskellSafe-Inferred
LanguageHaskell2010

ConCat.Free.VectorSpace

Description

Vector spaces as zippable functors

Synopsis

Documentation

zeroV :: (Pointed f, Num a) => f a Source #

scaleV :: (Functor f, Num s) => s -> f s -> f s Source #

Scale a vector

(*^) :: (Functor f, Num s) => s -> f s -> f s infixl 7 Source #

Scale a vector

negateV :: (Functor f, Num s) => f s -> f s Source #

Negate a vector

addV :: (Zip f, Num s) => f s -> f s -> f s Source #

Add vectors

(^+^) :: (Zip f, Num s) => f s -> f s -> f s infixl 6 Source #

Add vectors

subV :: (Zip f, Num s) => f s -> f s -> f s Source #

Subtract vectors

(^-^) :: (Zip f, Num s) => f s -> f s -> f s infixl 6 Source #

Subtract vectors

dotV :: forall s f. (Zip f, Foldable f, Num s) => f s -> f s -> s Source #

Inner product

(<.>) :: forall s f. (Zip f, Foldable f, Num s) => f s -> f s -> s infixl 7 Source #

Inner product

normSqr :: forall s f. (Functor f, Foldable f, Num s) => f s -> s Source #

Norm squared

distSqr :: forall s f. (Zip f, Foldable f, Num s) => f s -> f s -> s Source #

Distance squared

outerV :: (Num s, Functor f, Functor g) => g s -> f s -> g (f s) Source #

Outer product

(>.<) :: (Num s, Functor f, Functor g) => g s -> f s -> g (f s) infixl 7 Source #

Outer product

normalizeV :: (Functor f, Foldable f, Floating a) => f a -> f a Source #

Normalize a vector (scale to unit magnitude)

data SumV f a Source #

Constructors

SumV (f a) 

Instances

Instances details
HasV s (f a) => HasV s (SumV f a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (SumV f a) :: Type -> Type Source #

Methods

toV :: SumV f a -> V s (SumV f a) s Source #

unV :: V s (SumV f a) s -> SumV f a Source #

(Zeroable f, Zip f, Num a) => Monoid (SumV f a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Methods

mempty :: SumV f a Source #

mappend :: SumV f a -> SumV f a -> SumV f a Source #

mconcat :: [SumV f a] -> SumV f a Source #

(Zeroable f, Zip f, Num a) => Semigroup (SumV f a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Methods

(<>) :: SumV f a -> SumV f a -> SumV f a Source #

sconcat :: NonEmpty (SumV f a) -> SumV f a Source #

stimes :: Integral b => b -> SumV f a -> SumV f a Source #

HasRep (SumV f a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type Rep (SumV f a) Source #

Methods

repr :: SumV f a -> Rep (SumV f a) Source #

abst :: Rep (SumV f a) -> SumV f a Source #

type V s (SumV f a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

type V s (SumV f a) = V s (Rep (SumV f a))
type Rep (SumV f a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

type Rep (SumV f a) = f a

sumV :: (Functor m, Foldable m, Zeroable n, Zip n, Num a) => m (n a) -> n a Source #

type RepHasV s a = (HasRep a, HasV s (Rep a), V s a ~ V s (Rep a)) Source #

class HasV s a where Source #

Minimal complete definition

Nothing

Associated Types

type V s a :: * -> * Source #

type V s a = V s (Rep a)

Methods

toV :: a -> V s a s Source #

default toV :: RepHasV s a => a -> V s a s Source #

unV :: V s a s -> a Source #

default unV :: RepHasV s a => V s a s -> a Source #

Instances

Instances details
HasV Double Double Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V Double Double :: Type -> Type Source #

HasV Float Float Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V Float Float :: Type -> Type Source #

HasV s () Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s () :: Type -> Type Source #

Methods

toV :: () -> V s () s Source #

unV :: V s () s -> () Source #

OpCon (:*) (Sat (HasV s) :: Type -> Type) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Methods

inOp :: forall (a :: k) (b :: k). (Sat (HasV s) a && Sat (HasV s) b) |- Sat (HasV s) (a :* b) Source #

HasV s a => HasV s (Product a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (Product a) :: Type -> Type Source #

Methods

toV :: Product a -> V s (Product a) s Source #

unV :: V s (Product a) s -> Product a Source #

HasV s a => HasV s (Sum a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (Sum a) :: Type -> Type Source #

Methods

toV :: Sum a -> V s (Sum a) s Source #

unV :: V s (Sum a) s -> Sum a Source #

HasV s a => HasV s (Par1 a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (Par1 a) :: Type -> Type Source #

Methods

toV :: Par1 a -> V s (Par1 a) s Source #

unV :: V s (Par1 a) s -> Par1 a Source #

HasV s a => HasV s (Pair a) Source # 
Instance details

Defined in ConCat.Pair

Associated Types

type V s (Pair a) :: Type -> Type Source #

Methods

toV :: Pair a -> V s (Pair a) s Source #

unV :: V s (Pair a) s -> Pair a Source #

HasV s (U1 a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (U1 a) :: Type -> Type Source #

Methods

toV :: U1 a -> V s (U1 a) s Source #

unV :: V s (U1 a) s -> U1 a Source #

(HasV s a, HasV s b) => HasV s (a :* b) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (a :* b) :: Type -> Type Source #

Methods

toV :: (a :* b) -> V s (a :* b) s Source #

unV :: V s (a :* b) s -> a :* b Source #

(HasV s a, HasV s b) => HasV s (a :+ b) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (a :+ b) :: Type -> Type Source #

Methods

toV :: (a :+ b) -> V s (a :+ b) s Source #

unV :: V s (a :+ b) s -> a :+ b Source #

HasV s (f a) => HasV s (SumV f a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (SumV f a) :: Type -> Type Source #

Methods

toV :: SumV f a -> V s (SumV f a) s Source #

unV :: V s (SumV f a) s -> SumV f a Source #

(HasV s b, KnownNat n) => HasV s (Vector n b) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (Vector n b) :: Type -> Type Source #

Methods

toV :: Vector n b -> V s (Vector n b) s Source #

unV :: V s (Vector n b) s -> Vector n b Source #

HasV s b => HasV s (a -> b) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (a -> b) :: Type -> Type Source #

Methods

toV :: (a -> b) -> V s (a -> b) s Source #

unV :: V s (a -> b) s -> a -> b Source #

HasV s (Rep (L s a b)) => HasV s (L s a b) Source # 
Instance details

Defined in ConCat.Free.LinearRow

Associated Types

type V s (L s a b) :: Type -> Type Source #

Methods

toV :: L s a b -> V s (L s a b) s Source #

unV :: V s (L s a b) s -> L s a b Source #

(HasV s a, HasV s b, HasV s c) => HasV s (a, b, c) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (a, b, c) :: Type -> Type Source #

Methods

toV :: (a, b, c) -> V s (a, b, c) s Source #

unV :: V s (a, b, c) s -> (a, b, c) Source #

(HasV s (f a), HasV s (g a)) => HasV s ((f :*: g) a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s ((f :*: g) a) :: Type -> Type Source #

Methods

toV :: (f :*: g) a -> V s ((f :*: g) a) s Source #

unV :: V s ((f :*: g) a) s -> (f :*: g) a Source #

(HasV s a, HasV s b, HasV s c, HasV s d) => HasV s (a, b, c, d) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s (a, b, c, d) :: Type -> Type Source #

Methods

toV :: (a, b, c, d) -> V s (a, b, c, d) s Source #

unV :: V s (a, b, c, d) s -> (a, b, c, d) Source #

HasV s (g (f a)) => HasV s ((g :.: f) a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Associated Types

type V s ((g :.: f) a) :: Type -> Type Source #

Methods

toV :: (g :.: f) a -> V s ((g :.: f) a) s Source #

unV :: V s ((g :.: f) a) s -> (g :.: f) a Source #

inV :: forall s a b. (HasV s a, HasV s b) => (a -> b) -> V s a s -> V s b s Source #

onV :: forall s a b. (HasV s a, HasV s b) => (V s a s -> V s b s) -> a -> b Source #

onV2 :: forall s a b c. (HasV s a, HasV s b, HasV s c) => (V s a s -> V s b s -> V s c s) -> a -> b -> c Source #

type IsScalar s = (HasV s s, V s s ~ Par1) Source #

class VComp h where Source #

Methods

vcomp :: forall s c. HasV s c :- (HasV s (h c), V s (h c) ~ (h :.: V s c)) Source #

Instances

Instances details
VComp ((->) a) Source # 
Instance details

Defined in ConCat.Free.VectorSpace

Methods

vcomp :: HasV s c :- (HasV s (a -> c), V s (a -> c) ~ ((->) a :.: V s c)) Source #