prelate-0.7.0.1: A Prelude
Safe HaskellSafe-Inferred
LanguageGHC2021

Prelate.Data.List

Description

List reexports from extra

Synopsis

Documentation

firstJust :: (a -> Maybe b) -> [a] -> Maybe b #

Find the first element of a list for which the operation returns Just, along with the result of the operation. Like find but useful where the function also computes some expensive information that can be reused. Particular useful when the function is monadic, see firstJustM.

firstJust id [Nothing,Just 3]  == Just 3
firstJust id [Nothing,Nothing] == Nothing