[Haskell-cafe] debugging vector index out of range
David Feuer
david.feuer at gmail.com
Wed Nov 23 04:38:10 UTC 2016
There may well be a way to get what you want. I don't personally know
much about the newly improved debugging features. What I do know is
that if you have a giant blob of code and you're getting a vector
indexing error *somewhere*, then you're doing things wrong. Vector
indexing is error-prone. You should really avoid doing it any more
than necessary. Try to confine indexing operations to simple functions
implementing higher-level vector operations, and write QuickCheck
and/or SmallCheck tests for those functions. When possible, prefer the
high-level operations already available in the vector package (and
even the vector-algorithms package). Another idea I've been playing
with lately is using reflection to tie an index into a vector to the
size of that vector. I can create an "index" that I know is in bounds,
and then pass it around freely while the type system keeps track of
the fact that it's in bounds. I don't think this sort of thing is
terribly practical at the moment, but it may become more practical as
Haskell gets closer to dependent types.
On Mon, Nov 21, 2016 at 1:01 AM, <briand at aracnet.com> wrote:
> Hi,
>
> I'm getting a vector index out of range.
>
> I'm trying to figure out how to get something to give the line number of the offender.
>
> However, attempting to use 'ghc -prof' gives me a problem because several of the libraries I'm using don't have profiled versions.
>
> Is there some way for me to debug this ? That is some way to debug it without inserting debug traces everywhere checking the vector indices ?
>
> Thanks.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
More information about the Haskell-Cafe
mailing list