import { curry, Predicate } from '@typed/lambda' import { Just, Maybe, Nothing } from '@typed/maybe' export const find: { (predicate: Predicate, iterable: Iterable): Maybe (predicate: Predicate): (iterable: Iterable) => Maybe } = curry(__find) function __find(predicate: Predicate, iterable: Iterable): Maybe { for (const value of iterable) { if (predicate(value)) { return Just.of(value) } } return Nothing }