[Haskell-cafe] cap 3: stopping thread 3 (stackoverflow)
Johannes Waldmann
waldmann at imn.htwk-leipzig.de
Tue Jun 7 19:27:53 CEST 2011
> I came up with this using immutable unboxed arrays [...]
> sss :: Int -> Int -> UArray Int Int -> O
Nice. - Although what you do here is actually "C programming":
you have a "global" array, and work on its indices.
Actually you always have a pair of indices, denoting a subsequence.
It would be nice if the program text showed this directly, using
data Seq a = Seq
{ contents :: ! ( Array Int a )
, lo :: ! Int, hi :: ! Int
}
and then all (well, most) of the methods in Data.Sequence,
implemented in such a way that the "contents" is just copied around, e.g.,
splitAt :: Int -> Seq a -> ( Seq a, Seq a )
splitAt k s = ( s { hi = lo s + k - 1 } , s { lo = lo s + k } )
and then a Foldable instance,
and then ... specializations for the types that
are allowed as elements of an unboxed array.
(and that's the part that does not seem to be working easily.
Can this be done by some specialize/rules magic in GHC?)
> > PS: I keep telling my students that "structural parallel programming"
> I don't know that term, so I might be missing the point. Sorry if so.
Your code is fine. - Some pointers are here:
http://www.iis.sinica.edu.tw/~scm/2008/constructing-list-homomorphism/
More information about the Haskell-Cafe
mailing list