9
3

monad_plus.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #include <boost/hana/ext/boost/tuple.hpp>
  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. #include <laws/base.hpp>
  10. #include <laws/monad_plus.hpp>
  11. #include <boost/tuple/tuple.hpp>
  12. namespace hana = boost::hana;
  13. template <int i>
  14. using eq = hana::test::ct_eq<i>;
  15. int main() {
  16. //////////////////////////////////////////////////////////////////////////
  17. // Setup for the laws below
  18. //////////////////////////////////////////////////////////////////////////
  19. auto eq_tuples = hana::make_tuple(
  20. ::boost::make_tuple(eq<0>{})
  21. , ::boost::make_tuple(eq<0>{}, eq<1>{})
  22. , ::boost::make_tuple(eq<0>{}, eq<1>{}, eq<2>{})
  23. );
  24. auto eq_values = hana::make_tuple(eq<0>{}, eq<1>{}, eq<2>{});
  25. auto predicates = hana::make_tuple(
  26. hana::equal.to(eq<0>{}), hana::equal.to(eq<1>{}), hana::equal.to(eq<2>{}),
  27. hana::always(hana::false_c), hana::always(hana::true_c)
  28. );
  29. //////////////////////////////////////////////////////////////////////////
  30. // MonadPlus
  31. //////////////////////////////////////////////////////////////////////////
  32. hana::test::TestMonadPlus<hana::ext::boost::tuple_tag>{eq_tuples, predicates, eq_values};
  33. }