Type-safe multi-dimensional array operations in Haskell, wrapping parts of the API of Repa to keep track of each array dimension size (not just number of dimensions) in the type system, preventing some common run-time errors (which become compile-time errors).
Most definitions have the same names as Repa, so import qualified if you need both.
repa-sized shape uses
ZZ ::. 1 ::. 2 ::. 3 (type-level
Repa shape uses
Z :. Int :. Int :. Int,
runtime indices use
Z :. 0 :. 1 :. 2.
This is because qualified imports would make it painful when using both in the same source code file (as may be common).
WithShape constructor is exported.
If you use it carelessly you can fake any array dimensions you like,
But it is necessary for wrapping third party libraries that extend Repa…
Some runtime indices (e.g. in
are not statically checked for safety,
so runtime errors are still possible
if you make a mistake.
Some operations (e.g.
select, reading image files from disk, …)
can produce differently sized arrays depending on data
that is not known at compile time.
This is handled in
repa-sized via the
which is not very convenient to use.
Some error messages are bad
(e.g. “can’t match False with True” in
the region extends outside the bounds of the array).
Some small features not found in Repa. Subject to change (e.g. removal to a different library).
bop is like
but it repeats (cycles in each dimension)
the right hand argument to match
the dimensions of the left hand argument,
which is also the dimensions of the output.
The dimensionality of the right hand side may be less than the left hand side, earlier dimensions are assumed to be 1 and are cycled also.
zipWith which intersects the dimensions with
Inspired by GridFlow’s
Turn an array into an array of arrays.
Turn an array of arrays into an array.
git clone https://code.mathr.co.uk/repa-sized.git
Or, soon (not yet published to Hackage), add
repa-sized >= 1 && < 1.1,
to the build depends in your
cabal update && cabal repl or similar.
Copyright (C) 2023 Claude Heiland-Allen
License: GNU Affero General Public License, version 3 only.
(If this license bothers you, you can pay me to change it.)