Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 15:06

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 24 07:47

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 23 02:04
    pthom commented #432
  • Jan 18 12:46

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 16 22:27
    ricejasonf commented #434
  • Jan 05 06:22
    ricejasonf commented #330
  • Jan 03 11:40

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Jan 02 00:33
    ricejasonf closed #434
  • Jan 02 00:33
    ricejasonf commented #434
  • Jan 02 00:04
    ricejasonf opened #434
  • Dec 27 2018 13:11

    ldionne on gh-pages

    Update benchmarks to 490dbf6 fo… (compare)

  • Dec 22 2018 11:56
    pthom commented #432
  • Dec 22 2018 11:55
    pthom commented #432
  • Dec 21 2018 15:48
    pthom synchronize #432
  • Dec 21 2018 09:19
    sdebionne opened #433
  • Dec 21 2018 00:08
    ricejasonf commented #432
  • Dec 21 2018 00:03
    ricejasonf commented #432
  • Dec 20 2018 23:36
    pthom commented #432
  • Dec 20 2018 23:36
    pthom commented #432
  • Dec 20 2018 23:13
    ricejasonf commented #432
Martchus
@Martchus
Thanks, your help is appreciated. However, I'll have to check the documentation about the usage anyways because it isn't completely obvious.
Alastair Rankine
@randomphrase
Hi, a hopefully quick question for someone. I’ve been struggling to find a solution. I have a std::tuple containing both hana::types and std::tuple<hana::type ...> I want to flatten to a single sequence of just the hana::types.
So for example:
using my_tuple = std::tuple< hana::type<A>, std::tuple< hana::type<B>, hana::type<C> > >;
auto my_types = hana::to_tuple(hana::tuple_t<A, B, C>);
How to easily transform my_tuple so that it is equal to my_types?
For the record it seems that hana::flatten will not work because it requires a sequence of sequences.
Jason Rice
@ricejasonf
An std::tuple is a hana::Sequence but you have to include it. like #include <boost/hana/ext/std/tuple.hpp>
So flatten should in fact work with that.
I think your to_tuple call is unnecessary.
Alastair Rankine
@randomphrase
Yeah I have included that header
As I said though, the reason why flatten doesn’t work is that it requires a sequence of sequences. I have a sequence which includes both sequences and non-sequences.
Jason Rice
@ricejasonf
Ah, I see so hana::type<A> is not wrapped in a tuple
I don't think there is a way around it unless you write a function to use append or concat, but really I would just make sure everything goes in as a tuple even if it only has one element.
Jason Rice
@ricejasonf
or you could use transform to normalize everything afterwards, but it feels kind of hacky:
hana::transform(my_tuple{}, [](auto x) { if constexpr(hana::is_a<hana::ext::std::tuple_tag>(x)) { return x; } else { return std::tuple{x}; } });
Alastair Rankine
@randomphrase
Yeah I think I had attempted something similar using adjust_if(my_tuple{}, [] (auto p) { return !hana::Sequence<decltype(p)>::value; }, hana::just) but it didn’t work.
In my mind I guess I had anticipated that flatten would work the way it does in lisp... maybe I’ll have to rethink this.
Jason Rice
@ricejasonf
Hana is particular about its inputs belonging to the same classification. For instance, you can't concat an std::tuple and a hana::tuple. You can't even add constants of int and unsigned int. It may seem impractical at first, but I've grown to prefer it.
adjust_if makes sense, but you are using hana::just which returns hana::optional. Could that be the problem there?
Alastair Rankine
@randomphrase
Yeah I couldn’t get adjust_if didn’t work because it ended up wrapping everything in a hana::optional, even though my predicate correctly detected sequences and returned false accordingly. So I ended up with a tuple of hana::optional<std::tuple<hana::type<A>, hana::type<B>>>, hana::optional<hana::type<C>>
Is there an online compiler with hana? Perhaps I can post a snippet if anyone is interested.
Austin McCartney
@apmccartney
Jason Rice
@ricejasonf
Yes, you gave it the function hana::justas the third argument. I would use hana::make_tuple. ;)
Alastair Rankine
@randomphrase
@ricejasonf Yeah I tried that too... Ended up with hana::tuple<std::tuple< ... >>. I’ll post a snippet to wandbox soon (thx @apmccartney)
Andreas Pokorny
@APokorny
hm is there prior art for .. compile time graph algorithms?
i.e. topology sort .. coffman graham.... or similar things
Andreas Pokorny
@APokorny
yeah I found that too, but they construct the graph at runtime.. I dont need it there..
Andreas Pokorny
@APokorny
hm can I make an arbitrary variadic template fulfill the iteratable concept of hana..
and just do all operations on template<typename ...Fs> struct foo{};
hmm maybe that makes no sense.. since I cannot call any predicates..
or rather would have to do that with declval..
Jason Rice
@ricejasonf
What are you trying to do exactly? Maybe a code snippet would explain it better.
Andreas Pokorny
@APokorny
right now I try to figure out whether i should try to back my DSL structures with hana tuple and type_c
Andreas Pokorny
@APokorny
I havent played with writing DSLs for some time .. last time was with C++03.. now with gcc/clangs compile time string literals you can easily collect far more information at compile time
but to harness that I have to be able to analyze the graph
The dsl constructs a graph of computational nodes
to evaluate the graph I want to traverse it in the right order and also parallelize the evaluation if there are multiple graphs..
Andreas Pokorny
@APokorny

slightly simplified:

template<char...Name>
struct node_name {};

template<char...Name>
struct input {};

template<char...Name>
struct output {};

template<typename Name, typename Type>
struct node {};

template<typename OutNode, typename Output, typename InNode, typename Input>
struct connection {};

template<typename ...Elements>
struct model {};

...

Andreas Pokorny
@APokorny
each parameter of model is either connection or node.. the order is define by the expression tree
Jason Rice
@ricejasonf
Are all those types really empty? I do something similar, but I've begun refactoring it to use Boost.Mp11.
By similar I mean I take a bunch of tag-like meta information and use it to generate types for different purposes.
Andreas Pokorny
@APokorny
at the moment yes.. I might want to store init parameters in node.. but I am not sure yet whether those would be needed..
so it seems that I could hook into the tag dispatching of hana and use the algorithms then
but I have to implement a lot of them myself for that.. hmm maybe I should just use hana tuple instead
Jason Rice
@ricejasonf
It's not that hard. I even implemented hana::Sequence, but it has the precondition that the types be stateless and default constructible (ie empty)
Andreas Pokorny
@APokorny
what was your motivation to implement a hana concept?
Jason Rice
@ricejasonf
I was already using Hana and needed a way to transform types. In general, implementing its concepts is very useful for generic programming.
... and you get a lot of algorithms for free.
Andreas Pokorny
@APokorny
i mean .. why not stick with tuple?
Jason Rice
@ricejasonf
Pure type programming is a bit faster at compile-time
It gets better and better as the compilers get faster, but hana::tuple has to manage the run-time state of objects which adds to the build time.