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

Allow local logical aliases (defines) #2463

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

clayrat
Copy link
Contributor

@clayrat clayrat commented Dec 11, 2024

This PR adds the ability to define logic aliases with a new define annotation outside of the built-in Language.Haskell.Liquid.GHC.CoreToLogic module. The declarations re-use the name resolution machinery, allowing for partial qualification. The local aliases are re-exported to the dependencies.

Following this, some defines have been moved out of CoreToLogic:

  • Set and Bag operations
  • GHC.CString.unpackCString#
  • Language.Haskell.Liquid.ProofCombinators.withProof
  • Numeric primitive aliases for Real and a local Integer alias needed in tests/pos/NumRefl.hs

@clayrat
Copy link
Contributor Author

clayrat commented Dec 11, 2024

filtered
bot
top

Copy link
Collaborator

@facundominguez facundominguez left a comment

Choose a reason for hiding this comment

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

Nice to see this feature in the works.

Import aliases are ignored when resolving defines. This made sense when they were global, but now that they are defined in modules, it would be best to treat them the same as measures or reflected functions.

There are other things to adjust that I mentioned in comments. But if name resolution looks too difficult, I could try contributing some of it, probably in January.

Another thing needed would be some user documentation for the new define annotation.

@clayrat clayrat changed the title Allow local logical aliases (defines) WIP Allow local logical aliases (defines) Dec 16, 2024
Copy link
Collaborator

@facundominguez facundominguez left a comment

Choose a reason for hiding this comment

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

I wonder if there is any define that needs to stay in CoreToLogic rather than being moved to an existing module.

@clayrat clayrat changed the title WIP Allow local logical aliases (defines) Allow local logical aliases (defines) Dec 18, 2024
, "define Language.Haskell.Liquid.Bag.empty = (Bag_empty 0)"
, ""
[ "define GHC.Types.True = (true)"
, "define GHC.Classes.not x = (~ x)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this can go in src/GHC/Classes_LHAssumptions.hs.

Comment on lines 10 to +13
, "define Language.Haskell.Liquid.Equational.eq x y = (y)"
, ""
, "define GHC.CString.unpackCString# x = x"
, "define Language.Haskell.Liquid.ProofCombinators.cast x y = (y)"
, "define Liquid.ProofCombinators.cast x y = (y)"
, "define ProofCombinators.cast x y = (y)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

And perhaps these can be migrated to liquid-prelude.

, "define Language.Haskell.Liquid.ProofCombinators.cast x y = (y)"
, "define Language.Haskell.Liquid.ProofCombinators.withProof x y = (x)"
, "define ProofCombinators.cast x y = (y)"
, "define Liquid.ProofCombinators.cast x y = (y)"
, "define Control.Parallel.Strategies.withStrategy s x = (x)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could it be migrated to liquid-parallel/src/Control/Parallel/Strategies_LHAssumptions.hs?

, ""
[ "define GHC.Types.True = (true)"
, "define GHC.Classes.not x = (~ x)"
, "define GHC.Internal.Base.$ f x = (f x)"
, "define Main.mempty = (mempty)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this one have any effect on tests?

, "define Language.Haskell.Liquid.Bag.sub a b = (Bag_sub a b)"
, "define Language.Haskell.Liquid.Bag.empty = (Bag_empty 0)"
, ""
[ "define GHC.Types.True = (true)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

To migrate to src/GHC/Types_LHAssumptions.hs (?)

, ""
[ "define GHC.Types.True = (true)"
, "define GHC.Classes.not x = (~ x)"
, "define GHC.Internal.Base.$ f x = (f x)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this can be migrated to src/GHC/Base_LHAssumptions.hs.

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