Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Bowden jaxrtech

View GitHub Profile
@jaxrtech
jaxrtech / typesafe-ast-nodes.ts
Created May 15, 2018
So you said you wanted typesafe AST nodes (based on TypeScript's compiler design)...
View typesafe-ast-nodes.ts
enum ShapeKind {
Circle,
Rectangle,
Square
}
type Shape =
| Circle
| Rectangle
| Square
View blinks-custom.zsh-theme.zsh
@jaxrtech
jaxrtech / github-tab-fix.js
Created Jan 12, 2018
Tampermonkey Scripts
View github-tab-fix.js
// ==UserScript==
// @name Github Code Tab-Size Fix
// @version 0.1
// @description Sets a reasonably tab-size to make code using tabs a bit more readible
// @match https://github.com/*
// @run-at document-start
// ==/UserScript==
function addGlobalStyle(css) {
var head, style;
@jaxrtech
jaxrtech / lalex_grammar.pegjs
Created Jul 22, 2016
Lalex's grammar in broken PEG.js
View lalex_grammar.pegjs
// Some expressions are from the JavaScript example grammar (which is very useful)
// https://github.com/pegjs/pegjs/blob/master/examples/javascript.pegjs
Program
= Statement+
Statement "statement"
= Expression
/ Comment
@jaxrtech
jaxrtech / static_type_inference.txt
Last active Jul 13, 2016
Idea for inferring and constraining structural types...
View static_type_inference.txt
// `@foo` is a symbol that can be treated as a type or a value
// `a :: T` is a forward type declaration where value `a` is of type `T`
// I'm using this for mainly for explanatory purposes to show what structural
// type inference might allow for
// `<'x>` declares a type variable `'x`
// I've prefixed the type variables with an apostrophe to make clear what is a
// regular type and what a type variable is (borrowing from F#/OCaml notation)
@jaxrtech
jaxrtech / nominal_and_structural.txt
Last active Jul 13, 2016
Idea for Nominal and Structural Types
View nominal_and_structural.txt
alias Named = { name: string }
// same as `type City = { name: string }`
// the structural type on the rhs will get "tagged" by the name on the lhs so
// that the original structural type becomes a nominal type
//
type City = Named
type State = Named
View HoverExample.scala
class HoverComponent extends Component {
// "Leaked" implementation detail of our `HoverSystem`
var time: Float
}
class PositionComponent extends Component {
var x: Float
var y: Float
}
You can’t perform that action at this time.