Skip to content

Instantly share code, notes, and snippets.

@diogot
diogot / States-v3.md
Created February 21, 2019 02:09 — forked from andymatuschak/States-v3.md
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@diogot
diogot / keybase.md
Created April 13, 2016 16:48
keybase.md

Keybase proof

I hereby claim:

  • I am diogot on github.
  • I am diogot (https://keybase.io/diogot) on keybase.
  • I have a public key ASCsCEdA5hL6oc5kH1vqoWl9bEk42-cuRL2IzADSgVUbwwo

To claim this, I am signing this object:

//
// DTNetworkOperation.h
// DTOperation
//
// Created by Diogo on 10/14/15.
// Copyright © 2015 Diogo Tridapalli. All rights reserved.
//
#import "DTOperation.h"
@diogot
diogot / XCTestCase+MethodSwizzling.h
Created May 28, 2014 20:31
XCTestCase (MethodSwizzling)
//
// XCTestCase+MethodSwizzling.h
//
// Created by Diogo Tridapalli on 5/28/14.
// Copyright (c) 2014 Diogo Tridapalli. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface XCTestCase (MethodSwizzling)
@diogot
diogot / bank.cc
Last active December 19, 2015 06:58
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
int nextAvailable(unsigned int C, int *chashier)
{
int avail = 0;