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
Louis Dionne
@ldionne
No, not at all!
I mean, do play with it by any means, but don’t wait to ask questions
Shreyans
@shreyans800755

@ldionne I'll try look at the PR and see if it interests me.

Another thing that would be useful is to add a concept for those set theoretic operations.

Wouldn't this require latest gcc7.x (with c++17 support, basically) ? And what about the backward compatibility ?

Jason Rice
@ricejasonf
Hana has its own method for simulating concepts which are basically traits
Shreyans
@shreyans800755
Oh okay.
Jason Rice
@ricejasonf
Shreyans
@shreyans800755
:smiley:
Looks like a big video, will have a look as time permits
Jason Rice
@ricejasonf
at 11:07 it goes over hana concepts
Barrett Adair
@badair

Is monadic_fold_left the best way to flatten something like this (an edge list)...

hana::tuple<
    hana::pair<A, B>,
    hana::pair<A, C>,
    hana::pair<A, D>,
    hana::pair<B, C>,
    hana::pair<B, D>>

...into something like this (an adjacency list)?

hana::tuple<
    hana::pair<A, hana::tuple<B, C, D>>,
    hana::pair<B, hana::tuple<C, D>>>
Jason Rice
@ricejasonf
like a "group_by"?
Barrett Adair
@badair
exactly
Jason Rice
@ricejasonf
do you have a working example?
Barrett Adair
@badair
No. I have my own implementation of group_by but it sucks
Jason Rice
@ricejasonf
if there is only A and B then partition would be really fast
Barrett Adair
@badair
There are more than A and B. Does hana have a group by operation? If not, is there interest in a PR?
Jason Rice
@ricejasonf
boostorg/hana#324
I have a couple of use cases for one
Having it build a map would be ideal (I think)
perhaps ignore that code I posted in there :P
Barrett Adair
@badair
I agree. I see that there is "group" in hana, but it looks like it excludes the predicate result from the group result
Jason Rice
@ricejasonf
I'm certain a PR for that would be welcome.
Barrett Adair
@badair
Clang 4 and Clang 5 give weird constexpr errors here (compiler bug?), and GCC 7 doesn't yield the result I would expect. Trying to group by first type in a pair -- is my predicate wrong? I think so, because the ordering of the input tuple elements affects the output type by more than just the output order. What's the best way to do this?
#include <utility>
#include <type_traits>
#include <boost/hana.hpp>

namespace hana = boost::hana;

struct A{};
struct B{};
struct C{};
struct D{};

int main() {

    auto grouped = hana::group(
        hana::make_tuple(
            std::pair<A, B>{},
            std::pair<A, C>{},
            std::pair<B, C>{},
            std::pair<A, D>{},
            std::pair<B, D>{}),
        hana::comparing([](auto t){ return hana::type_c<decltype(t.first)>; }));

    // print type as error message
    decltype(grouped)::asdfasdfasdf();
}
Louis Dionne
@ldionne
Jason Rice
@ricejasonf
There is a workaround for that problem in clang c++1z https://bugs.llvm.org/show_bug.cgi?id=28337#c3
Louis Dionne
@ldionne
Ah, thanks for the heads up.
Shreyans
@shreyans800755

@badair You can print the type of complex templated data type using the following:

template<typename T>
void print_T() { std::cout << __PRETTY_FUNCTION__ << '\n'; }
print_T(decltype(grouped));

FYI

Instead of getting it as error message
Jason Rice
@ricejasonf
I had no idea you could do that. Your print_T has to take a T as an argument though.
The problem with that is that you have to include iostream, compile and run the program to see what T is. still a neat trick
Barrett Adair
@badair

So, what is the best way to transform this:

hana::tuple<
    hana::pair<A, B>,
    hana::pair<A, C>,
    hana::pair<B, C>,
    hana::pair<A, D>,
    hana::pair<B, D>>

into something like this:

hana::tuple< /*map*/
    hana::pair<A, hana::tuple<B, C, D>>,
    hana::pair<B, hana::tuple<C, D>>>
I'm playing around with monadic_fold_left
Jason Rice
@ricejasonf
Is using monadic_fold_left a requirement?
Barrett Adair
@badair
nope
I have a compile-time list of pairs that I want to transform/flatten into a map of first -> tuple<second...> if that makes sense
I'm exploring some ideas for a compile-time graph
Jason Rice
@ricejasonf
I think sort then group would be good unless there are only two keys then partition would be better
Barrett Adair
@badair
okay thanks
what if the types don't have an ordering though
Jason Rice
@ricejasonf
oh yeah :sweat_smile:
You could even use fold_left but it will be very slow
I'll take a hack at it later
Barrett Adair
@badair
I did it with fold_left like this
but it's probably a slow way to do it
Louis Dionne
@ldionne
@badair @ricejasonf For info, I’m trying to fix C++1z issues: boostorg/hana#361
Jason Rice
@ricejasonf
Sweet!
Barrett Adair
@badair
Is there a customization point for Hashable in the same way that you can define equal to satisfy Comparable?
Jason Rice
@ricejasonf
hana::hash_impl
Do you really need that?
Barrett Adair
@badair
is that part of the stable interface?