Official support for views
The goal of this PR is to officially support views, which are only experimental right now.
Still left to do:
- [x] Move view types out of the
experimentalnamespace, perhaps intodetail - [ ] ~~Consider providing access to the
flattenedmethods & al.~~ (not at first) - [x] Test nested views
- [ ] Add examples
- [ ] Document views in the tutorial (requires some rewording of the sections on containers and on algorithms)
- [ ] ~~Provide operators~~ (not at first)
- [x] Provide a non-dummy implementation of
hana::equal(thanks @ricejasonf) - [x] Provide a non-dummy implementation of
hana::ap(thanks @ricejasonf) - [ ] ~~Consider providing a
filtered_view~~ (not at first)
I have a PR for equal, and I'd like to do ap as well. It appears that detail::cartesian_product_indices provides an interface that should make that easy to implement. A cartesian_product view looks pretty easy with that as well.
I'm striking a few things that I marked as being required to ship this PR. Given my lack of time to work on Hana (very sadly), I'm going to go for a minimal implementation for the sake of shipping this. This PR is important and it has been sitting around for way too long.
I didn't actually do ap yet, but it should be trivial now.
I could help with tests too if that is welcome.
I think the tests for ap are okay, what I'm mostly concerned about is tests for the rest of the functionality. For example, filter should work currently because view_tag implements MonadPlus, but I'm fairly confident it won't work properly (either compilation error or dangling reference) based on looking at how single_view is implemented.
So yeah, I'd welcome help on making the tests more robust. I'm happy to tackle the documentation side.
Are we going to make the views Sequence or is that some kind of violation?
(can't remember if I already asked this)
They can't be Sequences because there's no way to make them from a pack of elements. In other words, they don't have storage like a Container, and Sequence requires that (actually Sequence might be better named Container, since it reflects element ownership).