Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ch10: add missing liftA2 in one of the examples #252

Merged
merged 1 commit into from
Mar 13, 2016

Conversation

eush77
Copy link
Contributor

@eush77 eush77 commented Mar 3, 2016

The first example in the Laws section of chapter 10 is not correct:

require('./support');
var Task = require('data.task');
var _ = require('ramda');


var tOfM = _.compose(Task.of, Maybe.of);

liftA2(_.concat, tOfM('Rainy Days and Mondays'), tOfM(' always get me down'))
  .fork(console.log, console.log);
$ node example
            throw new TypeError('can\'t concat ' + typeof set1);
            ^

TypeError: can't concat object

Instead, _.concat needs to be lifted into Maybe type:

var tOfM = _.compose(Task.of, Maybe.of);

liftA2(liftA2(_.concat), tOfM('Rainy Days and Mondays'), tOfM(' always get me down'))
  .fork(console.log, console.log);
$ node example
Maybe(Rainy Days and Mondays always get me down)

This is by the way a nice example of liftA2 being partially applied (as discussed earlier in this chapter).

@eush77 eush77 changed the title ch10: add missing liftA2 in one of the example ch10: add missing liftA2 in one of the examples Mar 9, 2016
@KtorZ
Copy link
Member

KtorZ commented Mar 13, 2016

Indeed!

KtorZ added a commit that referenced this pull request Mar 13, 2016
ch10: add missing liftA2 in one of the examples
@KtorZ KtorZ merged commit d83fe47 into MostlyAdequate:master Mar 13, 2016
@eush77 eush77 deleted the ch10-missing-lift branch March 14, 2016 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants