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

Add an example for KEnum and KMaybe #37

Merged
merged 1 commit into from
Apr 11, 2022
Merged

Add an example for KEnum and KMaybe #37

merged 1 commit into from
Apr 11, 2022

Conversation

zliu41
Copy link
Member

@zliu41 zliu41 commented Apr 6, 2022

No description provided.

data Input = Input
{ iInt32 :: C Int32,
-- | To use an enum type, wrap it with `KEnum`.
iEnum :: KEnum C Pet
Copy link
Member

Choose a reason for hiding this comment

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

99% of the time, enums can just be used directly, without KEnum. I feel like this isn't quite right, it's too broad, but we only need KEnum if we "use" it in an f-parameterized context. This example should really be just using Pet, not KEnum C Pet.

Copy link
Member Author

Choose a reason for hiding this comment

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

Using Pet directly doesn't work here because there's no IfCat Cat Pet. I don't immediately know whether this instance is not possible, or we just didn't implement it (see #42), but either way, KEnum is currently the safer thing to use.

Copy link
Member

Choose a reason for hiding this comment

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

Ah! You're right, it's IfCat that forces us to use KEnum in general. I knew my recollection wasn't right. We should capture that on the docs for KEnum, and also add a comment on this example that points out why we need KEnum here, but don't in general.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@zliu41 zliu41 merged commit 40b673c into master Apr 11, 2022
@zliu41 zliu41 deleted the example/sum branch April 11, 2022 18:19
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.

2 participants