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

9.6 support #54

Merged
merged 4 commits into from
Mar 24, 2023
Merged

9.6 support #54

merged 4 commits into from
Mar 24, 2023

Conversation

wz1000
Copy link
Contributor

@wz1000 wz1000 commented Mar 13, 2023

This is based on the 9.6 branch of ghc exactprint: alanz/ghc-exactprint#123

@facebook-github-bot
Copy link
Contributor

Hi @wz1000!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Mar 13, 2023
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@guibou
Copy link

guibou commented Mar 17, 2023

I think you meant that this is based on alanz/ghc-exactprint#124

I had to patch a bit in order to get this to build, using the following:

diff --git a/Retrie/Elaborate.hs b/Retrie/Elaborate.hs
index 1c88441..8be459f 100644
--- a/Retrie/Elaborate.hs
+++ b/Retrie/Elaborate.hs
@@ -103,7 +103,7 @@ allMatches _ [] = return []
 allMatches ctxt matchResults = do
   results <-
     forM matchResults $ \(sub, RewriterResult{..}) -> do
-      result <- lift $ liftIO $ rrTransformer ctxt $ MatchResult sub rrTemplate
+      result <- TransformT $ lift $ liftIO $ rrTransformer ctxt $ MatchResult sub rrTemplate
       return (rrQuantifiers, result)
   return
     [ project <$> result
diff --git a/Retrie/Rewrites/Function.hs b/Retrie/Rewrites/Function.hs
index 3944584..9f24977 100644
--- a/Retrie/Rewrites/Function.hs
+++ b/Retrie/Rewrites/Function.hs
@@ -53,7 +53,7 @@ dfnsToRewrites libdir specs am = fmap astA $ transformA am $ \ (L _ m) -> do
 getImports
   :: LibDir -> Direction -> Maybe (LocatedA ModuleName) -> TransformT IO AnnotatedImports
 getImports libdir RightToLeft (Just (L _ mn)) = -- See Note [fold only]
-  lift $ liftIO $ parseImports libdir ["import " ++ moduleNameString mn]
+  TransformT $ lift $ liftIO $ parseImports libdir ["import " ++ moduleNameString mn]
 getImports _ _ _ = return mempty
 
 matchToRewrites
diff --git a/Retrie/Types.hs b/Retrie/Types.hs
index 0f082b0..4bd7fb6 100644
--- a/Retrie/Types.hs
+++ b/Retrie/Types.hs
@@ -329,7 +329,7 @@ firstMatch _ [] = return NoMatch
 firstMatch ctxt ((sub, RewriterResult{..}):matchResults) = do
   -- 'firstMatch' is lazy in 'rrTransformer', only running it enough
   -- times to get the first valid MatchResult.
-  matchResult <- lift $ liftIO $ rrTransformer ctxt (MatchResult sub rrTemplate)
+  matchResult <- TransformT $ lift $ liftIO $ rrTransformer ctxt (MatchResult sub rrTemplate)
   case matchResult of
     MatchResult sub' _
       -- Check that all quantifiers from the original rewrite have mappings

This is because of the following change https://github.com/alanz/ghc-exactprint/pull/124/files#r1140532016

@pepeiborra pepeiborra merged commit b76391f into facebookincubator:main Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants