Skip to main content

fork()

fork<A, B, C>(a): <D>(b) => (c) => (d) => C

Pass a value through two different functions and the results to a function that takes two arguments.

Type Parameters

A

The type of the first input to the binary function. Corresponds to the return type of the first function.

B

The type of the second input to the binary function. Corresponds to the return type of the second function.

C

The return type of the binary function.

Parameters

a

(x) => (y) => C

The final curried, binary function that receives the results from b and c.

Returns

Function

Type Parameters

D

Parameters

b

(x) => A

Returns

Function

Parameters

c

(x) => B

Returns

Function

Parameters
d

D

Returns

C

Remarks

Phi combinator

λabcd.a(bd)(cd)

'fork :: (a → b → c) → (d → a) → (d → b) → d → c'

pure function

Example

fork((x) => (y) => x + y)(x => x + 3)(x => x - 2)(9)
// 19