snoyberg / mono-traversable

Type classes for mapping, folding, and traversing monomorphic containers
152 stars 63 forks source link

Make index work on negative indices #173

Closed sniperrifle2004 closed 5 years ago

sniperrifle2004 commented 5 years ago

All implementations in Data.Sequences return Nothing now. This conforms to the (partial) behaviour of the underlying type's corresponding function, as confirmed by the failing tests when the nonnegative modifier was removed. When possible index is implemented using the underlying's type corresponding total function.

The default implementation now also returns Nothing for negative indices. Returning (headMay . drop) besides being strange, also did not correspond to the partial behaviour of the underlying types.

Closes #172 and #114

snoyberg commented 5 years ago

Looks like CI is busted for other reasons, I'll need to look into that later. Anyway, this seems to be working from the test cases that did pass. Thanks!