Hacker News new | past | comments | ask | show | jobs | submit login
bilby.js - Serious functional programming library for JavaScript (brianmckenna.org)
3 points by jhck on Sept 9, 2012 | hide | past | favorite | 1 comment



Thanks for the submission! The GitHub repository might be more interesting:

https://github.com/pufuwozu/bilby.js

The syntax examples show off a bit of everything:

Monads:

    λ.Do()(
        λ.some(1) >= function(x) {
            return x < 0 ? λ.none : λ.some(x + 2);
        }
    ).getOrElse(0) == 3;
Kleislis:

    λ.Do()(
        function(x) {
            return x < 0 ? λ.none : λ.some(x + 1);
        } >> function(x) {
            return x % 2 != 0 ? λ.none : λ.some(x + 1);
        }
    )(1).getOrElse(0) == 3;
Functors:

    λ.Do()(
        λ.some(1) < add(2)
    ).getOrElse(0) == 3;
Applicatives:

    λ.Do()(
        λ.some(add) * λ.some(1) * λ.some(2)
    ).getOrElse(0) == 3;
Semigroups:

    λ.Do()(
        λ.some(1) + λ.some(2)
    ).getOrElse(0) == 3;




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: