samhh / fp-ts-std

The missing pseudo-standard library for fp-ts.
https://samhh.github.io/fp-ts-std/
MIT License
207 stars 27 forks source link

Apply many Alternative functions #124

Closed samhh closed 2 years ago

samhh commented 2 years ago
firstGood :: Alternative m => [a -> m b] -> a -> m b
firstGood [] _     = empty
firstGood (f:gs) x = f x <|> firstGood gs x
samhh commented 2 years ago

https://github.com/samhh/fp-ts-std/commit/c96a0d8dd53c8fb98291246fe82538e3ca1c5155

I think it doesn't exist in Haskell because of Haskell's laziness, allowing you to just flap and choice (altAll).