The specialization example is the same as template specialization in C++.
The specialization example is the same as template specialization in C++.
> The specialization example is the same as template specialization in C++.
This sounds very interesting to me, because you're saying it's accomplished entirely in the type system: do you have an example or a reference you can point me to?
I'm guessing there's a type-level tag for an algorithm, and the compiler is told how to combine tags corresponding to a sequence of operations on vectors that looks a certain way. Something like do_the_thing<t, DotWith<Self>, HasFastNorm<t>> = do_the_thing<Norm<t>>? (just thinking aloud in pseudo-C++, nothing to see here, move along) In that case, it would be closer to something using a function on types, which Haskell has in the form of type families.
http://www.cprogramming.com/tutorial/template_specialization...
What you have towards the end of that post is actually something like
type family Vector a where
type instance Vector (Ptr a) = ...
type instance Vector a = ...
This is a closed type family. (Think of it as a pattern-match on types where the cases are tried in order.) Very cool!I still don't know how the linear algebra/Eigen examples might work, though.