/*! @file Defines `boost::hana::monadic_compose`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_MONADIC_COMPOSE_HPP #define BOOST_HANA_MONADIC_COMPOSE_HPP #include #include #include #include #include #include namespace boost { namespace hana { namespace detail { struct monadic_compose_helper { template constexpr decltype(auto) operator()(F&& f, G&& g, X&& x) const { using M = typename hana::tag_of::type; #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Monad::value, "hana::monadic_compose(f, g) requires 'g' to return a monadic value"); #endif return hana::chain(static_cast(g)(static_cast(x)), static_cast(f)); } }; } //! @cond template constexpr auto monadic_compose_t::operator()(F&& f, G&& g) const { return hana::partial(detail::monadic_compose_helper{}, static_cast(f), static_cast(g) ); } //! @endcond }} // end namespace boost::hana #endif // !BOOST_HANA_MONADIC_COMPOSE_HPP