Skip to content

Instantly share code, notes, and snippets.

@apskii
apskii / gist:1787071
Created February 10, 2012 06:00
cl-hacking with macroexpand-hook
(defvar *source-storage* (make-hash-table))
(defun source-of (name)
(gethash name *source-storage*))
(defun source-save-hook (expander form env)
(when (eq (car form) 'defun)
(setf (gethash (cadr form) *source-storage*)
form))
(funcall expander form env))
data T = SymT Id
| StrT String
| IntT Integer
| ChrT Char
| LisT [T]
| CloT Env Id T
-------------------------------------------------------------------------
(~|~) = (() <$) .: (<|>)
{-# Language TemplateHaskell, QuasiQuotes, FlexibleContexts #-}
module Main where
import Text.Peggy hiding ( Expr, parse )
import Text.Peggy.LeftRec
import Prelude
type Id = String
data Prog = Prog Id [Decl] Stmt deriving (Show)
import scala.reflect.runtime.universe._
import scala.tools.reflect.Eval
object O {
type A = {
type B = {
type C = O.type
}
}
}
@apskii
apskii / ffixed_ebx_as_global_counter.c
Created February 15, 2013 13:31
gcc -std=c99 -ffixed-ebx
#include <stdio.h>
#include <stdint.h>
uint32_t quux(void) {
uint32_t ebx;
__asm ("inc %ebx");
__asm ("mov %%ebx, %0" : "=r"(ebx));
return ebx;
}
#include <iostream>
using namespace std;
template <typename Type>
typename Type::Repr quux(Type sig, typename Type::Repr val) {
return val;
}
template <typename Type>
module Dual where
import Prelude.Unicode
import Data.List
import Control.Applicative
data Term = Term :$: [Term]
| Term :→: Term
| Id String
{-# LANGUAGE NoMonomorphismRestriction, MultiParamTypeClasses, GADTs, StandaloneDeriving,
TypeFamilies, ConstraintKinds, TypeOperators, TupleSections,
NoImplicitPrelude #-}
import BasicPrelude hiding ((.), id, Map, Set)
import GHC.Prim
import Data.Map (Map)
import Data.Set (Set)
import qualified Data.Map as M
import qualified Data.Set as S
// Enviance Form Filler
// ---------------------------------------------------------------------------------------------
//
// Form-filling script for custom enviance applications.
// Currently can into many basic things but doesn't support complex dependencies between fields.
//
// ---------------------------------------------------------------------------------------------
//
// ==UserScript==
// @name Enviance Form Filler
module KV where
open import Data.Nat hiding (_⊔_)
open import Data.Unit
open import Data.List using (List; []; _∷_)
open import Data.Empty
open import Data.Maybe
open import Data.Product
open import Function
open import Relation.Binary.Core