Skip to content

Instantly share code, notes, and snippets.

@drostron
drostron / tohProduction.txt
Created November 15, 2012 18:06
Towers of Hanoi production in reference to https://gist.github.com/66925
read L as Left, R as Right, C as Center
moveN
m1:Move[Succ[_0],L,C,R]
m2:Move[_0,L,R,C] production side effect "Move from Left to Right" via move0
m3:Move[Succ[_0],C,R,L]
produces Move[Succ[_1](_2),L,R,C]
moveN
m1:Move[_0,L,R,C] production side effect "Move from Left to Right" via move0
@drostron
drostron / PhantomTypes.scala
Created November 9, 2012 17:40
Phantom Types Exploration
object PhantomTypes {
trait State; trait Closed extends State; trait Open extends State
class SingleCallOps[A <: State, B <: State] {
def a(implicit a: A =:= Open) = SingleCallOps.as[Closed, B]
def b(implicit b: B =:= Open) = SingleCallOps.as[A,Closed]
}
object SingleCallOps {