hof icon indicating copy to clipboard operation
hof copied to clipboard

Provide a framework for the user to define adaptors

Open pfultz2 opened this issue 8 years ago • 6 comments

pfultz2 avatar Mar 15 '16 20:03 pfultz2

This is not what I read as comment during the review. The reviewer requested to show how an adaptor is written.

viboes avatar Mar 15 '16 20:03 viboes

Having a framework to build adaptors can simplify the building of adaptors in the library, and simplify how they could be defined by the user.

pfultz2 avatar Mar 15 '16 21:03 pfultz2

You are right, but people want to know how to define flat adaptors as the ones you have defined.

having other functions that help to define them would be worth the effort, that could be justified because adding flat adaptors is maybe complex or cumbersome.

So even if you opt for a framework, we would need to explain why do we need them.

Well this is just my opinion.

viboes avatar Mar 15 '16 22:03 viboes

You are right, but people want to know how to define flat adaptors as the ones you have defined.

But there is a lot detail things that goes on now. There is the detail::callable_base to handle callable, there is FIT_INHERIT_CONSTRUCTOR to handle the constructor, there is the get_base_function(xs...) with unused parameters to handle the base conversion, and there is other things to handle constexpr initialization with MSVC. Having a framework can simplify how the user would define an adaptor, and it can simplify the implementation of adaptors currently in Fit.

pfultz2 avatar Mar 15 '16 22:03 pfultz2

I'm not against a framework. The framework would need a motivation that should be described by showing how do you define an adaptor without :)

viboes avatar Mar 15 '16 23:03 viboes

Builders could be provided to build adaptors. Here are the different builders I am thinking about:

  • unary_adaptor_builder - This builds an adaptor taking one function
  • binary_adaptor_builder - This builds an adaptor taking two functions with an optional unary parameter.
  • fold_adaptor_builder - This builds an adaptor taking one or more functions but does a fold over the adaptors(like what is done currently for conditional, compose, flow, etc).
  • pack_adaptor_builder - This builds an adaptor taking one or more functions, but fit::pack is given for all the functions.
  • partial_adaptor_builder - This builds an adaptor taking one function. It works like like unary_adaptor_builder except it doesn't invoke the user defined adaptation if the original function is callable.

pfultz2 avatar Mar 26 '16 02:03 pfultz2