Skip to content

Instantly share code, notes, and snippets.

View joshburgess's full-sized avatar
💭
🤔

Josh Burgess joshburgess

💭
🤔
View GitHub Profile
@joshburgess
joshburgess / Ref.js
Created June 24, 2018 08:50 — forked from maddie927/Ref.js
react-basic Ref component
"use strict";
var React = require("react");
var ReactDOM = require("react-dom");
exports.makeRef = function(toMaybe) {
var Ref = function(props) {
this.DOMNode = null;
return this;
};
@joshburgess
joshburgess / foo.ts
Created June 27, 2018 02:23 — forked from OliverJAsh/foo.ts
Type safe routing with `fp-ts-routing` and `unionize`
import {
end,
int,
lit,
Match,
parse,
Route as RouteBase,
zero
} from "fp-ts-routing";
import { pipe } from "fp-ts/lib/function";
@joshburgess
joshburgess / bidirectional-structural.ts
Created July 25, 2018 15:29 — forked from gelisam/bidirectional-structural.ts
bidirectional type-checker in TypeScript
// in response to https://twitter.com/arntzenius/status/1022076441603829760
// types A,B ∷= base | A → B
// terms M ∷= E | λx.M
// exprs E ∷= x | E M | (M : A)
type Type = "Base" | {lhs: Type, tag: "->", rhs: Type};
type Var = string;
type Term = Expr | {tag: "Lam", varname: Var, body: Term};
type Expr = Var | {tag: "App", fn: Expr, arg: Term} | {term: Term, tag: ":", tp: Type};
const Day = ({ get, left, right }) => {
const map = f => Day ({
get: f (extract()),
left, right
})
const extend = f =>
Day ({
get: (left, right) => f (Day ({ get, left, right })),
@joshburgess
joshburgess / README.md
Created August 10, 2018 01:14 — forked from bfncs/README.md
Slaying a UI Antipattern with TypeScript & TsMonad

Technical overview

A basic Option type

// Option.ts

// definition
export class None {
  readonly tag: 'None' = 'None'
@joshburgess
joshburgess / README.md
Created September 10, 2018 21:56 — forked from OliverJAsh/README.md
FP list combinators demo with fp-ts
tsc && node main.js
@joshburgess
joshburgess / algebraic.ts
Created September 11, 2018 18:14 — forked from SimonAlling/algebraic.ts
Algebraic Data Types in TypeScript
// Types:
type Just<T> = { Just: T }
type Nothing = {}
type Maybe<T> = Just<T> | Nothing
type Left<L> = { Left: L }
type Right<R> = { Right: R }
type Either<L, R> = Left<L> | Right<R>
// For convenience:
@joshburgess
joshburgess / UIPattern.re
Created September 11, 2018 23:56 — forked from busypeoples/UIPattern.re
Slaying a UI Anti Pattern in ReasonML
/*
Slaying a UI Anti Pattern in ReasonML
Based on Kris Jenkins original writing.
http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html
*/
type remoteData 'e 'a =
| NotAsked
| Loading
| Failure 'e
| Success 'a;
type Init<T extends any[], TTail extends any[] = TailArray<T>> = CastArray<{
[K in keyof TTail]: T[keyof T & K];
}>
type PotentialArgs<T extends any[], TResult extends any[] = T> = {
"continue": PotentialArgs<Init<T>, TResult | Init<T>>;
"end": TResult;
}[T extends [] ? "end" : "continue"]
type Args<T extends Function> =