Skip to content
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

Add NonEmptySet #7

Merged
merged 2 commits into from
Sep 6, 2018
Merged

Add NonEmptySet #7

merged 2 commits into from
Sep 6, 2018

Conversation

garyb
Copy link
Member

@garyb garyb commented Aug 19, 2018

No description provided.

unions :: forall f a. Foldable1 f => Ord a => f (NonEmptySet a) -> NonEmptySet a
unions = foldl append (NonEmptySet Set.empty)

-- | Form the set difference. `Nothing` if the sets are identical.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Difference is lhs - rhs, so I think it should be:

Form the set difference. Nothing if the first is a subset of the second.


-- | Form the union of a non-empty collection of non-empty sets.
unions :: forall f a. Foldable1 f => Ord a => f (NonEmptySet a) -> NonEmptySet a
unions = foldl append (NonEmptySet Set.empty)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not unions = fold1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thinking. Another one I thought of earlier today is that we can have a Bounded instance rather than providing findMin and findMax too.

Copy link
Member

@LiamGoodacre LiamGoodacre Aug 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow the Bounded idea. Although Bounded a => Bounded (NonEmptySet a) makes sense 👍 . I don't see how that relates to findMin, which is "give me the minimum element in a specific non empty set".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, Bounded a => Bounded (NonEmptySet a) also doesn't make sense. Not sure what I was thinking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't know what I was thinking either 😁

@garyb
Copy link
Member Author

garyb commented Sep 5, 2018

@LiamGoodacre how's this look now?

Copy link
Member

@LiamGoodacre LiamGoodacre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@garyb garyb merged commit 8622a23 into purescript:master Sep 6, 2018
@garyb garyb deleted the nonemptyset branch September 6, 2018 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants