Skip to content

Instantly share code, notes, and snippets.

View acfoltzer's full-sized avatar

Adam C. Foltzer acfoltzer

View GitHub Profile
@acfoltzer
acfoltzer / cas.hs
Created December 8, 2011 16:37
Pointer equality woes
import Data.CAS
import Data.IORef
test1 = do ref <- newIORef 0
let old = 0
new = (old+1)
casIORef ref old new
test2 = do let old = 0
ref <- newIORef old
@acfoltzer
acfoltzer / tagless.hs
Created November 27, 2011 23:01
Tagless final games
-- No LANGUAGE pragmas! This is all barebones Haskell.
-- $ ghc --make -O2 -fllvm -fforce-recomp tagless.hs
import Control.Applicative
import Control.Monad.Reader hiding (fix)
import Control.Monad.State hiding (fix)
import Criterion.Main
-- An example of how multiple backends can be achieved for an EDSL
@acfoltzer
acfoltzer / gist:1321567
Created October 28, 2011 03:38
No stacks to overflow here...
import java.util.Formatter;
public class _interp {
//labels
static final int _value$_of = 0;
static final int _apply$_k = 1;
static final int _apply$_env = 2;
static final int _apply$_proc = 3;
//registers
@acfoltzer
acfoltzer / gist:1242902
Created September 26, 2011 18:09
Prototype heterogenous unifier
{-# LANGUAGE GADTs #-}
import Control.Applicative
import Data.Dynamic
import Data.Maybe
type Id = Integer
data Val where
Var :: Id -> Val
@acfoltzer
acfoltzer / gist:1052530
Created June 28, 2011 23:50
PG variables
(*
*** Local Variables: ***
*** coq-prog-name: "coqtop" ***
*** coq-prog-args: ("-emacs-U" "-I" "sf") ***
*** End: ***
*)