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 / CNEx.hs
Created October 14, 2011 11:26
purity police, arrest this man
{-# LANGUAGE DeriveDataTypeable #-}
module CNEx where
import Prelude hiding (catch)
import Data.Typeable
import Control.Exception
import System.Random
import System.IO.Unsafe
data ChuckNorris = ChuckNorris deriving (Typeable)
@andy-morris
andy-morris / gist:1378940
Created November 19, 2011 15:13
wootles
anders:DisML ± cat f.dis {git:DisML@pretty}!
fun type f: int*int -> int
| f (x,y) if x < y = x+y+7
| ... if x == y = x+y
| ... = y-x
anders:DisML ± dist/build/DisML/disml < f.dis {git:DisML@pretty}!
Program {unProgram = [TLDecls [FunDecl [FunD (Just (FunType (Id "f") (Type []
@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");
}
@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 / 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 / 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 / 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 / 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 / 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 / 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];