3 Forward declares `boost::hana::chain`.
5 @copyright Louis Dionne 2013-2016
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_HANA_FWD_CHAIN_HPP
11 #define BOOST_HANA_FWD_CHAIN_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Feed a monadic value into a monadic computation.
19 //! @ingroup group-Monad
21 //! Given a monadic value and a monadic function, `chain` feeds the
22 //! monadic value into the function, thus performing some Monad-specific
23 //! effects, and returns the result. An implementation of `chain` must
26 //! chain(xs, f) == flatten(transform(xs, f))
32 //! For a monad `M`, given a monadic value of type `M(A)` and a monadic
33 //! function @f$ f : A \to M(B) @f$, `chain` has the signature
35 //! \mathtt{chain} : M(A) \times (A \to M(B)) \to M(B)
39 //! A monadic value to be fed to the function `f`.
42 //! A function taking a normal value in the `xs` structure, and returning
43 //! a monadic value. This function is called as `f(x)`, where `x` is an
44 //! element of the structure `xs`.
49 //! @include example/chain.cpp
50 #ifdef BOOST_HANA_DOXYGEN_INVOKED
51 constexpr auto chain = [](auto&& xs, auto&& f) -> decltype(auto) {
52 return tag-dispatched;
55 template <typename M, typename = void>
56 struct chain_impl : chain_impl<M, when<true>> { };
59 template <typename Xs, typename F>
60 constexpr decltype(auto) operator()(Xs&& xs, F&& f) const;
63 constexpr chain_t chain{};
65 BOOST_HANA_NAMESPACE_END
67 #endif // !BOOST_HANA_FWD_CHAIN_HPP