-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SetTheoretic] Add SetTheoretic concept #364
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*! | ||
@file | ||
Defines `boost::hana::SetTheoretic`. | ||
|
||
@copyright Shreyans Doshi 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_CONCEPT_SET_THEORETIC_HPP | ||
#define BOOST_HANA_CONCEPT_SET_THEORETIC_HPP | ||
|
||
#include <boost/hana/fwd/concept/set_theoretic.hpp> | ||
|
||
#include <boost/hana/config.hpp> | ||
#include <boost/hana/core/default.hpp> | ||
#include <boost/hana/core/tag_of.hpp> | ||
#include <boost/hana/detail/integral_constant.hpp> | ||
#include <boost/hana/difference.hpp> | ||
#include <boost/hana/intersection.hpp> | ||
#include <boost/hana/symmetric_difference.hpp> | ||
#include <boost/hana/union.hpp> | ||
|
||
|
||
BOOST_HANA_NAMESPACE_BEGIN | ||
template <typename STh> | ||
struct SetTheoretic | ||
: hana::integral_constant<bool, | ||
!is_default<difference_impl<typename tag_of<STh>::type>>::value && | ||
!is_default<intersection_impl<typename tag_of<STh>::type>>::value && | ||
!is_default<union_impl<typename tag_of<STh>::type>>::value | ||
> | ||
{ }; | ||
BOOST_HANA_NAMESPACE_END | ||
|
||
#endif // !BOOST_HANA_CONCEPT_SET_THEORETIC_HPP |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*! | ||
@file | ||
Forward declares `boost::hana::SetTheoretic`. | ||
|
||
@copyright Shreyans Doshi 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_FWD_CONCEPT_SET_THEORETIC_HPP | ||
#define BOOST_HANA_FWD_CONCEPT_SET_THEORETIC_HPP | ||
|
||
#include <boost/hana/config.hpp> | ||
|
||
|
||
BOOST_HANA_NAMESPACE_BEGIN | ||
//! @ingroup group-concepts | ||
//! @defgroup group-SetTheoretic SetTheoretic | ||
//! The `SetTheoretic` concept represents data structures supporting | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defining the concept as "things that have the methods that the concept provides" is kind of circular, and not very useful IMO. Also, you're not defining laws for the concept. I'd go for a brief like this instead:
Then, I'd make some comments about what the concept is at a high level, and why it's useful. I'd also give the laws that the concept must follow, e.g. probably the ones on the Wikipedia page. Other comments:
I know this may seem like a lot, but this is what a concept in Hana is; it's not only a syntactical construction, it's also a tool to reason mathematically about programs, which requires a little more work to define than "loose" concepts that don't have clear semantics, if I may put it that way. If there are things where you really don't know what to do, let me know and I'll try to make some time for researching the topic to try and provide some guidance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense for It might even simplify implementation of these functions assuming "keys" are strictly looked up at compile-time. Hmm.. that might also require something like the Also perhaps it should be just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The TLDR is that they would only have to implement those accessors and not the union, intersection,... algorithms directly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I see it does not necessarily make sense to have You can make plenty of things that support the algebra of sets that it does not make sense to be For example: a string of bits:
Anyways......thats just the way I see it....... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DarthRubik I don't believe we are trying to couple |
||
//! algebra of sets. | ||
//! | ||
//! Minimal complete definition | ||
//! --------------------------- | ||
//! `union_`, `intersection`, `difference` and `symmetric_difference` | ||
shreyans800755 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//! | ||
//! Concrete models | ||
//! --------------- | ||
//! `hana::set`, `hana::map` | ||
//! | ||
//! | ||
template <typename STh> | ||
struct SetTheoretic; | ||
BOOST_HANA_NAMESPACE_END | ||
|
||
#endif // !BOOST_HANA_FWD_CONCEPT_SET_THEORETIC_HPP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ldionne
This actually doesn't seem good to me logically. Although infinite set had union function implemented, we can't call it, because apparantly, union requires the class to be SetTheoretic meaning it requires minimal definition - all 3 functions union, intersection & difference. But, mathematically, it seems accurate though.
Any thoughts ?