I was wondering if there anyone had any rules of thumb for when to create parametric types of a parametric types (if this is even possible?).
To give a concrete example, I was messing around to describe/implement elliptic curve point addition: # ring of integers mod P immutable Z{P} <: PAdicInteger val::Integer Z(val) = new(mod(val, P)) end immutable EC{P} # elliptic curve a::Z{P} b::Z{P} f::Function EC(a, b) = new(a, b, x -> Z{P}(x^3 + a*x + b)) end Which works great (and I can add some neat methods cleanly), however I then want a type dependent on an elliptic curve, the solutions of that curve (so I can define addition), something like: immutable ECPoint{EC{P}} x::Z{P} y::Z{P} ECPoint(x, y) = y^2 == EC.f(x) ? new(x, y) : error("($x,$y) not a solution of $EC") end This doesn't compile. I can put the EC as an attribute (and assert I'm using equal ECs in every method), but to me it seems "nicer" to rely on the type system. Is there a trick here for types dependant of parametric types? Am I just thinking about this "wrong"? Best, Andy p.s. no doubt I'm reinventing the julia wheel with p-adics and elliptic curves... :)