import { Arity1, curry } from '@typed/lambda'
import { Just } from './Just'
import { map } from './map'
import { Maybe } from './Maybe'
import { withDefault } from './withDefault'
/**
* Used for performing side-effects with a Maybe
*/
export const unwrap: {
(fn: Arity1, maybe: Just): B
(fn: Arity1, maybe: Maybe): B | null
(fn: Arity1): {
(maybe: Just): B
(maybe: Maybe): B | null
}
} = curry((fn: Arity1, maybe: Maybe): B | null => withDefault(null, map(fn, maybe)))