Skip to content

Instantly share code, notes, and snippets.

Antony Courtney antonycourtney

Block or report user

Report or block antonycourtney

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@antonycourtney
antonycourtney / fruit-reflections-2008.md
Last active Nov 6, 2017
Reflections on why Fruit (A prototype Functional Reactive UI Toolkit for Haskell) never took off (2008)
View fruit-reflections-2008.md
Received: by 10.140.161.21 with HTTP; Fri, 22 Feb 2008 06:35:48 -0800 (PST)
Message-ID: <3be64c030802220635i3380e50fh70bf62e0bdc6d5a0@mail.gmail.com>
Date: Fri, 22 Feb 2008 09:35:48 -0500
From: "Antony Courtney" <antony.courtney@gmail.com>
To: "Conal Elliott" <conal@conal.net>
Subject: Re: Fruit
Cc: Yampa-Users <yampa-users@cs.yale.edu>
In-Reply-To: <ea8ae9fb0802211906t232938c5wded0a56b35ceaa2d@mail.gmail.com>
MIME-Version: 1.0
@antonycourtney
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 https://flow.org/try/ 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
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
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
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
antonycourtney / DiamondExample.md
Last active Feb 5, 2018
A real world example of recombinant / diamond wiring and feedback with RxJS
View DiamondExample.md

A realistic RxJS app with diamond wiring

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

esnet-estes-charts

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
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
antonycourtney / invokeLater.js
Last active Oct 19, 2015
invokeLater for oneref
View invokeLater.js
function invokeLater(f) {
window.setTimeout(f, 0);
}
@antonycourtney
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
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)) {
requestSithInfo(true,lastSith.info.apprenticeId,updater);
} else {
const firstSith = st.firstKnownSith();
if (st.needsMaster(firstSith)) {
You can’t perform that action at this time.