Skip to content

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

Merged
garyb merged 4 commits into
purescript:masterfrom
NightRa:master
Dec 1, 2014
Merged

Move toEnum&fromEnum into the Enum class, provide range functions.#6
garyb merged 4 commits into
purescript:masterfrom
NightRa:master

Conversation

@NightRa

@NightRa NightRa commented Nov 28, 2014

Copy link
Copy Markdown
Contributor

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

garyb commented Dec 1, 2014

Copy link
Copy Markdown
Member

@jdegoes can you review this one please?

@jdegoes

jdegoes commented Dec 1, 2014

Copy link
Copy Markdown
Contributor

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

NightRa commented Dec 1, 2014

Copy link
Copy Markdown
Contributor Author

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

NightRa commented Dec 1, 2014

Copy link
Copy Markdown
Contributor Author

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

@NightRa

NightRa commented Dec 1, 2014

Copy link
Copy Markdown
Contributor Author

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

@NightRa

NightRa commented Dec 1, 2014

Copy link
Copy Markdown
Contributor Author

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

@garyb

garyb commented Dec 1, 2014

Copy link
Copy Markdown
Member

Done

@NightRa

NightRa commented Dec 1, 2014

Copy link
Copy Markdown
Contributor Author

@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 <[email protected]>
Co-authored-by: Matthew Leon <[email protected]>
Co-authored-by: Gary Burgess <[email protected]>
Co-authored-by: Liam Goodacre <[email protected]>
Co-authored-by: Jorge Acereda <[email protected]>
Co-authored-by: Kristoffer Josefsson <[email protected]>
Co-authored-by: Denis Stoyanov <[email protected]>
Co-authored-by: Harry Garrood <[email protected]>
Co-authored-by: Cyril <[email protected]>
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