export interface DoF { Do: HKT.Kind bind: ( name: N extends keyof Scope ? { error: `binding name '${N}' already in use` } : N, fn: (_: Scope) => HKT.Kind ) => ( self: HKT.Kind ) => HKT.Kind< F, R & R0, E | E0, { readonly [k in N | keyof Scope]: k extends keyof Scope ? Scope[k] : A } > bindValue: ( name: N extends keyof Scope ? { error: `binding name '${N}' already in use` } : N, fn: (_: Scope) => B ) => ( self: HKT.Kind ) => HKT.Kind< F, R, E, { readonly [k in N | keyof Scope]: k extends keyof Scope ? Scope[k] : B } > } /** * @tsplus static DSL getDoF */ export function getDoF(F: Monad): DoF { return { Do: DSL.succeedF(F)({}), bind: ( name: N extends keyof Scope ? { error: `binding name '${N}' already in use` } : N, f: (_: Scope) => HKT.Kind ) => (self: HKT.Kind): HKT.Kind< F, R & R0, E | E0, { readonly [k in N | keyof Scope]: k extends keyof Scope ? Scope[k] : A } > => DSL.flatMapF_(F)(self, (scope) => F.map((a: A) => ({ ...scope, [name as string]: a } as { readonly [k in N | keyof Scope]: k extends keyof Scope ? Scope[k] : A }))(f(scope))), bindValue: ( name: N extends keyof Scope ? { error: `binding name '${N}' already in use` } : N, f: (_: Scope) => B ) => ( self: HKT.Kind ): HKT.Kind< F, R, E, { readonly [k in N | keyof Scope]: k extends keyof Scope ? Scope[k] : B } > => F.map((k: Scope) => Object.assign( {}, k, { [name as string]: f(k) } as { readonly [k in N | keyof Scope]: k extends keyof Scope ? Scope[k] : B } ) )(self) } }