sweet-algebras
A implementation of emcascript-algebras with macros
Last updated 3 years ago by disnet .
ISC · Original npm · Tarball · package.json
$ cnpm install sweet-algebras 
SYNC missed versions from official npm registry.

sweet algebras

This is an experimental implementation of emcascript algebras in Sweet.js.

Install

npm install @sweet-js/cli sweet-algrebras

Use

Import class and interface from the sweet-algrebras packages:

// maybe.js
'lang sweet.js';
import { class, interface } from 'sweet-algrebras';

interface Functor {
  map;
}

class Maybe implements Functor { }
class Just extends Maybe {
  constructor(value) {
    super();
    this.value = value;
  }

  [Functor.map](fn) {
    return new Just(fn(this.value));
  }
}
class Nothing extends Maybe {
  [Functor.map](fn) {
    return this;
  }
}

new Just(1)[Functor.map](console.log);

and compile with Sweet:

sjs maybe.js

Current Tags

  • 0.0.4                                ...           latest (3 years ago)

4 Versions

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

Copyright 2014 - 2016 © taobao.org |