Christopher Jeris wrote:
>
> Here is another one for haskell-newbies, really. :)
>
> Does anybody else wish for Ix.increment and Ix.decrement ? I have been
> writing some matrix code and whenever I want to refer to "the next row
> down" I have been writing (range (i0,i1))!!1, which seems inelegant.
> But, it's so simple that there must be a good reason why these functions
> are not there ?
>
> thanks & peace,
> Chris Jeris (writes his Java programs in Haskell first)
No way to get around this, really, with just the Ix class. However, you
could try to restrict the type to be of class Enum, in which case you
can use the `succ' function. Or, you could try something like:
> succIx :: Ix a => a -> a -> a
> succIx max x = (range (x,max))!!1
> ...
> fooSucc = succIx maxFoo
> ...
> nextFoo = fooSucc x