1 Aug 2008 21:40
compiler weirdness with crazy types
Sorry for the vague subject, I'm not sure how else to describe this. This is based on some thinking about the following blog post: http://michid.wordpress.com/2008/07/30/meta-programming-with-scala-part-ii-multiplication/#comment-69 Consider: object Church { abstract class Zero abstract class Succ[T] type _0[s[_], z] = z type _1[s[_], z] = s[z] type _2[s[_], z] = s[s[z]] type _3[s[_], z] = s[s[s[z]]] type _4[s[_], z] = s[s[s[s[z]]]] trait apply1[t[_[_],_],u[_]] { type It[a] = t[u,a] } type mul[m[s[_], z], n[s[_], z], s[_], z] = m[apply1[n,s]#It, z] type x[m[s[_], z], n[s[_], z]] = mul[m, n, Succ, Zero] type three = _3 x _1 //type four = _2 x _2 type six = _2 x _3 type eight = _4 x _2 } This code compiles fine. We can even use the defined types! But if we(Continue reading)
RSS Feed