Skip to content

Instantly share code, notes, and snippets.

View andy-morris's full-sized avatar

andy morris andy-morris

View GitHub Profile
@andy-morris
andy-morris / code.rs
Last active October 11, 2016 10:29 — forked from duckinator/code.rs
#[derive(Clone, Copy)]
struct Op(fn(u16, u16));
// lets you call foo() instead of foo.0() (where foo: Op)
impl std::ops::Deref for Op {
type Target = fn(u16, u16);
fn deref(&self) -> &fn(u16, u16) { &self.0 }
}
fn op_mov(one: u16, two: u16) {
module HSubst
%default total
infixr 0 >>>
data Ty = O | (>>>) Ty Ty
%name Ty a, b, c
namespace Ctx
data Ctx = Nil | (::) Ty Ctx
@andy-morris
andy-morris / gist:4157b6513555415e3127
Created October 26, 2014 20:51
spot the left recursion
ident = tok.ident[&make_id];
id_expr = ident[&make_id_expr];
int_expr = tok.int_[&make_int_expr];
paren_expr %= '(' > expr > ')';
atomic_expr %= id_expr | paren_expr;
lam_expr = ("fn" > ident > "=>" > expr)[&make_lam_expr];
app_expr = (+atomic_expr)[&make_app_expr];
@andy-morris
andy-morris / keybase.md
Last active August 29, 2015 14:07
keybase.md

Keybase proof

I hereby claim:

  • I am andy-morris on github.
  • I am anders_ (https://keybase.io/anders_) on keybase.
  • I have a public key whose fingerprint is F959 A1BE B2A4 90FB 717B 3A16 6F5E 66A3 C97A 20A9

To claim this, I am signing this object:

@andy-morris
andy-morris / blah.hs
Created September 28, 2013 18:09
gloss stuff
import Graphics.Gloss
import Graphics.Gloss.Interface.Pure.Game
main = play w white 60 st0 draw ev advance
w = InWindow "a boring game." (640,480) (30,30)
data State = State {s, x, y, ds, dx, dy :: Float}
st0 = State 10 30 30 0 0 0
@andy-morris
andy-morris / cabal-stow.zsh
Created March 5, 2013 13:00
Cabal + stow = magic
#!/usr/bin/env zsh
cd $STOW_DIR
if [[ -a $1 ]]; then
echo "$1 already exists in stowland!"
exit 1
fi
mkdir $1
cd $1
@andy-morris
andy-morris / Data.Record.TL.hs
Created September 14, 2012 23:07
GHC’s DataKinds pretty printing leaves a bit to be desired
-- WIP
{-# LANGUAGE DataKinds, GADTs, KindSignatures, TemplateHaskell,
ScopedTypeVariables, FlexibleContexts, FlexibleInstances,
UndecidableInstances, QuasiQuotes, RecordWildCards,
TypeOperators #-}
module Data.Record.TL (
type Label(..), l, label, labels,
type Record(..), type (:=), type Field(..), (&),
@andy-morris
andy-morris / gist:3338546
Created August 13, 2012 09:15
luite’s hackage mirror
remote-repo: hdiff.luite.com:http://hdiff.luite.com/packages/archive
@andy-morris
andy-morris / haskellmode-cabal-dev-ghc.zsh
Created June 22, 2012 18:34
Wrapper for ghc with haskellmode & cabal-dev
#!/usr/local/bin/zsh
if [[ -d ./cabal-dev ]]; then
ignoreflags=('-O.*' --make -debug -threaded -ticky '.*\.hs' -prof)
ignorere="/^(${(j'|')ignoreflags})\$/"
argflags=(-package-name -package-conf -odir -hidir -stubdir -package-id)
argre="/^(${(j'|')argflags})\$/"
output=`cabal-dev buildopts` || exit 1
@andy-morris
andy-morris / Foo.java
Created December 7, 2011 02:01
TIL java can break from arbitrary named blocks
class Foo {
static void println(String s) { System.out.println(s); }
public static void main(String args[]) {
println("A");
foo: {
println("B");
if (true) break foo;
println("C");
}