Created
July 25, 2016 15:43
-
-
Save gcanti/c8cccf986e335066f1220eef5fc1e5d6 to your computer and use it in GitHub Desktop.
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
| export default class Eff<EA: Object, A> { | |
| run: () => A; | |
| constructor(run: () => A) { | |
| this.run = run | |
| } | |
| map<B>(f: (_: A) => B): Eff<EA, B> { | |
| return new Eff(() => f(this.run())) | |
| } | |
| chain<EB: Object, B>(f: (_: A) => Eff<EB, B>): Eff<EA & EB, B> { | |
| return Eff.join(this.map(f)) | |
| } | |
| static join<EA: Object, EB: Object, B>(x: Eff<EB, Eff<EA, B>>): Eff<EA & EB, B> { | |
| return new Eff(() => x.run().run()) | |
| } | |
| ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment