| 1 | // Copyright Louis Dionne 2013-2022 |
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) |
| 4 | |
| 5 | #include <boost/hana/bool.hpp> |
| 6 | #include <boost/hana/equal.hpp> |
| 7 | #include <boost/hana/functional/always.hpp> |
| 8 | #include <boost/hana/tuple.hpp> |
| 9 | |
| 10 | #include <laws/applicative.hpp> |
| 11 | #include <laws/base.hpp> |
| 12 | #include <laws/functor.hpp> |
| 13 | #include <laws/monad.hpp> |
| 14 | #include <laws/monad_plus.hpp> |
| 15 | namespace hana = boost::hana; |
| 16 | using hana::test::ct_eq; |
| 17 | |
| 18 | |
| 19 | int main() { |
| 20 | auto eq_tuples = hana::make_tuple( |
| 21 | hana::make_tuple() |
| 22 | , hana::make_tuple(ct_eq<0>{}) |
| 23 | , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}) |
| 24 | , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) |
| 25 | , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) |
| 26 | , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) |
| 27 | , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}) |
| 28 | ); |
| 29 | |
| 30 | auto eq_values = hana::make_tuple( |
| 31 | ct_eq<0>{}, |
| 32 | ct_eq<2>{}, |
| 33 | ct_eq<4>{} |
| 34 | ); |
| 35 | |
| 36 | auto predicates = hana::make_tuple( |
| 37 | hana::equal.to(ct_eq<0>{}), |
| 38 | hana::equal.to(ct_eq<2>{}), |
| 39 | hana::equal.to(ct_eq<4>{}), |
| 40 | hana::always(hana::true_c), |
| 41 | hana::always(hana::false_c) |
| 42 | ); |
| 43 | |
| 44 | auto nested_eqs = hana::make_tuple( |
| 45 | hana::make_tuple() |
| 46 | , hana::make_tuple( |
| 47 | hana::make_tuple(ct_eq<0>{}) |
| 48 | ) |
| 49 | , hana::make_tuple( |
| 50 | hana::make_tuple(ct_eq<0>{}), |
| 51 | hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}) |
| 52 | ) |
| 53 | , hana::make_tuple( |
| 54 | hana::make_tuple(ct_eq<0>{}), |
| 55 | hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), |
| 56 | hana::make_tuple(ct_eq<3>{}, ct_eq<4>{}) |
| 57 | ) |
| 58 | ); |
| 59 | |
| 60 | hana::test::TestFunctor<hana::tuple_tag>{eq_tuples, eq_values}; |
| 61 | hana::test::TestApplicative<hana::tuple_tag>{eq_tuples}; |
| 62 | hana::test::TestMonad<hana::tuple_tag>{eq_tuples, nested_eqs}; |
| 63 | hana::test::TestMonadPlus<hana::tuple_tag>{eq_tuples, predicates, eq_values}; |
| 64 | } |
| 65 | |