fp-ts Algebraic Data Types and Type Classes

Installation
SKILL.md

fp-ts Algebraic Data Types and Type Classes

This skill covers algebraic data types (ADTs) and type classes in fp-ts for robust domain modeling in TypeScript.

Core Concepts

What are Algebraic Data Types?

Algebraic Data Types (ADTs) are composite types formed by combining other types. There are two fundamental kinds:

  • Product Types: Combine types with AND (tuples, records) - "A user HAS a name AND an email"
  • Sum Types: Combine types with OR (discriminated unions) - "A result IS either success OR failure"

What are Type Classes?

Type classes define behavior that can be implemented for different types. In fp-ts, they're represented as interfaces with instances for specific types:

  • Eq: Equality comparison
  • Ord: Ordering/comparison
Related skills
Installs
GitHub Stars
6
First Seen