elemIndex -package:utf8-string package:rio

O(n) The elemIndex function returns the index of the first element in the given ByteString which is equal to the query element, or Nothing if there is no such element. This implementation uses memchr(3).
O(n) The elemIndex function returns the index of the first element in the given ByteString which is equal to the query element, or Nothing if there is no such element. This implementation uses memchr(3).
The elemIndex function returns the index of the first element in the given list which is equal (by ==) to the query element, or Nothing if there is no such element. For the result to be Nothing, the list must be finite.

Examples

>>> elemIndex 4 [0..]
Just 4
>>> elemIndex 'o' "haskell"
Nothing
>>> elemIndex 0 [1..]
* hangs forever *
O(n) The elemIndexEnd function returns the last index of the element in the given ByteString which is equal to the query element, or Nothing if there is no such element. The following holds:
elemIndexEnd c xs = case elemIndex c (reverse xs) of
Nothing -> Nothing
Just i  -> Just (length xs - 1 - i)
O(n) The elemIndexEnd function returns the last index of the element in the given ByteString which is equal to the query element, or Nothing if there is no such element. The following holds:
elemIndexEnd c xs = case elemIndex c (reverse xs) of
Nothing -> Nothing
Just i  -> Just (length xs - 1 - i)
elemIndexL finds the leftmost index of the specified element, if it is present, and otherwise Nothing.
elemIndexR finds the rightmost index of the specified element, if it is present, and otherwise Nothing.