Created
November 29, 2017 05:05
-
-
Save zerobias/dd6c9cd577d4f258465fd0c9147a8bae to your computer and use it in GitHub Desktop.
Flow curry3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@flow | |
declare export function curry3<A, B, C, D>(fn: (a: A, b: B, c: C) => D): ( | |
& ((a: A, nob: void, noc: void) => ( | |
& ((b: B, noc: void) => ((c: C) => D)) | |
& ((b: B, c: C) => D) | |
)) | |
& ((a: A, b: B, noc: void) => ((c: C) => D)) | |
& ((a: A, b: B, c: C) => D) | |
) | |
// EXAMPLE: | |
declare function sum(a: number, b: number, c: number): number | |
const sum10 = sumCurry(10) | |
const sum10_9 = sum10(9) | |
const res = sum10(11, 12) | |
//Must fail | |
//const sum10err = sumCurry('10') | |
//const wrongCurry = sum10(11)(12, 14) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment