Vicente J. Botet Escriba
Le 24/06/15 18:39, Louis Dionne a écrit :
John Bytheway
writes: [...]
Mostly very good, but of course there is always room for improvement. One particular thing I wanted to raise here is that I struggled to find enough information about Hana-convertibility (i.e. using the 'to' function). For example, I wondered if I could create a Tuple from a Range, and it seems I can. Then I wondered whether I could create a std::Array from a homogeneous Tuple, but it seems I cannot. A Tuple is a Sequence, and a Sequence can be created from any Foldable. Since a Range is Foldable, it works. However, a std::array is _not_ a Sequence.
Couldn't std::array
be considered the empty Array and so Array could be considered a homogeneous sequence?
The problem is that a homogeneous sequence (in Hana's mathematical universe) is a sequence whose tags are homogeneous. Hence, a tuple containing IntegralConstant<int> objects only is a homogeneous sequence for Hana's concepts. Hence, a std::array is not powerful enough to hold Hana-homogeneous data. Indeed, the following is Hana-homogeneous but not homogeneous in the usual C++ sense: auto xs = make_tuple(int_<1>, int_<2>, int_<3>); It is Hana-homogeneous because all the int_s have the IntegralConstant<int> tag, but it is not C++-homogeneous because they all have different C++ types. Again, the concern here is being correct mathematically, but there's no other technical reason why this can't be done. Ideally, I'd like to be mathematically correct while also providing this functionality, or similar.
[...]
See how we make an arbitrary choice to use the type of the first element of the sequence for `T`? This, and the fact that it will only work when the Sequence happens to contain elements of a single type, are what breaks naturality. Why not request that the sequence is homogeneous?
My answer to your other question above should also answer this one. If not, let me know and I'll gladly clarify. Regards, Louis