Commit graph

44 commits

Author SHA1 Message Date
1fdeb08f19 TreeExplorer: finished and unit test PASS
several extensions and convenience features are conceivable,
but I'll postpone all of them for later, when actual need arises

Note especially there is one recurring design challenge, when creating
such a demand-driven tree evaluation: more often than not it turns out
that "downstream" will need some information about the nested tree structure,
even while, on the surfice, it looks as if the evaluation could be working
completely "linearised". Often, such a need arises from diagnostic features,
and sometimes we want to invoke another API, which in turn could benefit
from knowing something about the original tree structure, even if just
abstracted.

I have no real solution for this problem, but implementing this pipeline builder
leads to a pragmatic workaround: since the iterator already exposes a expandChildren(),
it may as well expose a depth() call, even while keeping anything beyond that
opaque. This is not the clean solution you'd like, but it comes without any
overhead and does not really break the abstraction.
2017-12-17 03:02:00 +01:00
7ed1948a89 TreeExplorer: refactor to make depth() reflect the logical expansion depth
...so sad.
The existing implementation was way more elegant,
just it discarded an exahusted parent element right while in expansion,
so effectively the child sequence took its place. Resolved that by
decomposing the iterNext() operation. And to keep it still readable,
I make the invariant of this class explicit and check it (which
caught yet another undsicovered bug. Yay!)
2017-12-16 19:21:22 +01:00
add5046c6e TreeExplorer: maybe pragmatic workaround for the remaining design problem
instead of building a very specific collaboration,
rather just pass the tree depth information over the extended iterator API.
This way, "downstream" clients *can* possibly react on nested scope exploration
2017-12-16 06:18:44 +01:00
53efdf6e2b TreeExplorer: investigate logical contradiction in this design
We get conflicting goals here:
 - either the child expansion happens within the opaque source data
   and is thus abstracted away
 - or the actual algorithm evaluation becomes aware of the tree structure
   and is thus able to work with nested evaluation contexts and a local stack
2017-12-15 00:32:30 +01:00
30775b2b32 TreeExplorer: draft demonstration example for a search algorithm
...build on top of the core features of TreeExplorer
- completely encapsulate and abstract the source data structure
- build an backtracking evaluation based on layered evaluation
  of this abstracted expandable data source

NOTE: test passes compilation, but doesn't work yet
2017-12-14 03:06:19 +01:00
46287dac0e TreeExplorer: Monads are of limited usefulnes
...and there is a point where to stop with the mere technicalities,
and return to a design in accordance with the inner nature of things.

Monads are a mere technology, without explicatory power as a concept or pattern

For that reason
 - discard the second expansion pattern implemented yesterday,
   since it just raises the complexity level for no given reason
 - write a summary of my findings while investigating the abilities
   of Monads during this design excercise.
 - the goal remains to abandon IterExplorer and use the now complete
   IterTreeEplorer in its place. Which also defines roughly the extent
   to wich monadic techniques can be useful for real world applications
2017-12-11 02:21:32 +01:00
4ef1801a6f TreeExplorer: draft how depth-first-to-leafs might be implemented
...it can sensibly only be done within the Expander itself.
Question: is this nice-to-have-feature worth the additional complexity
of essentially loading two quite distinct code paths into a single
implementation object?

As it stands, this looks totally confusing to me...
2017-12-11 02:20:15 +01:00
13d32916ee TreeExplorer: implement simple auto-expansion
...just expand children instead of normal iteration;
works out of the box, since expansion itself performs a iteration step.
2017-12-10 00:24:36 +01:00
fd5d44f6ca TreeExplorer: draft next case -- auto-expand children
this leads to either unfolding the full tree depth-first,
or, when expanding eagerly, to delve into each sub-branch down to the leaf nodes

Both patterns should be simple to implement on top of what we've built already...
2017-12-09 19:42:22 +01:00
e242053620 TreeExplorer: document wrapping into IterSource 2017-12-09 18:41:35 +01:00
c7e37c29e6 TreeExplorer / IterSource: document design mismatch (-> Ticket #1125)
IterSource should be refactored to have an iteration control API similar to IterStateWrapper.
This would resolve the need to pass that pos-pointer over the abstraction barrier,
which is the root cause for all the problems and complexities incurred here
2017-12-09 06:24:57 +01:00
f300545232 TreeExplorer: investigate wrong behaviour in test
turns out that -- again -- we miss some kind of refresh after expanding children.
But this case is more tricky; it indicates a design mismatch in IterSource:
we (ab)use the pos-pointer to communicate iteration state. While this might be
a clever trick for iterating a real container, it is more than dangerous when
applied to an opaque source state as in this case. After expanding children,
the pos-pointer still points into the cache buffer of the last transformer.
In fact, we miss an actualisation call, but the IterSource interface does not
support such a call (since it tries to get away with state hidden in the pos pointer)
2017-12-09 03:49:59 +01:00
7f6bfc1e45 TreeExplorer: implement wrapping opaquely into an IterSource 2017-12-09 01:17:50 +01:00
681cfbfd8c TreeExplorer: add warning due to the moving builder operations
this was a design decision, but now I myself run into that obvious mistake;
thus not sure if this is a good design, or if we need a dedicated operation
to finish the builder and retrieve the iterable result.
2017-12-08 05:34:28 +01:00
ce1ee71955 TreeExplorer: clarify base initialisation
as it turned out, when "inheriting" ctors, C++14 removes the base classes' copy ctors.
C++17 will rectify that. Thus for now we need to define explicitly that
we'll accept the base for initialising the derived. But we need do so
only on one location, namely the most down in the chain.
2017-12-08 05:32:04 +01:00
aa008d6d4a TreeExplorer: draft my requirements for packaging a TreeExplorer pipeline as IterSource
Since this now requires to import iter-adapter-stl.hpp and iter-source.hpp
at the same time, I decided to drop the convenience imports of the STL adapters
into namespace lib. There is no reason to prefer the IterSource-based adapters
over the iter-adapter-stl.hpp variants of the same functionality.
Thus better always import them explicitly at usage site.


...actual implementation of the planned IterSource packaging is only stubbed.
But I needed to redeclare a lot of ctors, which doesn't seem logical
And I get a bad function invocation from another test case which worked correct beforehand.
2017-12-07 05:48:36 +01:00
9b9dcb2b78 TreeExplorer: add yet another convoluted example
Yay!
...and all of this works flawless right away
2017-12-07 03:11:11 +01:00
160a5e5465 TreeExplorer: cover further flavours of predicate definition 2017-12-07 02:19:19 +01:00
2eacde7f2c TreeExplorer: draft the filter operation
should be low hanging fruit now....
2017-12-06 02:33:32 +01:00
085b304a38 TreeExplorer: finish test coverage of expand+transform 2017-12-06 02:02:22 +01:00
52edf7d930 Refactoring: switch IterStateWrapper to member function based API
Considering the fact that we are bound to introduce yet another iteration control function,
because there is literally no other way to cause a refresh within the IterTreeExplorer-Layers,
it is indicated to reconsider the way how IterStateWrapper attaches to the
iteration control API.

As it turns out, we'll never need an ADL-free function here;
and it seems fully adequate to require all "state core" objects to expose
the API as argument less member function. Because these reflect precisely
the contract of a "state core", so why not have them as member functions.
And as a nice extra, the implementation becomes way more concise in
all the cases refactored with this changeset!

Yet still, we stick to the basic design, *not* relying on virtual functions.
So this is a typical example of a Type Class (or "Concept" in C++ terminology)
2017-12-05 03:28:00 +01:00
81c6136509 TreeExplorer: define interaction between expand and transform-operation
good news: it (almost) works out-of-the-box as expected.

There is only one problem: expandChildren() alters the content of the
data source, yet downstream decorators aren't aware of that fact and
continue to present cached evaluations, until the next iterate() call
is issued. Yet unfortunately this iterate already consumes the first
of the expanded children, which thus gets shadowed by the cached
outcome of parent node already consumed and expanded at that point

See the first example:

"10-8-expand-8-4-2-6-4-2"
should be 6 ^^^
2017-12-04 06:11:08 +01:00
823848db37 TreeExplorer: document arcane special case
...which happens to be supported out of the box,
due to the generic adaptor magic shared with the explore-operation

Exploiting this feature, some functor could even subvert the layering order
2017-12-04 04:34:27 +01:00
ca270028a9 TreeExplorer: transform-operation implemented and covered in test 2017-12-04 04:34:27 +01:00
b5453cc429 TreeExplorer: reimplementation with simpler design
- always layer the TreeExplorer (builder) on top of the stack
- always intersperse an IterableDecorator in between adjacent layers
- consequently...
  * each layer implementation is now a "state core"
  * and the source is now always a Lumiera Iterator

This greatly simplifies all the type rebindings and avoids the
ambiguities in argument converison. Basically now we can always convert
down, and we just need to pick the result type of the bound functor.

Downside is we have now always an adaptation wrapper in between,
but we can assume the compiler is able to optimise such inline
accessors away without overhead.
2017-12-04 04:34:26 +01:00
e58e4553f4 TreeExplorer: make the Core -> Core design work, kind of
...yet this seems like a rather bad idea,
it breeds various problems and requires arcane trickery to make it fly

==> abandon this design
==> always intersperse an IterableDecorator between each pair of Layers
2017-12-04 04:34:24 +01:00
a3a64147c1 TreeExplorer: implementation draft for the transform-operation
attempt to re-use the same traits as much as possible

NOTE: new code not passing compiler yet, but refactored old code
      does, and still passes unit test
2017-11-30 03:52:32 +01:00
09a263431c TreeExplorer: note further functionality to supplement
- add a filter (should be low hanging fruit)
- wrap the result as IterSource
2017-11-28 03:53:38 +01:00
5b86b660ae TreeExplorer: draft functionality of transform-operation 2017-11-28 03:53:09 +01:00
134821ca15 DOC: document some of the language limitations highlighted by this research 2017-11-27 05:39:47 +01:00
d8f7a22123 TreeExplorer: cover all the remaining cases supported for the expansion functor 2017-11-27 05:07:06 +01:00
86856390e1 TreeExplorer: cover expansion using a different result type
here using a lambda with side-effect and returning a reference to
a STL collection with the children, which is managed elsewhere.
2017-11-27 05:07:06 +01:00
6667a51a61 TreeExplorer: cover another use case expand( Val -> iter<Val> )
...which uncovered an error in the test fixture
plus helped to spot the spurious copy when passing the argument to the expand functor

And my GDB crashed when loading the executable, YAY!
so we'll need to coment out some code from now on,
until we're able to switch to a more recent toolchain  (#1118)
2017-11-26 22:35:43 +01:00
bb948bff34 TreeExplorer: working solution to accept generic lambda
but possible only for the iterator -> iterator case

Since we can not "probe" a generic lambda, we get only one shot:
we can try to bind it into a std::function with the assumed signature
2017-11-25 02:16:21 +01:00
01937f9736 Research: possiblity to detect a generic Lambda? 2017-11-24 23:48:56 +01:00
18553f22b2 TreeExplorer: cover both variants of functor signature by unit test (PASS) 2017-11-23 03:29:26 +01:00
f10e66e4ae TreeExplorer: design a solution to handle expansion of children
this solution makes me feel somewhat queasy..
stacking several adaptors and wrappers and traits on top of each other.

Well, it type checks and passes the test, so let's trust functional programming
2017-11-20 01:03:44 +01:00
d10c5a4f77 TreeExplorer: draft the core (explore) operation
The plan is to use a monad-like scheme, but allow for a lot of leeway
with respect to the src and value types of the expand functor.
A key idea is to allow for a *different* state core than used in the source
2017-11-19 20:36:19 +01:00
cbb35d7161 TreeExplorer: add shortcut to adapt STL container automatically
...selecting the iterator or const iterator as apropriate
2017-11-19 17:35:00 +01:00
fd3d6fb60e TreeExplorer: first testcase, build either from Lumiera-Iterator or use StateCore
TODO: also wrap any suitable STL iterable.
we need a one-shot solution here
2017-11-19 02:28:48 +01:00
2345d76138 Research: how to detect that a type in question exposes a free function extension point
The key trick is to form an expression with the free function, using a declval of the type to probe.
What is somewhat tricky is the fact that functions can be void, so we need just to pick up
the type and use it in another type expression
2017-11-19 00:35:38 +01:00
a7bdc05091 WIP: draft first testcase
...just wrapping various kinds of iterators
2017-11-18 18:40:30 +01:00
c3b04af76f TreeExplorer: decide upon the steps towards implementation
Here, the tricky question remains, how to relate this evalutaion scheme
to the well known monadic handling of collections and iterators.

It seems, we can not yet decide upon that question, rather we should
first try to build a concrete implementation of the envisioned algorithm
and then reconsider the question later, to what extent this is "monadic"
2017-11-18 03:00:59 +01:00
782b4f949f TreeExplorer: extended analysis regarding tree expanding and backtracking computation (#1117)
This can be seen as a side track, but the hope is
by relying on some kind of monadic evaluation pattern, we'll be
able to to reconcile the IterExplorer draft from 2012 with the requirement
to keep the implementation of "tree position" entirely opaque.

The latter is mandatory in the use case here, since we must not intermingle
the algorithm to resolve UI-coordinates in any way with the code actually
navigating and accessing GTK widgets. Thus, we're forced to build some kind
of abstraction barrier, and this turns out to be surprisingly difficult.
2017-11-17 21:43:50 +01:00