snoyberg / mono-traversable

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

`index` i === listToMaybe for negative indices #114

Closed richsmith92 closed 1 month ago

richsmith92 commented 7 years ago
> index [1,2,3] (-1)
Just 1
> index [] (-1)
Nothing

I expected Nothing to be the result in both cases. Can we consider tis behavior a bug, or there is some reasoning behind it?

snoyberg commented 7 years ago

I don't have a strong feeling on this in any direction, I'd be OK with changing it (or even throwing an exception as invalid input).

BebeSparkelSparkel commented 1 month ago

fixed by #173