macros.operators
Sweet.js operator macros for common operations
Last updated 6 years ago by killdream .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install macros.operators 
SYNC missed versions from official npm registry.

macros.operators

Build Status NPM version Dependencies Status unstable

Sweet.js operator macros for common operations

Example

f >>= g;          // chaining
a <*> b <*> c;    // ap
a +++ b +++ c;    // concat
a |> f; g <| a;   // piping
f ->> g; f <<- g; // function composition

Installing

$ npm install macros.operators

Using

You can either choose to use all macros, by compiling with the root module:

sjs --module macros.operators yourfile.sjs

Or choose only the appropriate macros by including each one separately:

sjs --module macros.operators/macros/applicative \
    --module macros.operators/macros/functor \
    yourfile.sjs

Available macros

alternative.sjs

  • a <|> b: Alternative (a.orElse(=> b));

applicative.sjs

  • a <*> b: Applicative (a.ap(b));
  • a <**> b: Right-associative applicative (b.ap(a));

function.sjs

  • a |> f: Forward piping (f(a));
  • f <| a: Backward piping (f(a));
  • f ->> g: Forward function composition (x => f(g(x)));
  • g <<- f: Backward function composition (x => g(f(x)));
  • a @f b, c, ...: Infix application (f(a, b, c, ...));

functor.sjs

  • a <$> f: Map (a.map(f));

monad.sjs

  • a >>= f: Chain (a.chain(f));
  • f =<< a: Backward chain (a.chain(f));
  • f >=> g: Chain composition (x => f(x).chain(g));
  • g <=< f: Backward chain composition (x => f(x).chain(g));

monoid.sjs

  • a +++ b: Concatenation (a.concat(b));

proto.sjs

  • a::b: Prototype shorthand (a.prototype.b);

Licence

Copyright (c) 2014 Quildreen Motta.

Released under the MIT licence.

Current Tags

  • 0.5.1                                ...           latest (6 years ago)

9 Versions

  • 0.5.1                                ...           6 years ago
  • 0.5.0                                ...           6 years ago
  • 0.4.0                                ...           6 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (0)
None
Dev Dependencies (7)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |