Skip to content

Instantly share code, notes, and snippets.

Antony Courtney antonycourtney

View GitHub Profile
antonycourtney /
Last active Nov 6, 2017
Reflections on why Fruit (A prototype Functional Reactive UI Toolkit for Haskell) never took off (2008)
Received: by with HTTP; Fri, 22 Feb 2008 06:35:48 -0800 (PST)
Message-ID: <>
Date: Fri, 22 Feb 2008 09:35:48 -0500
From: "Antony Courtney" <>
To: "Conal Elliott" <>
Subject: Re: Fruit
Cc: Yampa-Users <>
In-Reply-To: <>
MIME-Version: 1.0
antonycourtney / flow-lambda-bug.js
Created Mar 31, 2017
Flow data flow analysis loses info under a lambda
View flow-lambda-bug.js
/* @flow */
/* Paste this into to see the bug: */
const f = (lut: ?{[key: string]: number}): number => {
// This correctly notices that we're doing a null check on lut:
const testKey = 'fizz'
const y = (lut != null) ? lut[testKey] : 0
antonycourtney / Timer.js
Created Jan 4, 2017
Example of maintaining Timer state for use in React
View Timer.js
/* @flow */
import * as Immutable from 'immutable'
* A timer object for use in OneRef-based immutable state
export type TimerUpdater = (f: (ts: Timer) => Timer) => void
antonycourtney / interp.lhs
Last active May 5, 2016
My own notes and exercises written while reading Wadler's wonderful "Monads for Functional Programming" in 1998
View interp.lhs
A really simple interpreter to use while learning about monads. Based on
the paper "Monads for Functional Programming" by Phil Wadler.
the type of terms:
> data Term = Con Int
> | Div Term Term
> deriving Show
antonycourtney / FunPix.hs
Created Mar 4, 2016
Layout thought of as an attribute grammar, encoded in Haskell
View FunPix.hs
-- Some experiments with a Picture type based on an attribute-grammar
-- model of Layout
module FunPic where
import Haven
-- A type for representing the dimensions of a rectangle, as (width,height)
type Dimension = (Double,Double)
antonycourtney /
Last active Mar 10, 2020
A real world example of recombinant / diamond wiring and feedback with RxJS

A realistic RxJS app with diamond wiring

Consider the following user interface (inspired by Strava) for looking at time-series charts of network data:


Notes on this interface and my Rx implementation of it:

  • Each chart (stacked vertically) charts a different metric (latency, packet loss and throughput) but over the same time period.
  • As the user moves the mouse left and right on any chart, the vertical line (called the tracker) moves to track the mouse position on all charts. The number displayed in the gray box on the right is the value underneath the tracker for that metric.
antonycourtney / Example1.elm
Last active Nov 8, 2015
Animaxe Example 1 in Elm
View Example1.elm
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import List exposing (..)
import Signal exposing (..)
import Time exposing (..)
import Array
-- a square of the given width and color:
square : Float -> Color -> Form
antonycourtney / invokeLater.js
Last active Oct 19, 2015
invokeLater for oneref
View invokeLater.js
function invokeLater(f) {
window.setTimeout(f, 0);
antonycourtney / scrollAction.js
Created Oct 15, 2015
scroll action in oneref-flux-challenge
View scrollAction.js
export function scroll(scrollAmount,updater) {
updater((prevState) => {
const {nextState, oldRequests} = prevState.scrollAdjust(scrollAmount);
oldRequests.forEach((req) => req.abort()); // cancel old requests
// Need invokeLater since we're within updater
invokeLater(() => fillView(nextState,updater));
return nextState;
antonycourtney / fillView.js
Created Oct 15, 2015
fillView action in oneref-flux-challenge
View fillView.js
* fill view by generating more requests if necessary
function fillView(st,updater) {
const lastSith = st.lastKnownSith();
if (st.needsApprentice(lastSith)) {
} else {
const firstSith = st.firstKnownSith();
if (st.needsMaster(firstSith)) {
You can’t perform that action at this time.