Mostly Adequate with fp-ts
1.0.0
1.0.0
  • Welcome
  • Chapter 01: What Ever Are We Doing?
  • Chapter 04: Currying
  • Chapter 05: Coding by Composing
  • Chapter 06: Example Application
  • Chapter 08: Tupperware
  • Chapter 09: Monadic Onions
  • Chapter 10: Applicative Functors
Powered by GitBook
On this page

Was this helpful?

Chapter 01: What Ever Are We Doing?

There's nothing specific to fp-ts to show in this chapter, but here is the "seagull example" to introduce the form we will use in this guide:

class Flock {
  constructor(n) {
    this.seagulls = n;
  }

  conjoin(other) {
    this.seagulls += other.seagulls;
    return this;
  }

  breed(other) {
    this.seagulls = this.seagulls * other.seagulls;
    return this;
  }
}

const flockA = new Flock(4);
const flockB = new Flock(2);
const flockC = new Flock(0);
const result = flockA
  .conjoin(flockC)
  .breed(flockB)
  .conjoin(flockA.breed(flockB))
  .seagulls;
// 32
class Flock {
  public seagulls: number;
  constructor(n: number) {
    this.seagulls = n;
  }

  conjoin(other: Flock) {
    this.seagulls += other.seagulls;
    return this;
  }

  breed(other: Flock) {
    this.seagulls = this.seagulls * other.seagulls;
    return this;
  }
}

const flockA = new Flock(4);
const flockB = new Flock(2);
const flockC = new Flock(0);
const result = flockA
  .conjoin(flockC)
  .breed(flockB)
  .conjoin(flockA.breed(flockB))
  .seagulls;
// 32

We will skip the next two chapters as there is nothing specific to fp-ts to cover

PreviousWelcomeNextChapter 04: Currying

Last updated 4 years ago

Was this helpful?