[GHC] #3315: Add generalised "lookup" function

GHC trac at galois.com
Sat Jun 20 06:52:29 EDT 2009


#3315: Add generalised "lookup" function
-----------------------------+----------------------------------------------
Reporter:  skorpan           |          Owner:                  
    Type:  feature request   |         Status:  new             
Priority:  normal            |      Component:  Prelude         
 Version:  6.11              |       Severity:  minor           
Keywords:                    |       Testcase:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
-----------------------------+----------------------------------------------
 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
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3315>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list