Skip to content

Optimized the Eq instance generation by removing the useless True at the start #130

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 2 commits into from
Oct 27, 2023

Conversation

jaredponn
Copy link
Contributor

@jaredponn jaredponn commented Oct 27, 2023

This optimizes the generated Eq instances.

For example,

module TEST

import Prelude

record A = { int : Integer }
derive Eq A

would previously generate code like

instance Prelude.Eq A where
  (==) = (\x0 -> (\x1 -> (Prelude.&&) (Prelude.True) ((Prelude.==) (a'int x0) (a'int x1)) ) )
                                   -- ^~~~~~~~~~~~~ this is not necessary

This PR changes the generated code to be as follows

instance Prelude.Eq A where
  (==) = (\x0 -> (\x1 -> (Prelude.==) (a'int x0) (a'int x1) ) )

@jaredponn jaredponn force-pushed the jared/eq-instance-improvement branch from 65064e9 to 992bd40 Compare October 27, 2023 02:23
Copy link
Contributor

@bladyjoker bladyjoker left a comment

Choose a reason for hiding this comment

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

Thanks!

@jaredponn
Copy link
Contributor Author

Thanks for the review, I'll merge it now.

@jaredponn jaredponn added this pull request to the merge queue Oct 27, 2023
Merged via the queue into main with commit 92045d7 Oct 27, 2023
@jaredponn jaredponn deleted the jared/eq-instance-improvement branch October 27, 2023 22:04
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