Frequently Asked Questions

Table of contents

  1. Data Types
    1. How can I handle errors with Tasks?
  2. Where do I find …?
    1. Where do I find the Maybe data type?
    2. Where do I find the liftA2, liftA3, … functions?
  3. Techniques
    1. Is it possible to serialize and deserialize an fp-ts type?
    2. Is it possible to use tagless final with fp-ts?
  4. Miscellaneous
    1. Does fp-ts provide Flow type definitions?

Data Types

How can I handle errors with Tasks?

Not every async computation necessarily needs error handling, which is why Task is simply defined as Task<A>. If you do need to handle errors, you can use TaskEither or variations of Task like Task<Option<A>> or Task<These<L, A>>.

Where do I find …?

Where do I find the Maybe data type?

fp-ts provides the Option data type, which is conceptually similar to the Maybe data type.

Where do I find the liftA2, liftA3, … functions?

Use sequenceT and sequenceS instead.

Techniques

Is it possible to serialize and deserialize an fp-ts type?

Yes, you can create an io-ts encoder/decoder for sending/receiving a data type like Option or Either over a network or exchange data with a web worker. Check out the functions createOptionFromNullable and createEitherFromJSON from io-ts-types for this use-case.

Note that it is not possible to serialize data types that contain functions (like IO or Task).

Is it possible to use tagless final with fp-ts?

Yes, read Functional Design: Tagless Final for an introduction. Also have a look at these code examples: mtl.ts, optimizing tagless final, and fp-ts-to-the-max-II.

Miscellaneous

Does fp-ts provide Flow type definitions?

No, fp-ts does not provide official Flow type definitions.