folly::gen, or Comprehensions->Folly
Summary: Moving Comprehensions library into Folly and refactoring its interface to be much more modular and composable. There are now two core abstractions: # Generators: Standalone classes supporting ##apply()## and optionally ##foreach()##. These all inherit from ##GenImpl<T, Self>##. # Operators: Standalone classes which, when composed with a generator, produce a new generator. These all inherit from ##OperatorImpl<Self>##. These generators may be composed with ##operator|## overloads which only match ##const GenImpl<T, Self>&## on the left like ##gen | op##. Additionally, generator may be consumed inline with ##gen | lambda## like ##gen | [](int x) { cout << x << endl; };##. With this design, new operators may be added very simply without modifying the core library and templates are instantiated only exactly as needed. Example: ```lang=cpp auto sum = seq(1, 10) | filter(isPrime) | sum; seq(1, 10) | [](int i) { cout << i << endl; }; ``` Test Plan: Unit tests Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D542215
Showing
folly/experimental/Gen-inl.h
0 → 100644
This diff is collapsed.
folly/experimental/Gen.h
0 → 100644
This diff is collapsed.
Please register or sign in to comment