
On 2016-11-30 04:08 AM, Baldur Blöndal wrote:
What about functions that aren't expected to preserve structure like ‘lookup’ and (new) suggestions
lookup :: Eq a => k -> Foldable f => f (k, v) -> Maybe v lookup = lookupOf folded
-1. It needs to die.
elemIndex :: Eq a => a -> Foldable f => f a -> Maybe Int elemIndex = elemIndexOf folded
elemIndices :: Eq a => a -> Foldable f => f a -> Maybe Int elemIndices = elemIndicesOf folded
findIndex :: (a -> Bool) -> Foldable f => f a -> Maybe Int findIndex = findIndexOf folded
findIndices :: (a -> Bool) -> Foldable f => f a -> [Int] findIndices = findIndicesOf folded
I'm +0.5 on these but only if they come in together with the (!!) operator, which should then be added as a Foldable class method to allow for optimizations. Without (!!) there'd be no way to express the laws these operations need to satisfy.