Kind/book/List.find.kind2
2024-02-12 22:39:06 -03:00

16 lines
365 B
Plaintext

List.find
: ∀(A: *)
∀(cond: ∀(x: A) Bool)
∀(list: (List A))
(Maybe A)
= λA λcond λlist
let P = λx(Maybe A)
let cons = λhead λtail
let found = (cond head)
let P = λx(Maybe A)
let true = (Maybe.some A head)
let false = (List.find A cond tail)
(~found P true false)
let nil = (Maybe.none A)
(~list P cons nil)