Skip to content

Instantly share code, notes, and snippets.

@fdaciuk
Last active November 23, 2023 14:29
Show Gist options
  • Star 45 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save fdaciuk/9e7eb058d999bb20caa769684ae76904 to your computer and use it in GitHub Desktop.
Save fdaciuk/9e7eb058d999bb20caa769684ae76904 to your computer and use it in GitHub Desktop.
Live Node.js + TS com Programação Funcional

Links

Repositório do projeto: https://github.com/fdaciuk/conduit-api

Especificação da API: https://gothinkster.github.io/realworld/docs/specs/backend-specs/introduction

Talks

Lidando com valores opcionais no React com fp-ts:

Haskell para programadores JavaScript (como programar de forma puramente funcional em JS):

Lazy evaluation do Haskell aplicado em JS:

Functional Architecture (Arquitetura Hexagonal):

Functional Design Patterns:

From Dependency Injection to dependency rejection:

Typed Functional Programming in TypeScript with fp-ts:

Teoria das categorias


Live #002: Tipos do fp-ts

// Lazy é só uma função que retorna alguma coisa.
type Lazy<A> = () => A

// usamos Option quando temos tipos de dados possivelmente nulos.
type Some<A> = {
    _tag: 'Some'
    value: A
}

type None = {
    _tag: 'None'
}

type Option<A> = Some<A> | None

// usamos Either quando temos algum valor síncrono que possivelmente vai disparar um erro
type Right<A> = {
    _tag: 'Right'
    right: A
}

type Left<E> = {
    _tag: 'Left'
    left: E
}

type Either<E, A> = Right<A> | Left<E>

// usamos Task para funções que retornam uma promise que nunca quebra
type Task<A> = Lazy<Promise<A>>

// usamos o TaskEither para funções que retornam uma Promise que possivelmente dispara um erro
type TaskEither<E, A> = Task<Either<E, A>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment