Skip to content

Instantly share code, notes, and snippets.

@MikuroXina
Created October 29, 2023 09:08
Show Gist options
  • Save MikuroXina/f1a1f1d1b1bdacac4da622e70d57ddcc to your computer and use it in GitHub Desktop.
Save MikuroXina/f1a1f1d1b1bdacac4da622e70d57ddcc to your computer and use it in GitHub Desktop.
Y fixed combinator with TypeScript.
export type Paradoxical<A, R> = (f: Paradoxical<A, R>) => (a: A) => R;
export const Y = <A, R>(f: (g: (a: A) => R) => (a: A) => R): ((a: A) => R) =>
((x: Paradoxical<A, R>) => f((lazy) => x(x)(lazy)))(
(x: Paradoxical<A, R>) => f((lazy) => x(x)(lazy)),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment