Frederik Eaton frederik at a5.repetae.net
Sat Apr 15 16:09:20 EDT 2006

```Yes, certainly... Otherwise the library would not be much use! If it
seems counterintuitive, as it did to me at first, you should check out
the "Implicit Configurations" paper, which uses modular arithmetic as
an example. My version of their code is in

http://ofb.net/~frederik/futility/src/Prepose.hs

The function I mainly use is:

reifyIntegral :: Integral a => a -> (forall s. ReflectNum s => s -> w) -> w

which turns an integral value into a type of the ReflectNum class
which represents that value, and calls the provided polymorphic
function with a dummy value (actually 'undefined') of that type; then
returning the function's result.

Frederik

On Sat, Apr 15, 2006 at 06:14:44PM +0200, Alberto Ruiz wrote:
> On Friday 14 April 2006 17:02, Frederik Eaton wrote:
> > An index-aware linear algebra library in Haskell
>
> Excellent work!
>
> Is it possible to create a vector or matrix whose size is not known at compile
> time?
>
> > - Due to the need to specify index types at some point, input of
> > vectors is difficult. I have provided two functions in Fu.Vector.Base
> > which should cover most of the cases:
> >
> > listVec :: Vector v e => [e] -> (forall n . (ReflectNum n) => v (L n) -> w)
> > -> w
> > listMat :: Vector v e => [[e]] ->
> >     (forall n m . (ReflectNum n, ReflectNum m) => v (L m, L n) -> w) -> w
> >
> > However, these aren't useful in interactive situations. So I have also
> > provided some template-haskell routines
> >
> >   http://ofb.net/~frederik/futility/src/Vector/Template.hs
> >
> > which can be used to instantiate vectors directly. For example:
>
> (In examples.hs):
>
> >-- matrix with elements of type Double
> >v6 = trans \$(dAM [[1,2,3,4]])
> >
> >v7 = \$(dAM [[1,0,0],[0,1,0],[0,0,1],[1,1,1]])
>
> --
> Alberto
>

--
http://ofb.net/~frederik/
```