mlabs-haskell / lambda-buffers

LambdaBuffers toolkit for sharing types and their semantics between different languages
https://mlabs-haskell.github.io/lambda-buffers/
Apache License 2.0
29 stars 0 forks source link

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

Closed jaredponn closed 10 months ago

jaredponn commented 10 months ago

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 commented 10 months ago

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