I need an alternative to reverseT that doesn't use toList.
Obviously, this code is incorrect, but demonstrates the idea I was pursuing:
reverseF
:: (Foldable f, Representable f, Num (Rep f))
=> f a -> f a
reverseF f = tabulate $ \ix -> index f $ last - ix
where last = length f - 1 -- Incorrect; length -> ?
Does anyone know what I can replace length with, so as to get the last index element offered by tabulate when building an f?
You could assume and use
Bounded (Rep f)andEnum (Rep f), i.e., convertRep ftoIntwithtoEnum, change indices by someIntarithmetic that usesIntcounterparts ofminBoundandmaxBoundonRep f(or assumefromEnum minBound == 0), and finally fromIntback toRep fwithfromEnum.