I am trying to create some Haskell types that are parameterized not by types, but by type elements, in particular integers. For example, a vector (linear algebra) in R ^ 2 and a vector in R ^ 3 are different typed objects. In particular, I write a KD tree in Haskell, and I want to parameterize my data structure with a positive integer, so the three-dimensional tree and 4-D tree are of a different type.
I tried to parameterize my tree by tuples, but it seems that it will not go anywhere (and it seems that this is unlikely, it can be skipped, especially since it does not seem that triples or anything more functors (and I donβt know, how to say an instance of HomogeneousTuple a => Functor a). I want to do something like this:
data (TupleOfDoubles a) => KDTree ab = ... ---so in a 3DTree a is (Double,Double,Double)
which would be good, or something like that would be equally good
data KDTree Int a = ...
Does anyone know if any of these effects are workable or reasonable?
Thanks joseph
Joseph Victor
source share