Skip to content

Commit

Permalink
Merge branch 'release/0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
cwmyers committed Oct 9, 2013
2 parents 3ebe3ff + 4e504bc commit 6e4e9ec
Show file tree
Hide file tree
Showing 10 changed files with 349 additions and 868 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monad.js",
"version": "0.5.1",
"version": "0.6.0",
"main": "src/main/javascript/monad.js",
"ignore": [
"**/.*",
Expand Down
15 changes: 5 additions & 10 deletions example/IO.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<script src="../src/main/javascript/monad.js" type="text/javascript"></script>
<script src="bower_components/underscore/underscore-min.js" type="text/javascript"></script>
<script src="bower_components/jquery/jquery.min.js" type="text/javascript"></script>
<script src="wu-0.1.8.min.js" type="text/javascript"></script>
<title>Example IO page</title>
</head>
<body>
Expand All @@ -23,22 +22,18 @@

<script>

Function.prototype.autoCurry = function (n) {
return wu.autoCurry(this, n);
}

function idFunction(id) {
return id
}

var happyPerson = function (f, l, p) {
return "Welcome " + f + " " + l + " who lives at " + p
}.autoCurry()
}.curry()

$("input").keyup(function () {
var validate = function (label, value) {
return value != "" ? value.success() : ["Please give a " + label].fail()
}.autoCurry()
}.curry()

var firstNameValidation = monadT(getValForId("#firstName").map(validate("first name")))
var lastNameValidation = monadT(getValForId("#lastName").map(validate("last name")))
Expand Down Expand Up @@ -73,19 +68,19 @@

var setHtml = function (html, o) {
return o.html(html)
}.autoCurry()
}.curry()

var setText = function (text, e) {
return e.text(text)
}.autoCurry()
}.curry()

var getVal = function (o) {
return o.val()
}

var writer = function (writeFn, id, content) {
return getId(id).map(writeFn(content))
}.autoCurry()
}.curry()

var addAwesomeness = function (text) {
return text + " now with awesomeness"
Expand Down
73 changes: 73 additions & 0 deletions example/List.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html>
<head>
<script src="../src/main/javascript/monad.js" type="text/javascript"></script>
<script src="bower_components/underscore/underscore-min.js" type="text/javascript"></script>
<script src="bower_components/jquery/jquery.min.js" type="text/javascript"></script>
<title>Example IO page</title>
</head>
<body>

<span id="SomeId">Some text</span>

<div>
<span>first name: <input type="text" id="firstName"/> </span>
<span>last name: <input type="text" id="lastName"/> </span>
<span>postcode: <input type="text" id="postcode"/> </span>
</div>

<div>
<span>Result:</span> <span id="result"></span>
</div>

<script>


function idFunction(id) {
return id
}


var a = List(2,List(1,Nil))


var getId = $.io1()

var getTextForId = function (id) {
return getId(id).map(getText)
}

var getValForId = function (id) {
return getId(id).map(getVal)
}

var getText = function (o) {
return o.text()
}

var setHtml = function (html, o) {
return o.html(html)
}.curry()

var setText = function (text, e) {
return e.text(text)
}.curry()

var getVal = function (o) {
return o.val()
}

var writer = function (writeFn, id, content) {
return getId(id).map(writeFn(content))
}.curry()

var addAwesomeness = function (text) {
return text + " now with awesomeness"
}

getId("#SomeId").map(getText.andThen(addAwesomeness)).flatMap(writer(setText)("#SomeId")).run()

</script>

</body>
</html>
16 changes: 0 additions & 16 deletions example/wu-0.1.8.min.js

This file was deleted.

Loading

0 comments on commit 6e4e9ec

Please sign in to comment.