import { Mapper } from "@siteimprove/alfa-mapper" ; import { Reducer } from "@siteimprove/alfa-reducer" ; public export type Thunk < T = void > = ( ) => T ; public export namespace Thunk { export function of < T > ( value ) { return ( ) => value ; } export function map < T , U > ( thunk , mapper ) { return ( ) => mapper ( thunk ( ) ) ; } export function flatMap < T , U > ( thunk , mapper ) { return ( ) => mapper ( thunk ( ) ) ( ) ; } export function reduce < T , U > ( thunk , reducer , accumulator ) { return reducer ( accumulator , thunk ( ) ) ; } }