Yuriy Bogomolov Profile picture
Programmer. All opinions are my own.
Herve Moal Profile picture 1 subscribed
Jul 1, 2019 13 tweets 4 min read
Welcome to twelfth episode of #monadicmonday! Today I want to talk about a Future – a concept of asynchronous lazy task, which is a far better replacement for an eager Promise. Due to their laziness, futures support cancellation, racing, parallelism and resource safety out of the box. The best library I've seen and used for Futures is fluture-js: github.com/fluture-js/Flu….
May 27, 2019 25 tweets 8 min read
Welcome to ninth episode of #monadicmonday! Today I would like to return to the roots of this series and provide you with a few "take and go" recepies for type-level programming in TypeScript. Let's start with the basics. Type-level programming means that we express statements using types, and ask compiler to check them. In TypeScript, we use conditional types to infer our statements to be either `never` (bottom type) or some meaningful type.
May 13, 2019 24 tweets 11 min read
Welcome to the seventh episode of #monadicmonday! Today we'll talk a bit about functional optics: lenses, prisms, folds and traversals. History of lenses started in 2009 with "The Essence of the Iterator Pattern" paper, which started a whole lot of cascading publications, leading to current `lens` package for Haskell and various implementations in different languages.
Apr 29, 2019 18 tweets 5 min read
Welcome to the fifth episode of #monadicmonday! Today we'll look at the famous Tagless Final pattern and its implementation in TypeScript.

If you haven't heard of Tagless Final style (also called "Finally Tagless Interpreters"), here's a brief recap. Originally this pattern was introduced by Oleg Kiselyov et al. in his paper "Finally Tagless, Partially Evaluated: Tagless Staged Interpreters for Simpler Typed Languages": okmij.org/ftp/tagless-fi…
Apr 15, 2019 22 tweets 7 min read
Welcome to the thrid installment of #monadicmonday!
Today we'll talk about quite complicated topic – recursion schemes. Hold tight, as the ride won't be easy.

First of all, I would like to stress that I'm still grokking this topic, so if you spot a mistake, please ping me back! Recursion schemes were popularized by a classical paper by Mejer, Fokkinga and Petterson called "Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire": eprints.eemcs.utwente.nl/7281/01/db-utw…
Apr 8, 2019 11 tweets 3 min read
Welcome to the second episode of #monadicmonday! Today we'll talk about algebraic data types, and more specifically – about semirings and rings. First of all, let's recap what a semiring is.
Semiring is a set equipped with two binary operations, called "addition" and "multiplication". The intuition that works here is such of natural numbers – you can define a semiring for Nat with addition as "+" and multiplication as "*"
Apr 1, 2019 5 tweets 3 min read
Welcome to #monadicmonday! Let's start with a These/Ior monad.

`These` is a monad which expresses "inclusive-OR" relation:

These(A, B) = A + B + A * B.

These represents a simple idea: it can hold either value of type A, value of type B or both of them simultaneously. It may be present in FP libraries under it's literal name "These" (Haskell, TypeScript), or under "Ior" name (like in Scala's `cats` package).

Take a look at the following function in TypeScript using These monad from fp-ts package by @GiulioCanti: