{- Transform an `Optional` value with a function Examples: ``` ./map Natural Bool Natural/even ([ 3 ] : Optional Natural) = [ False ] : Optional Bool ./map Natural Bool Natural/even ([] : Optional Natural) = [] : Optional Bool ``` -} let map : ∀(a : Type) → ∀(b : Type) → (a → b) → Optional a → Optional b = λ(a : Type) → λ(b : Type) → λ(f : a → b) → λ(o : Optional a) → Optional/fold a o (Optional b) (λ(x : a) → [ f x ] : Optional b) ([] : Optional b) in map