Skip to content

Instantly share code, notes, and snippets.

View msiegenthaler's full-sized avatar

Mario Siegenthaler msiegenthaler

View GitHub Profile
import scala.annotation.implicitNotFound
import scala.reflect._
object Protocol extends App {
def witness = null
sealed trait Action
sealed trait End extends Action
sealed trait Receive[Value, Next <: Action] extends Action
sealed trait Send[V, Next <: Action] extends Action {
@msiegenthaler
msiegenthaler / import_bitbucket.rb
Created April 10, 2013 18:50
Import a whole directory structure of GIT repositories into bitbucket.
require 'find'
base = '/your/repostructure/root'
repo = 'you' # Bitbucket user
user = 'you'
pass = 'pass'
Find.find('../gits') do |path|
if File.basename(path) == '.git'
gitpath = File.dirname(path)
@msiegenthaler
msiegenthaler / gist:2361997
Created April 11, 2012 19:58
HList and TypeEq
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, ScopedTypeVariables, UndecidableInstances, OverlappingInstances #-}
module OptTest () where
data HTrue
data HFalse
class HBool b where hBool :: b -> Bool
instance HBool HTrue where hBool _ = True
instance HBool HFalse where hBool _ = False
@msiegenthaler
msiegenthaler / Union.scala
Created June 22, 2011 21:11
Union Type in Scala with some experimental functions on top of it (like toEither)
import annotation.implicitNotFound
package object union {
private type ¬[A] = A => Nothing
private type ¬¬[A] = ¬[¬[A]]
private type ∧[A, B] = A with B
private type ∨[A, B] = ¬[∧[¬[A], ¬[B]]] // since (A ∨ B) ⇔ ¬(¬A ∧ ¬B)
sealed trait UnionInstance[A, B, T, -From, +To] {