Portability | non-portable |
---|---|

Stability | experimental |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Safe Haskell | Trustworthy |

n-D Vectors

- data V n a
- int :: Int -> TypeQ
- dim :: forall n a. Dim n => V n a -> Int
- class Dim n where
- reflectDim :: p n -> Int

- reifyDim :: Int -> (forall n. Dim n => Proxy n -> r) -> r
- reifyVector :: forall a r. Vector a -> (forall n. Dim n => V n a -> r) -> r
- fromVector :: forall n a. Dim n => Vector a -> Maybe (V n a)

# Documentation

Dim n => Monad (V n) | |

Functor (V n) | |

Dim n => Applicative (V n) | |

Foldable (V n) | |

Traversable (V n) | |

Dim n => Distributive (V n) | |

Dim n => Representable (V n) | |

Apply (V n) | |

Bind (V n) | |

Dim n => Additive (V n) | |

Dim n => Metric (V n) | |

Dim n => Trace (V n) | |

Dim n => Affine (V n) | |

Eq a => Eq (V n a) | |

(Dim n, Fractional a) => Fractional (V n a) | |

(Dim n, Num a) => Num (V n a) | |

Ord a => Ord (V n a) | |

Read a => Read (V n a) | |

Show a => Show (V n a) | |

Generic (V n a) | |

(Dim n, Storable a) => Storable (V n a) | |

Ixed (V n a) | |

(Dim n, Epsilon a) => Epsilon (V n a) | |

Dim n => Dim (V n a) |

This can be used to generate a template haskell splice for a type level version of a given `int`

.

This does not use GHC TypeLits, instead it generates a numeric type by hand similar to the ones used in the "Functional Pearl: Implicit Configurations" paper by Oleg Kiselyov and Chung-Chieh Shan.

`instance Num (Q Exp)`

provided in this package allows writing `$(3)`

instead of `$(int 3)`

. Sometimes the two will produce the same
representation (if compiled without the `-DUSE_TYPE_LITS`

preprocessor
directive).

reifyVector :: forall a r. Vector a -> (forall n. Dim n => V n a -> r) -> rSource