Skip to content

Instantly share code, notes, and snippets.

@gcanti
Created July 25, 2016 15:43
Show Gist options
  • Select an option

  • Save gcanti/c8cccf986e335066f1220eef5fc1e5d6 to your computer and use it in GitHub Desktop.

Select an option

Save gcanti/c8cccf986e335066f1220eef5fc1e5d6 to your computer and use it in GitHub Desktop.
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