Open godefv opened 5 years ago
Checkout hana::tuple
, hana::lazy
, or hana::optional
Here the operator|
is typically used with hana::Monad
s
For point-free programming check out Boost.Hof
ok, I didn't know about that. It seems that the idea of the operator| for monads is indeed chaining functions, but it doesn't work to chain transforms, folds, etc, right ?
I have tried to used boost::hana::operator|
like this :
map|boost::hana::values
|[](auto const& x){return boost::hana::transform(x, func);}
|[](auto const& x){return boost::hana::fold(x, boost::hana::union_);}
The compiler complains that transform requires a functor as x.
So, I have defined myself auto operator|(T&&, Invokable<T>&&)
.
Without the Invokable
constraint, it conflicts with boost::hana::operator|
, but with it, it seems to work.
It would be nicer to be able to use boost::hana::transform(boost::hana::_, func)
. Is it intended that this syntax is not allowed ? EDIT : actually, I have not tried it again with my own operator, it might work...
The placeholder _
is just an object that supports some operators. Boost.Hof is probably what you are looking for if you want high order functions.
It would be nice to have the same syntax as the ranges TS.
For example, instead of
I would write