summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/test/_include/laws/comonad.hpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/test/_include/laws/comonad.hpp
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/hana/test/_include/laws/comonad.hpp')
-rw-r--r--src/boost/libs/hana/test/_include/laws/comonad.hpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/_include/laws/comonad.hpp b/src/boost/libs/hana/test/_include/laws/comonad.hpp
new file mode 100644
index 000000000..82ef7b32d
--- /dev/null
+++ b/src/boost/libs/hana/test/_include/laws/comonad.hpp
@@ -0,0 +1,53 @@
+// 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_TEST_LAWS_COMONAD_HPP
+#define BOOST_HANA_TEST_LAWS_COMONAD_HPP
+
+#include <boost/hana/assert.hpp>
+#include <boost/hana/concept/comonad.hpp>
+#include <boost/hana/concept/comparable.hpp>
+#include <boost/hana/core/when.hpp>
+#include <boost/hana/concept/foldable.hpp>
+#include <boost/hana/concept/functor.hpp>
+
+#include <laws/base.hpp>
+
+
+namespace boost { namespace hana { namespace test {
+ template <typename W, typename = when<true>>
+ struct TestComonad : TestComonad<W, laws> {
+ using TestComonad<W, laws>::TestComonad;
+ };
+
+ template <typename W>
+ struct TestComonad<W, laws> {
+ template <typename Ws>
+ TestComonad(Ws ws) {
+ hana::for_each(ws, [](auto w) {
+ static_assert(Comonad<decltype(w)>{}, "");
+
+ // extract(duplicate(w)) == w
+ BOOST_HANA_CHECK(hana::equal(
+ hana::extract(hana::duplicate(w)),
+ w
+ ));
+
+ // transform(duplicate(w), extract) == w
+ BOOST_HANA_CHECK(hana::equal(
+ hana::transform(hana::duplicate(w), extract),
+ w
+ ));
+
+ // duplicate(duplicate(w)) == transform(duplicate(w), duplicate)
+ BOOST_HANA_CHECK(hana::equal(
+ hana::duplicate(hana::duplicate(w)),
+ hana::transform(hana::duplicate(w), duplicate)
+ ));
+ });
+ }
+ };
+}}} // end namespace boost::hana::test
+
+#endif // !BOOST_HANA_TEST_LAWS_COMONAD_HPP