]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/include/boost/hana/fwd/monadic_compose.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / fwd / monadic_compose.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Forward declares `boost::hana::monadic_compose`.
4
5@copyright Louis Dionne 2013-2016
6Distributed under the Boost Software License, Version 1.0.
7(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8 */
9
10#ifndef BOOST_HANA_FWD_MONADIC_COMPOSE_HPP
11#define BOOST_HANA_FWD_MONADIC_COMPOSE_HPP
12
13#include <boost/hana/config.hpp>
14#include <boost/hana/core/when.hpp>
15
16
17BOOST_HANA_NAMESPACE_BEGIN
18 //! Composition of monadic functions.
19 //! @ingroup group-Monad
20 //!
21 //! Given two monadic functions `f` and `g`, `monadic_compose` returns
22 //! a new function equivalent to the composition of `f` with `g`, except
23 //! the result of `g` is `chain`ed into `f` instead of simply passed to
24 //! it, as with normal composition. `monadic_compose` satisfies
25 //! @code
26 //! monadic_compose(f, g)(x) == chain(g(x), f)
27 //! @endcode
28 //!
29 //!
30 //! @note
31 //! Unlike `compose`, `monadic_compose` does not generalize nicely to
32 //! arities higher than one. Hence, only unary functions may be used
33 //! with `monadic_compose`.
34 //!
35 //!
36 //! Signature
37 //! ---------
38 //! Given a `Monad` `M` and two functions @f$ f : B \to M(C) @f$ and
39 //! @f$ g : A \to M(B) @f$, the signature is
40 //! @f$
41 //! \mathtt{monadic\_compose}
42 //! : (B \to M(C)) \times (A \to M(B)) \to (A \to M(C))
43 //! @f$.
44 //!
45 //! @param f
46 //! A monadic function with signature @f$ B \to M(C) @f$.
47 //!
48 //! @param g
49 //! A monadic function with signature @f$ A \to M(B) @f$.
50 //!
51 //!
52 //! @note
53 //! This method is not tag-dispatched, so it can't be customized directly.
54 //!
55 //!
56 //! Example
57 //! -------
58 //! @include example/monadic_compose.cpp
59#ifdef BOOST_HANA_DOXYGEN_INVOKED
60 constexpr auto monadic_compose = [](auto&& f, auto&& g) {
61 return [perfect-capture](auto&& x) -> decltype(auto) {
62 return hana::chain(forwarded(g)(forwarded(x)), forwarded(f));
63 };
64 };
65#else
66 struct monadic_compose_t {
67 template <typename F, typename G>
68 constexpr auto operator()(F&& f, G&& g) const;
69 };
70
71 constexpr monadic_compose_t monadic_compose{};
72#endif
73BOOST_HANA_NAMESPACE_END
74
75#endif // !BOOST_HANA_FWD_MONADIC_COMPOSE_HPP