- Leverage the type system to model your domain
- Catch errors at compile time to avoid surprises at runtime.
- Refactor with confidence
- Working with impure code
- Managing errors
- Manipulating runtime data
- Make the code predictable at all times
- Emphsizing pure functions
- Encapsulating side effects
- Reusing code through function composition and categories
Statically typed FP allows us to write more declarative code, focusing on the what rather than the how.
The type allows us to purify function using algebraic data types rather than exceptions, and model truly total functions. Side effects are clearly identified through the use of IO monads.
This idea, combining functional programming with a strong type system isn't new. It is the fundation of languages like Haskell and ML, and nowadays, it is gaining popularity in the javascript community through compiled languages like ReasonML, Scala.js, PureScript ...
- It has support for firt-class functions
- It emphasizes on referentially transparent expressions
- It has ways of handling effectful computations
- It has support for algrebaraic data types (discriminated unions, Either ...)
https://dev.to/gcanti/interoperability-with-non-functional-code-using-fp-ts-432e