Skip to content

Instantly share code, notes, and snippets.

View aztek's full-sized avatar

Evgenii Kotelnikov aztek

View GitHub Profile
import language.experimental.macros
import reflect.macros.Context
object WeirdMacro {
def show_structure(something: Any): String = macro show_structure_impl
def show_structure_impl(c: Context)(something: c.Expr[Any]): c.Expr[String] = {
import c.universe._
c.Expr[String](Literal(Constant(something.tree.toString)))
@aztek
aztek / Functor.v
Created June 11, 2012 17:11
Coq Functor type class with statically checked functor laws
Require Import Coq.Program.Basics.
Require Import Coq.Program.Syntax.
Require Import Coq.Init.Datatypes.
Require Import Coq.Unicode.Utf8.
Open Local Scope program_scope.
Open Local Scope list_scope.
Open Local Scope type_scope.
Class Functor (φ : Type → Type) := {
@aztek
aztek / IntegerFunctions.scala
Created April 27, 2012 20:41
Scala functions defined in JavaBeans
package com.myapp
object IntegerFunctions {
val increment: Int => Int = _ + 1
val decrement: Int => Int = _ + 1
val lolNoIntegers: String => String = _ + "!!!"
}
@aztek
aztek / factorial.cpp
Created November 8, 2011 20:56
Compile-time factorial in C++
#include <iostream>
using namespace std;
template <int N> struct Factorial {
enum { value = N * Factorial<N - 1>::value };
};
template <> struct Factorial<0> {
enum { value = 1 };
};