Skip to content

Instantly share code, notes, and snippets.

@brucou
brucou / Promise naive implementation
Last active June 5, 2019 10:17
robust-user-interfaces-with-state-machines - for medium
function makePromiseMachine(params) {
let state = {
control: 'pending',
// ... other pieces of state
};
return function (event) {
const control = state.control;
let output;
@brucou
brucou / TMDB movie search machine definition - take 1
Created May 24, 2019 01:49
Robust user interfaces with state machines - for Medium
const movieSearchFsmDef = {
initialExtendedState: {
queryFieldHasChanged: false, movieQuery: '', results: null, movieTitle: null
},
states: makeStates([
START, MOVIE_QUERYING, MOVIE_SELECTION, MOVIE_SELECTION_ERROR,
MOVIE_DETAIL_QUERYING, MOVIE_DETAIL_SELECTION,
MOVIE_DETAIL_SELECTION_ERROR
]),
events: [
@brucou
brucou / my_introduction_to_monads
Created June 3, 2017 00:18
Yet another explanation of monads
[TOC]
# Introduction
As many before me, I have struggled (and probably continue to struggle) with the concept of monads and comonads. I reviewed a large number of tutorials presenting the concept in many different ways. I think I found a way that works for me, at least for monads, and I wanted to detail that in what follows with the hope that it will be useful for others too[^1].
[^1]: Note that I am referring to monads in the context of computer science and programming. While this is obviously linked to monads in category theory, the presentation of the latter is much more abstract, and I do not deal with that here.
Now, I am trying to end the struggle with :