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 instances for Functor, etc., for Set #129

Closed
lukaszcz opened this issue Oct 17, 2024 · 3 comments · Fixed by #130
Closed

Add instances for Functor, etc., for Set #129

lukaszcz opened this issue Oct 17, 2024 · 3 comments · Fixed by #130
Assignees

Comments

@lukaszcz
Copy link
Contributor

  • To avoid conversions to/from List
  • Also reimplement the inefficient implementation of Foldable, etc., which uses conversions to/from list under the hood
@lukaszcz lukaszcz self-assigned this Oct 17, 2024
@paulcadman
Copy link
Collaborator

Haskell Set doesn't have a Functor instance.

The reason given is that the Functor law:

fmap (g . f) = fmap g . fmap f

can be violated. On the right duplicates are removed using f and then g . Whereas on the left duplicates are removed using g only.

I'm not sure if this is an issue for our Set implementation.

@lukaszcz
Copy link
Contributor Author

Right, forgot about that. But we should have Set.map at least.

@heueristik
Copy link

I also have an implementation of isSubset. This should be in stdlib and probably should be improved.

    isSubset {A} {{Ord A}} (sub sup : Set A) : Bool := all (x in Set.toList sub) Set.isMember x sup;

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 a pull request may close this issue.

3 participants