-
-
Save WimJongeneel/f2951c238604c860f63fae639f8a074a to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Construct a continuation a' from a (f: (a:a') => void) => void | |
* @param c - the cont a' | |
*/ | |
export const unit = <a>(f: (c: (_: a) => void) => void): Cont<a> => ({ | |
run: c, | |
map<b>(f: (a: a) => b) { | |
return create_cont(cont_map(this.runCont, f)) | |
}, | |
then<b>(f: (a: a) => Cont<b>) { | |
return create_cont<b>(cont_bind<a, b>(this.runCont, a => f(a).run)) | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment