Skip to content

Move toEnum&fromEnum into the Enum class, provide range functions. #6

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

Merged
merged 4 commits into from
Dec 1, 2014

Conversation

NightRa
Copy link
Contributor

@NightRa NightRa commented Nov 28, 2014

This PR moves toEnum and fromEnum into the Enum class, providing default implementations for succ, pred, toEnum and fromEnum.

The move is nessesary for providing O(1) toEnum and fromEnum implementations.

Migration guide:
-- Add toEnum & fromEnum to all Enum classes, with a fallback to default implementations.
-- Beware of ScopedTypeVariables and passing typeclass functions to the default implementations.
-- See the implementation for workarounds.

Also, this PR adds the range functions for enums.

@garyb
Copy link
Member

garyb commented Dec 1, 2014

@jdegoes can you review this one please?

@jdegoes
Copy link
Contributor

jdegoes commented Dec 1, 2014

Assuming this compiles to something that works (always have to be careful with ScopedTypeVariables workarounds), and that it gets a middle version increment (0.x.0), 👍 . Nice work @NightRa!

@NightRa
Copy link
Contributor Author

NightRa commented Dec 1, 2014

Thanks @jdegoes!
It does compile and work indeed :)
One thing that concerns me with the development cycle of core libraries is that I can't unit test them until they get merged - for core-test, and that testing frameworks depend on those libraries themselves.

Feel free to merge :)

@NightRa
Copy link
Contributor Author

NightRa commented Dec 1, 2014

One thing that concerns me is the local definition of div, which should be removed once there is support for ints.

@NightRa
Copy link
Contributor Author

NightRa commented Dec 1, 2014

Let me at first update the dependencies for the array ST changes

@NightRa
Copy link
Contributor Author

NightRa commented Dec 1, 2014

@garyb / @paf31: Can you please tag the updated purescript-tuples?

@garyb
Copy link
Member

garyb commented Dec 1, 2014

Done

@NightRa
Copy link
Contributor Author

NightRa commented Dec 1, 2014

@garyb Ready for merging

garyb added a commit that referenced this pull request Dec 1, 2014
Move toEnum&fromEnum into the Enum class, provide range functions.
@garyb garyb merged commit 0d35770 into purescript:master Dec 1, 2014
JordanMartinez added a commit that referenced this pull request Dec 25, 2020
* first commit

* Fix instances for record fields

* Break modules up

* Deriving Show (#5)

* Initial work on deriving Show

* Add test for Show

* Remove import

* Travis etc.

* Data.Generic.Rep.Bounded (#6)

* Data.Generic.Rep.Bounded

Generic implementations of Prelude.Bounded class's top and bottom.

* GenericBounded - don't support product types

* GenericBounded - only support NoArguments

* Update for PureScript 0.11

* Add Generic instance for Maybe (#9)

* Add missing Bounded instances for Argument

* Add GenericEnum and GenericBoundedEnum

* Add enum tests, convert existing "tests" into assertions

* Product instances in Bounded and Enum

* Added GenericShowFields instances for NoConstructors and NoArguments (#20)

* Added Eq and Show instances to NoArguments and NoConstructors

* Added GenericShowFields

* Removed Show, Eq

* Cleanup

* Removed NoConstructors Show instance

* Remove Rec and Field & update package & bower symbols

* Bump deps for compiler/0.12

* Remove symbols and fix operator fixity issue

* Update dependencies, license

* Added HeytingAlgebra, Semiring, Ring

* Fix type annotation precedence in tests

* Replace monomorphic proxies by Type.Proxy.Proxy (#44)

* Move Enum file to Data.Enum.Generic

* Update module name to match file name for Enum

* Update module path for Bounded Generic

* Move test file to Data.Enum folder and rename to Generic.purs

* Remove code unrelated to Enum in test file

* Update Generic X module names to Data.X.Generic

* Rename `main` function in test file to testGenericEnum

* Update module name in test file to match file name

* Remove all files in repo that are unrelated to Enum Generic

* Include Enum's Generic tests in repo's tests

* Remove unused logShow

Co-authored-by: Phil Freeman <paf31@cantab.net>
Co-authored-by: Matthew Leon <ml@matthewleon.com>
Co-authored-by: Gary Burgess <gary.burgess@gmail.com>
Co-authored-by: Liam Goodacre <goodacre.liam@gmail.com>
Co-authored-by: Jorge Acereda <jacereda@gmail.com>
Co-authored-by: Kristoffer Josefsson <kejace@gmail.com>
Co-authored-by: Denis Stoyanov <stoyanov.gr@gmail.com>
Co-authored-by: Harry Garrood <harry@garrood.me>
Co-authored-by: Cyril <sobierajewicz.cyril@gmail.com>
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.

3 participants