Skip to content

Conversation

@ammatsui
Copy link
Contributor

@ammatsui ammatsui commented Oct 1, 2019

No description provided.

enum ranges Outdated
Comment on lines 4 to 5
data Rank = R2 | R3 | R4 | R5 | R6 | R7 | R8 | R9 | R10 | J | Q | K | A
deriving (Bounded, Enum, Eq, Ord)
Copy link
Member

Choose a reason for hiding this comment

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

We noticed this comes from your haskell-exercises repo, it's cool that you had an example handy to use :)

Instead of single-letter names for the contructors, maybe entire words would be more clear? It took us a minute to figure out what J, Q, K, A meant; I think seeing "jack", "queen", etc. could make it more immediately obvious that we're talking about playing cards.

data Rank = Rank2 | Rank3 | Rank4 | Rank5 | Rank6 | Rank7
          | Rank8 | Rank9 | Rank10 | Jack | Queen | King | Ace

enum ranges Outdated
Comment on lines 28 to 41
instance Show MyType where
show Foo = "Foo"
show Bar = "Bar"
show Baz = "Baz"


instance Enum MyType where
toEnum 0 = Foo
toEnum 1 = Bar
toEnum 2 = Baz

fromEnum Foo = 0
fromEnum Bar = 1
fromEnum Baz = 2
Copy link
Member

Choose a reason for hiding this comment

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

This is great for an in-depth explanation of how Enum works, but I think it's out of scope for the Phrasebook. The circumstances for manually writing Enum seem pretty rare (I don't think I've ever done it). Let's keep this page to derived instances only.

@chris-martin chris-martin mentioned this pull request Oct 2, 2019
Renamed ranks and added more examples
@chris-martin
Copy link
Member

chris-martin commented Oct 14, 2019

I like this example a lot. This'll be released under the creative commons CC BY-NC 4.0 license - Please let us know if that's okay and how you'd like to be attributed (your name, and a link to a blog or social account if you'd like).

@ammatsui
Copy link
Contributor Author

I am very glad to be helpful :) Everything's okay, and I think a link to my GitHub and my username would be more than enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants