Nifty Pony Merchandise

    list-monad

    0.4.3 • Public • Published

    list-monad

    Monads in JavaScript / sample implemantation

    List monad derived from free-monoid

    https://www.npmjs.com/package/free-monoid

    monad laws validation

    const util = require("util");
    const validate = a => b => util.inspect(a) === util.inspect(b)
      ? true : false;
     
    const f = x => (M)(+ 7);
    const g = x => (M)(* 5);
    const a = 9;
    const m = (M)(3)(5)(7);
     
    console.log(
      validate(
        (M)(a).bind(f)
      )(
        f(a)
      )
    );
    console.log(
      validate(
        m.bind(M)
      )(
        m
      )
    );
    console.log(
      validate(
        m.bind(f)
          .bind(g)
      )(
        m.bind(x => f(x)
          .bind(g))
      )
    );
    true
    true
    true

    Install

    npm i list-monad

    DownloadsWeekly Downloads

    0

    Version

    0.4.3

    License

    MIT

    Unpacked Size

    10.8 kB

    Total Files

    6

    Last publish

    Collaborators

    • kenokabe