babel-plugin-monadic-do
Hijacks `do`/`while` statements with bitwise left shift (`<<`) to implement the `for`/`yield` syntax we all know and love :heart: from [scala](https://docs.scala-lang.org/tutorials/FAQ/yield.html).
Last updated 2 years ago by pfgray .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-plugin-monadic-do 
SYNC missed versions from official npm registry.

Hijacks do expressions with bitwise left shift (<<) to implement the for/yield syntax we all know and :heart: from scala.

If you don't like using the tasiest syntax sugar available, then stay away!

However, if you like feeling alive and the taste of the kool-aid they're handing out in fp land, then look no further!

You can turn:

getFoo("/api/foo").chain(foo => {
  return getBar("/api/bar").chain(bar => {
    const lol = bar.name;
    return getBaz("/api/baz/" + lol).map(baz => {
      return foo + bar + baz;
    });
  });
});

into:

do {
  foo << getFoo("/api/foo")
  bar << getBar("/api/bar")
  const lol = bar.name;
  baz << getBaz("/api/baz/" + lol)

  foo + bar + baz;
}

Limitations:

  1. Top expression must be a 'bind' expression, i.e. x << y
  2. Last line must be a plain expression (not a bind expression)
  3. Coworkers will loathe you when you try to explain monads to them.

Current Tags

  • 0.0.2                                ...           latest (2 years ago)

2 Versions

  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 1
This Week 2
This Month 4
Last Day 0
Last Week 0
Last Month 2
Dependencies (3)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |