Inato
A Functional Programing journey
About me
- ๐ @ThierryCols
- ๐ฅ 6 years
- ๐งณ EM
Started functional stuff @inato ๐
Setup
& Inciting Incident
The Throwing Issue
The Throwing Issue
Can you tell the type difference?
The Throwing Issue
There is none.
The Throwing Issue
- Throwing is not reflected in a function signature ๐
- Throwing does not force the caller to react ๐ฎโโ๏ธ
We need a safer way to type what can fail.
And Functional Programming can help with that. ๐งฎ
A little aside
on Functional Programming
๐ฉโ๐ซ What is FP to you?
A little aside on Functional Programming
- Pure functions and function composition ๐
-
Strong type system and containers ๐ฆ
ย - Immutability (and no shared state) ๐ก
Either to the rescue
- Explicit function signatures
- Returning an arbitrary number of errors
What we want:
Either to the rescue
Either to the rescue
Either to the rescue
- Explicit function signatures โ
- Returning an arbitrary number of errors โ
What we have:
Actions & Climax
Tooling our Either
Manipulating containers
- combinators (map, chain...)
- destructors (fold, getOrElse...)
- helpers (pipe, flow...)
Without combinators
With
combinators
Get Help from the community
github.com/gcanti/fp-ts
- Write helper functions fromInatoEitherToFPEither ๐ฅต
- Depreciate homemade code (lint/static) ๐ฎโโ๏ธ
- Boyscout the codebase ๐งน
Advanced Patterns
More Types to solve more problems
- Null/Undefined โก๏ธ Option
- Async/Promises โก๏ธ Task
Advanced Patterns
Dependency Injection
Advanced Patterns
Dependency Injection
Resolution.
Was it worth the hassle?
Is FP Worth?
Development Speed ๐ข
๐ค
Is FP Worth?
Code Quality ๐ฒ
Is FP Worth?
Developer Hapiness ๐โโ๏ธ
9/10 devs @Inato โค๏ธ FP
Resistance from newcomers
Enlightenment
Cheers ๐ป
Questions?
fp-journey
By Thierry Colsenet
fp-journey
- 600