fold
The original state if the option is None, otherwise it returns the updated state with the folder and the option value.
Type
type fold = <T, S>(folder: Folder<T, S>) => (state: S) => (option: Option<T>) => S
Examples
import {fold, Some} from 'fnxt/option';
const sum = fold((a:number, b:number) => a + b);
sum(1)(Some(42)) // -> Some(43)
import {fold, None} from 'fnxt/option';
const sum = fold((a:number, b:number) => a + b);
sum(1)(None) // -> 1