[Haskell-cafe] computation over containers, greatly simplified notation.
Takayuki Muranushi
muranushi at gmail.com
Wed Nov 28 18:57:03 CET 2012
Dear all,
I came up with an idea to greatly simplify some kinds of array
computations. It should work well with many kinds of arrays. Is this new?
https://gist.github.com/4162375
These few days, I've been trying to rewrite a hydrodynamic simulation code
that used Data.Vector (~250 lines), to Repa [1] . It seemed promising, but
soon I realized that I needed to use Repa.map and Repa.zipWith almost
everywhere. I need careful thinking to transform every lines (that used
vector's indexing) to Repa's point-free stile. Is there any better ways?
Then I realized that I was the author of Paraiso [2], a DSL for stencil
computation. One of its feature is to write down array computation just as
if it were scalar computation.
Basically what I need is ZipList-like Applicative instances for vectors and
Repa arrays. Why not they support ZipVector? Because 'pure' of zipList was
an infinite list and you can't do infinite vectors. Then I came up with
this idea.
https://gist.github.com/4162375
the wrapper W does several things: it represents the 'pure,' homogeneous
array in a space-efficient manner, and also serves as a newtype-wrapper of
Num (and possibly Fractional, Floating...) instances.
Questions are: is this technology new? or promising? doomed?
It seems to me like a free-Applicative, like the free-Monad theory. Are
they related?
The function 'backend' helps to mix in the non-zip-like computations. How
can we remove the 'undefined' in the 'backend?'
Some of Repa computations are Monads. W needs to be a monad transformer to
incooperate this.
Also I'm grateful to past cafe discussion on existing Zippable
implementations [3][4] .
[1] hackage.haskell.org/package/repa
[2] http://hackage.haskell.org/package/Paraiso
[3] http://www.haskell.org/pipermail/haskell-cafe/2009-July/064403.html
[4]
http://hackage.haskell.org/packages/archive/category-extras/latest/doc/html/Control-Functor-Zip.html
--
Takayuki MURANUSHI
The Hakubi Center for Advanced Research, Kyoto University
http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121129/d68c5b1f/attachment.htm>
More information about the Haskell-Cafe
mailing list