mirror of
https://github.com/ekmett/speculation.git
synced 2024-11-23 02:41:58 +03:00
factor out First
This commit is contained in:
parent
16803ee79e
commit
a7d55d07cb
@ -418,5 +418,5 @@ find :: (Foldable t, Eq a) => (Int -> Maybe a) -> (a -> Bool) -> t a -> Maybe a
|
||||
find = findBy (==)
|
||||
|
||||
findBy :: Foldable t => (Maybe a -> Maybe a -> Bool) -> (Int -> Maybe a) -> (a -> Bool) -> t a -> Maybe a
|
||||
findBy cmp g p = getFirst . foldMapBy (on cmp getFirst) (First . g) (\x -> if p x then First (Just x) else First Nothing)
|
||||
findBy cmp g p = getFirst . foldMapBy (on cmp getFirst) (First . g) (\x -> First (if p x then Just x else Nothing))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user