0.5.1 • Published 10 years ago

macros.operators v0.5.1

Weekly downloads
5
License
MIT
Repository
github
Last release
10 years ago

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.

0.5.1

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago