>>> 3 `elem` [] False
>>> 3 `elem` [1,2] False
>>> 3 `elem` [1,2,3,4,5] TrueFor infinite structures, the default implementation of elem terminates if the sought-after value exists at a finite distance from the left side of the structure:
>>> 3 `elem` [1..] True
>>> 3 `elem` ([4..] ++ [3]) * Hangs forever *
>>> 3 `elem` [] False
>>> 3 `elem` [1,2] False
>>> 3 `elem` [1,2,3,4,5] True
>>> 3 `elem` [1..] True
>>> 3 `elem` [4..] * Hangs forever *
>>> elemIndex 4 [0..] Just 4
>>> elemIndex 'o' "haskell" Nothing
>>> elemIndex 0 [1..] * hangs forever *
>>> elemIndices 'o' "Hello World" [4,7]
>>> elemIndices 1 [1, 2, 3, 1, 2, 3] [0,3]
>>> 3 `notElem` [] True
>>> 3 `notElem` [1,2] True
>>> 3 `notElem` [1,2,3,4,5] FalseFor infinite structures, notElem terminates if the value exists at a finite distance from the left side of the structure:
>>> 3 `notElem` [1..] False
>>> 3 `notElem` ([4..] ++ [3]) * Hangs forever *
>>> bielem 42 (17, 42) True
>>> bielem 42 (17, 43) False
>>> bielem 42 (Left 42) True
>>> bielem 42 (Right 13) False
>>> bielem 42 (BiList [1..5] [1..100]) True
>>> bielem 42 (BiList [1..5] [1..41]) False
peekElemOff addr idx = IOExts.fixIO $ \result -> peek (addr `plusPtr` (idx * sizeOf result))Note that this is only a specification, not necessarily the concrete implementation of the function.
pokeElemOff addr idx x = poke (addr `plusPtr` (idx * sizeOf x)) x