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