• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright Louis Dionne 2013-2017
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/ext/std/tuple.hpp>
8 #include <boost/hana/functional/always.hpp>
9 #include <boost/hana/tuple.hpp>
10 
11 #include <laws/applicative.hpp>
12 #include <laws/base.hpp>
13 #include <laws/functor.hpp>
14 #include <laws/monad.hpp>
15 #include <laws/monad_plus.hpp>
16 
17 #include <tuple>
18 namespace hana = boost::hana;
19 using hana::test::ct_eq;
20 
21 
main()22 int main() {
23     auto tuples = hana::make_tuple(
24           std::make_tuple()
25         , std::make_tuple(ct_eq<0>{})
26         , std::make_tuple(ct_eq<0>{}, ct_eq<1>{})
27         , std::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
28         , std::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{})
29     );
30 
31     auto values = hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{});
32 
33     auto nested_tuples = hana::make_tuple(
34           std::make_tuple()
35         , std::make_tuple(
36             std::make_tuple(ct_eq<0>{}))
37         , std::make_tuple(
38             std::make_tuple(ct_eq<0>{}),
39             std::make_tuple(ct_eq<1>{}, ct_eq<2>{}))
40         , std::make_tuple(
41             std::make_tuple(ct_eq<0>{}),
42             std::make_tuple(ct_eq<1>{}, ct_eq<2>{}),
43             std::make_tuple(ct_eq<3>{}, ct_eq<4>{}))
44     );
45 
46     auto predicates = hana::make_tuple(
47         hana::equal.to(ct_eq<0>{}), hana::equal.to(ct_eq<1>{}), hana::equal.to(ct_eq<2>{}),
48         hana::always(hana::false_c), hana::always(hana::true_c)
49     );
50 
51     hana::test::TestFunctor<hana::ext::std::tuple_tag>{tuples, values};
52     hana::test::TestApplicative<hana::ext::std::tuple_tag>{tuples};
53     hana::test::TestMonad<hana::ext::std::tuple_tag>{tuples, nested_tuples};
54     hana::test::TestMonadPlus<hana::ext::std::tuple_tag>{tuples, predicates, values};
55 }
56