import { Maybe } from './Maybe' ; import { curry2 } from '@typed/functions' ; import { fromJust } from './fromJust' ; import { isNothing } from './isNothing' ; name export const chain = curry2 ( __chain ) ; function __chain < A , B > ( f , maybe ) { return isNothing ( maybe ) ? maybe : f ( fromJust ( maybe ) ) ; } export interface MaybeChain { < A , B > ( f , maybe ) : Maybe < B > ; < A , B > ( f ) : ( maybe : Maybe < A > ) => Maybe < B > ; }