Skip to content

Instantly share code, notes, and snippets.

@SimonRichardson
Created December 4, 2013 15:54
Show Gist options
  • Select an option

  • Save SimonRichardson/7789972 to your computer and use it in GitHub Desktop.

Select an option

Save SimonRichardson/7789972 to your computer and use it in GitHub Desktop.
Chain effects. Is there a way to represent the .chain.chain.chain scenario some like the do notation? Does the do notation already work with this?
var M = State.StateT(IO),
program = M.lift(init)
.chain(doSomething)
.chain(doSomethingElse)
.chain(doSomethingWicked);
console.log(program.exec([]).unsafePerform());
/*
// What I would like to happen
var M = State.StateT(IO),
program = $do {
a = M.lift(init);
b -> doSomething;
c -> doSomethingElse;
d -> doSomethingWicked;
return d;
};
console.log(program.exec([]).unsafePerform());
*/
@SimonRichardson
Copy link
Copy Markdown
Author

Question is there anything that sort of does something like what I want i.e. hide the chain call in haskell or similar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment