Skip to content

Commit

Permalink
Merge pull request #81 from cwmyers/develop
Browse files Browse the repository at this point in the history
Alpha 2 release
  • Loading branch information
ulfryk authored Oct 25, 2016
2 parents 06d4854 + d62c647 commit 208cffa
Show file tree
Hide file tree
Showing 16 changed files with 218 additions and 78 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Simply download and add to your html pages or we also support [bower]. You can
bower install monet --save

# or to install a specific version
bower install monet#0.9.0-alpha.1
bower install monet#0.9.0-alpha.2
```

### Node installation
Expand All @@ -44,7 +44,7 @@ bower install monet#0.9.0-alpha.1
npm install monet --save

# or to install a specific version
npm install [email protected].1
npm install [email protected].2
```

## A note on types
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monet",
"version": "0.9.0-alpha.1",
"version": "0.9.0-alpha.2",
"main": "src/main/javascript/monet.js",
"ignore": [
"**/.*",
Expand Down
2 changes: 1 addition & 1 deletion dist/monet-pimp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* monet-pimp.js 0.9.0-alpha.1
* monet-pimp.js 0.9.0-alpha.2
*
* This file needs to be included after monet.js
*
Expand Down
2 changes: 1 addition & 1 deletion dist/monet-pimp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 22 additions & 11 deletions dist/monet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Monet.js 0.9.0-alpha.1
* Monet.js 0.9.0-alpha.2
*
* (c) 2012-2016 Chris Myers
* @license Monet.js may be freely distributed under the MIT license.
Expand Down Expand Up @@ -135,8 +135,17 @@
function cons(head, tail) {
return tail.cons(head);
}
function List(head, tail) {
return new List.fn.init(head, tail);
function List() {
switch (arguments.length) {
case 0:
return new List.fn.init();

case 1:
return new List.fn.init(arguments[0]);

default:
return new List.fn.init(arguments[0], arguments[1]);
}
}
root.List = List;
var listEach = function(effectFn, l) {
Expand Down Expand Up @@ -197,15 +206,17 @@
};
var Nil;
List.fn = List.prototype = {
init: function(head, tail) {
if (head == null) {
init: function() {
var head = arguments[0];
var tail = arguments[1];
if (arguments.length === 0) {
this.isNil = true;
this.size_ = 0;
} else {
this.isNil = false;
this.head_ = head;
this.tail_ = tail == null ? Nil : tail;
this.size_ = tail == null ? 0 : tail.size() + 1;
this.tail_ = tail || Nil;
this.size_ = this.tail_.size() + 1;
}
},
of: function(value) {
Expand Down Expand Up @@ -824,7 +835,7 @@
return Return(a);
};
Free.liftF = function(functor) {
return Suspend(functor.map(Return));
return isFunction(functor) ? Suspend(compose(Return, functor)) : Suspend(functor.map(Return));
};
Free.fn = Free.prototype = {
init: function(val, isSuspend) {
Expand All @@ -841,9 +852,9 @@
});
},
bind: function(fn) {
return this.isSuspend ? Suspend(isFunction(this.functor) ? compose(function(free) {
return this.isSuspend ? isFunction(this.functor) ? Suspend(compose(function(free) {
return free.bind(fn);
}, this.functor) : this.functor.map(function(free) {
}, this.functor)) : Suspend(this.functor.map(function(free) {
return free.bind(fn);
})) : fn(this.val);
},
Expand Down Expand Up @@ -966,7 +977,7 @@
}).cata(function() {
return assign(Monet, root);
}, function(rootObj) {
assign(rootGlobalObject, root);
assign(rootObj, root);
return Monet;
});
});
4 changes: 2 additions & 2 deletions dist/monet.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/monet.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function (config) {
basePath: '',
frameworks: ['jasmine'],
files: [
'src/*.js',
'src/monet.js',
'test/*-helper.js',
'test/*-spec.js'
],
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
],
"name": "monet",
"description": "Monadic types library for JavaScript",
"version": "0.9.0-alpha.1",
"version": "0.9.0-alpha.2",
"homepage": "https://github.com/cwmyers/monet.js",
"repository": {
"type": "git",
Expand All @@ -30,8 +30,9 @@
"scripts": {
"test": "karma start && tsc -m system --noEmit --listFiles",
"test-typings": "tsc -m system --noEmit --listFiles",
"tdd": "karma start --auto-watch --no-single-run --browsers Chrome,Firefox,PhantomJS",
"tdd-osx": "karma start --auto-watch --no-single-run --browsers Chrome,Firefox,PhantomJS,Safari",
"tdd": "karma start --auto-watch --no-single-run",
"tdd-full": "karma start --auto-watch --no-single-run --browsers Chrome,Firefox,PhantomJS",
"tdd-full-osx": "karma start --auto-watch --no-single-run --browsers Chrome,Firefox,PhantomJS,Safari",
"minify:monet": "uglifyjs dist/monet.js -o dist/monet.min.js --source-map dist/monet.min.js.map -m -c unsafe -v --comments --keep-fnames",
"minify:monet-pimp": "uglifyjs dist/monet-pimp.js -o dist/monet-pimp.min.js --source-map dist/monet-pimp.min.js.map -m -c unsafe -v --comments --keep-fnames",
"minify": "npm run minify:monet && npm run minify:monet-pimp",
Expand Down
2 changes: 1 addition & 1 deletion src/monet-pimp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* monet-pimp.js 0.9.0-alpha.1
* monet-pimp.js 0.9.0-alpha.2
*
* This file needs to be included after monet.js
*
Expand Down
42 changes: 27 additions & 15 deletions src/monet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Monet.js 0.9.0-alpha.1
* Monet.js 0.9.0-alpha.2
*
* (c) 2012-2016 Chris Myers
* @license Monet.js may be freely distributed under the MIT license.
Expand Down Expand Up @@ -166,9 +166,12 @@
}

// List monad

function List(head, tail) {
return new List.fn.init(head, tail)
function List() {
switch (arguments.length) {
case 0: return new List.fn.init()
case 1: return new List.fn.init(arguments[0])
default: return new List.fn.init(arguments[0], arguments[1])
}
}

root.List = List
Expand Down Expand Up @@ -250,15 +253,17 @@
var Nil

List.fn = List.prototype = {
init: function (head, tail) {
if (head == null) {
init: function () {
var head = arguments[0];
var tail = arguments[1];
if (arguments.length === 0) {
this.isNil = true
this.size_ = 0
} else {
this.isNil = false
this.head_ = head
this.tail_ = tail == null ? Nil : tail
this.size_ = tail == null ? 0 : tail.size() + 1
this.tail_ = tail || Nil
this.size_ = this.tail_.size() + 1
}
},
of: function (value) {
Expand Down Expand Up @@ -899,7 +904,7 @@
}

Reader.of = function (x) {
return Reader(function (_) {
return Reader(function (_ /* do not remove - it's for currying purposes */) {
return x
})
}
Expand Down Expand Up @@ -959,7 +964,9 @@
}

Free.liftF = function (functor) {
return Suspend(functor.map(Return))
return isFunction(functor) ?
Suspend(compose(Return, functor)) :
Suspend(functor.map(Return))
}

Free.fn = Free.prototype = {
Expand All @@ -977,14 +984,19 @@
})
},
bind: function (fn) {

return this.isSuspend ?
Suspend(isFunction(this.functor) ?
compose(function (free) {

isFunction(this.functor) ?

Suspend(compose(function (free) {
return free.bind(fn)
}, this.functor) :
this.functor.map(function (free) {
}, this.functor)) :

Suspend(this.functor.map(function (free) {
return free.bind(fn)
})) :

fn(this.val)
},
ap: function (ff) {
Expand Down Expand Up @@ -1127,7 +1139,7 @@
return Maybe.fromNull(rootGlobalObject)
.filter(function (rootObj) { return Boolean(rootObj.notUseMonetGlobalObject) })
.cata(function () { return assign(Monet, root) }, function (rootObj) {
assign(rootGlobalObject, root)
assign(rootObj, root)
return Monet
})
}))
Expand Down
3 changes: 2 additions & 1 deletion test/either-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ describe('An Either', function () {

})

describe("will pimp an object", function () {
// TODO: Provide additional test suite for `monet-pimp`
xdescribe("will pimp an object", function () {
it("with right", function () {
expect("hello".right()).toBeRightWith("hello")
})
Expand Down
Loading

0 comments on commit 208cffa

Please sign in to comment.