-
Notifications
You must be signed in to change notification settings - Fork 1
Circular newtype wrapper: Enables all enum methods #1
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
base: main
Are you sure you want to change the base?
Conversation
|
Thank you very much for your contribution, I like your work! 🚀 I just checked it out locally and start reading it in detail, let's work together on this. Maybe let's discuss some things first:
What property tests do you suggest?
As there's no runtime penalty for using |
Using an old ubuntu version for runners prevented runners from picking up our workflows. Fixed in main.
Sadly, I don't have Ideas for meaningful property based testing, since the Enum must be defined in the source code which would not allow for much randomness.
I thought about the other enum functions which would then do the wrapping for you, namely:
For consistency with the current API, these could all be prefixed with |
src/Data/Enum/Circular.hs
Outdated
| -- Beware: this alters the behaviour of some functions, producing infinite lists (because of circularity) | ||
|
|
||
| newtype Circular a = Circular a | ||
| deriving (Show, Eq, Ord, Bounded) |
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.
Actually, I don't know if we should derive Bounded here as the whole point of this newtype is to go beyond boundaries.
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.
I tried to address this in 2ca189e
as the whole point of it to go beyond boundaries. Only the sky is the limit.
|
When/If this is ready to join,
|
|
I have moved the Language Extensions to |
|
I'm working on it. :) Stay tuned. :) |
I wrote this code sometime and figured I might contribute it back after polishing it up.
Creates a newtype called
Circularand implements theEnumtypeclass for it.All operations using the
Enuminstance are now circular, none callerror(something that often annoyed me), but some may produce infinite lists, when given the right arguments.I also added some tests, but I'm not very versed with unit testing.
Feel free to suggest more test cases, I could also add QuickCheck tests.
If desired, I could also imagine adding more methods like already present (
csuccandcpred), which just wrap toCircularinternally.