Skip to content

Add generalised "lookup" function

I think it would be very nice to have a default implementation of a generalised lookup function, such as lookupWith. The code I'm currently using is very simple and straight-forward:

lookupWith :: (a -> Bool) -> [(a, b)] -> Maybe b
lookupWith _ []          = Nothing
lookupWith p ((x, y):xs) | p x = Just y
                         | otherwise = lookupWith p xs
Trac metadata
Trac field Value
Version 6.11
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Prelude
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information