tensor-0.2.0: A completely type-safe library for linear algebra

Data.TypeList

Description

The Module `Data.TypeList` is a collection of classes to manipulate lists of types, a.k.a. heterogeneous lists. Check the module `Data.TypeList.MultiIndex` for a concrete implementation of `TypeList`.

Synopsis

Documentation

class TypeList l whereSource

Every `TypeList` has a `Length`. The `Length` is actually a type, and should be a `Cardinal` (see `Data.Cardinal`).

Associated Types

type Length l Source

Methods

length :: l -> Length lSource

Instances

 TypeList Nil TypeList l => TypeList (:|: e l)

class TypeList l => HeadTail l whereSource

Associated Types

type Tail l Source

Methods

tail :: l -> Tail lSource

(.|.) :: Head l -> Tail l -> lSource

Instances

 (TypeList (:|: e l), TypeList l) => HeadTail (:|: e l)

class Component l n whereSource

Extracts the `n`-th component of the list `l`

Associated Types

type l :!!: n Source

Methods

(!!) :: l -> n -> l :!!: nSource

The second argument of `!!` should always be ```undefined :: n```.

partialMap :: n -> ((l :!!: n) -> l :!!: n) -> l -> lSource

Applies the given function to one component of the list.

Instances

 HeadTail l => Component l Zero (HeadTail l, Component (Tail l) n) => Component l (Succ n)

class (TypeList l, TypeList l') => AppendList l l' whereSource

A class for appending two `TypeList`s. The result of appending `l` and `l'` has type `l :++: l'`.

Associated Types

type l :++: l' Source

Methods

(<++>) :: l -> l' -> l :++: l'Source

Instances

 (TypeList Nil, TypeList l) => AppendList Nil l (TypeList (:|: e l), TypeList l', AppendList l l') => AppendList (:|: e l) l'

class (Cardinal n, TypeList l) => TakeList n l whereSource

This is does for `TakeList` what `take` does for ordinary lists.

Associated Types

type Take n l Source

Methods

take :: n -> l -> Take n lSource

Instances

 TakeList Zero Nil (Cardinal Zero, TypeList (:|: e l), TakeList Zero l) => TakeList Zero (:|: e l) (Cardinal (Succ n), TypeList (:|: e l), TakeList n l) => TakeList (Succ n) (:|: e l)

class (Cardinal n, TypeList l) => DropList n l whereSource

This is does for `TakeList` what `drop` does for ordinary lists.

Associated Types

type Drop n l Source

Methods

drop :: n -> l -> Drop n lSource

Instances

 DropList Zero Nil (Cardinal Zero, TypeList (:|: e l), DropList Zero l) => DropList Zero (:|: e l) (Cardinal (Succ n), TypeList (:|: e l), DropList n l) => DropList (Succ n) (:|: e l)

class (TypeList l, TypeList l') => TailRevList l l' whereSource

Reverse `l` and append it in front of `l'`.

Associated Types

type TailRev l l' Source

Methods

rev :: l -> l' -> TailRev l l'Source

Instances

 (TypeList Nil, TypeList l) => TailRevList Nil l (TypeList (:|: e l), TailRevList l (:|: e l'), TypeList l') => TailRevList (:|: e l) l'

class TypeList l => ReverseList l whereSource

Reverse the `TypeList` `l`, and get `Reverse l`.

Associated Types

type Reverse l Source

Methods

reverse :: l -> Reverse lSource

Instances

 ReverseList Nil (TypeList (:|: e l), TailRevList l Nil, TailRevList (:|: e l) Nil) => ReverseList (:|: e l)

class JoinList n l l' whereSource

Join together `TypeList`s `l` and `l'` where the last `n` types of `l` coincide with the first `n` types of `l'`. The result has a the common `n` types eliminated.

Associated Types

type Join n l l' Source

Methods

join :: n -> l -> l' -> Join n l l'Source

Instances

 (ReverseList (Drop n (Reverse l)), DropList n (Reverse l), ReverseList l, AppendList (Reverse (Drop n (Reverse l))) (Drop n l'), DropList n l', ~ * (Reverse (Take n (Reverse l))) (Take n l')) => JoinList n l l'

class Extend l l' whereSource

Extend the list `l` to `l'` by adding the necessary extension `Ext l l'`.

Associated Types

type Ext l l' Source

Methods

extend :: l -> Ext l l' -> l'Source

Instances

 Extend Nil l' Extend l l' => Extend (:|: e l) (:|: e l')