by fyfy18 · 6y ago · 0 comments
https://en.m.wikipedia.org/wiki/Option_type
If you are using TypeScript (TFA mentions it), fp-ts provides a good functional programming layer. Although if you aren't already familiar with functional programming it's going to be hard as the documentation is rather lacking.
I would go even further that even if the semantics are a little clunky (wrap/unwrap) any programming language can implement Option.
As an aside, TypeScript is very unsafe by default, and still relatively unsafe with strict mode enabled. Stringent fp-ts usage bypasses these issues.
Is it? I have been using Typescript more and more these last few years, and lately haven't really experienced any issues where it's type system failed me.
To clarify, I'm not trying to argue against your point, genuinely curious to learn if fp-ts can really improve my code quality in production.
Beyond that there's functions that throw/reject doing so outside the type system, something solved by Either/Option/similar types in fp-ts.
The biggest benefit of fp-ts though is that it makes you think functionally. If you're dead set against that, then there are plenty of other libraries that give you types/wrappers like these without having to use pipe/flow (two functions you'll want to use before anything else in fp-ts).