title: Task, Lift and complex monads in FP-TS
body: <p>I have the following code:</p>
  
  <pre class="lang-js prettyprint-override"><code>import { Task, task } from "fp-ts/lib/Task"
  import { Either, left, right } from "fp-ts/lib/Either"
  import { curry } from "fp-ts/lib/function"
  import { liftA2 } from "fp-ts/lib/Apply"
  import { Repo } from "./repo"
  
  const buildPerson = curry((name: string, age: number): Either&lt;Error, any&gt; =&gt; {
      if (name !== undefined &amp;&amp; age !== undefined) {
          return right({ name, age })
      } else {
          return left(Error("Missing parameter"))
      }
  })
  
  const validatePerson = (person: any): Either&lt;Error, any&gt; =&gt; {
      if ( person.age &lt; 18) {
          return left(Error("Too Young")) 
      } else {
          return right(person)
      }
  }
  
  const getNameFromRepo = (repo: Repo): Task&lt;string&gt; =&gt; {
      return new Task(
          () =&gt; repo.getName()
      )
  }
  
  const getAgeFromRepo = (repo: Repo): Task&lt;number&gt; =&gt; {
      return new Task(
          () =&gt; repo.getAge()
      )
  }
  
  const savePerson = curry((person:any, repo: Repo): Task&lt;void&gt; =&gt; {
      return new Task(
          () =&gt; {
              console.log(person)
              return repo.setPerson(person)
          }
      )
  })
  
  const hello = async () =&gt; {
      const repo = new Repo()
  
      await liftA2(task)(buildPerson)(getNameFromRepo(repo))(getAgeFromRepo(repo))
      .map(
          (e) =&gt; e.chain(
              (p) =&gt; validatePerson(p)
          )
      )
      .map(
          (e) =&gt; e.fold(
              (l) =&gt; console.log(l),
              (r) =&gt; savePerson(r)
          )
      )
      .run()
  }
  
  hello()
  </code></pre>
  
  <p>1) savePerson function doesn't get run, return type however is Promise</p>
  
  <p>2) Fp-Ts library indicates that liftA2 type is deprecated and I should use sequenceT instead. However from the signature it's not clear how sequenceT would apply to the parameters of buildPerson like liftA2 does</p>
  
  <p>3) Is there a better way to compose the functions? </p>