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?

Made with Slides.com