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

Fix sequence section in chapter 12 #605

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dotnetCarpenter
Copy link
Contributor

@dotnetCarpenter dotnetCarpenter commented Feb 22, 2021

This PR fixes most of the issues in #581.

From chapter 12, Type Feng Shui section, I have only changed line 4 from
sequence(Either.of, [Either.of('wing')]); // Right(['wing'])
to
sequence(List.of, Either.of(['wing'])), // List(Right('wing')),
which unlike the original will not throw a TypeError. But also is an example of inverting a Right (List (String)) to a List (Right (String)).
The original, Right (List (String)) to Right (List (String)) made little sense.

Line 5, however is not changed and does not highlight anything particular useful, since
sequence(Task.of, left('wing')) = Task.of(left('wing')).

sequence(List.of, Maybe.of(['the facts'])); // [Just('the facts')]
sequence(Task.of, new Map({ a: Task.of(1), b: Task.of(2) })); // Task(Map({ a: 1, b: 2 }))
sequence(IO.of, Either.of(IO.of('buckle my shoe'))); // IO(Right('buckle my shoe'))
sequence(List.of, Either.of(['wing'])), // List(Right('wing'))
sequence(Task.of, left('wing')); // Task(Left('wing'))

Only two changes was required to support/index.js.

  1. Right
traverse(of, fn) {
  return fn(this.$value).map(Either.of); // added return
}
  1. Map
  // ----- Pointed Map
  static of(x) {
    return new Map(x);
  }

@dotnetCarpenter
Copy link
Contributor Author

Blocks #607

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.

1 participant