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

Fix toEnum for (Maybe a) #20

Merged
merged 2 commits into from
Nov 10, 2016
Merged

Fix toEnum for (Maybe a) #20

merged 2 commits into from
Nov 10, 2016

Conversation

jacereda
Copy link
Contributor

No description provided.

to _ 0 = Nothing
to (Cardinality ca) n | n <= ca = Just $ toEnum (n - 1)
to _ 0 = Just Nothing
to (Cardinality ca) n | n > 0 && n <= ca = Just $ toEnum (n - 1)
Copy link
Contributor

@paf31 paf31 Nov 10, 2016

Choose a reason for hiding this comment

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

Why are we even doing a check here? Why not just let the call to toEnum fail?

toEnum 0 = pure Nothing
toEnum n = Just <$> toEnum (n - 1)

@jacereda
Copy link
Contributor Author

@paf31 much better :)

@paf31
Copy link
Contributor

paf31 commented Nov 10, 2016

Thanks! @garyb, any comments on this? Looks good to me.

@garyb
Copy link
Member

garyb commented Nov 10, 2016

Nope, looks great!

@garyb garyb merged commit 52e61de into purescript:master Nov 10, 2016
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