packages feed

monadic-bang 0.2.2.0 → 0.2.2.1

raw patch · 3 files changed

+21/−15 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for monadic-bang
 
+## 0.2.2.1 -- 2024-05-20
+
+* Only run plugin on modules that contain bangs
+
 ## 0.2.2.0 -- 2024-05-20
 
 * Added support for GHC 9.10
monadic-bang.cabal view
@@ -14,7 +14,7 @@ -- PVP summary:      +-+------- breaking API changes
 --                   | | +----- non-breaking API additions
 --                   | | | +--- code changes with no API change
-version:            0.2.2.0
+version:            0.2.2.1
 
 -- A short (one-line) description of the package.
 synopsis:           GHC plugin to desugar ! into do-notation
src/MonadicBang/Internal.hs view
@@ -135,20 +135,22 @@ spanToLoc = liftA2 MkLoc srcLocLine srcLocCol . realSrcSpanStart
 
 replaceBangs :: [CommandLineOption] -> ModSummary -> Handler Hsc ParsedResult
-replaceBangs cmdLineOpts _ (ParsedResult (HsParsedModule mod' files) msgs) = do
-  options <- liftIO . (either throwIO pure =<<) . runThrow @ErrorCall $ parseOptions mod' cmdLineOpts
-  dflags <- getDynFlags
-  (newErrors, mod'') <-
-    runM .
-    runUniquesIO 'p' .
-    runWriter .
-    runReader options .
-    runReader noneInScope .
-    evalWriter @Occs .
-    runReader dflags $
-    fillHoles fills mod'
-  log options.verbosity (ppr mod'')
-  pure $ ParsedResult (HsParsedModule mod'' files) msgs{psErrors = oldErrors <> newErrors}
+replaceBangs cmdLineOpts _ orig@(ParsedResult (HsParsedModule mod' files) msgs)
+  | null fills = pure orig
+  | otherwise = do
+    options <- liftIO . (either throwIO pure =<<) . runThrow @ErrorCall $ parseOptions mod' cmdLineOpts
+    dflags <- getDynFlags
+    (newErrors, mod'') <-
+      runM .
+      runUniquesIO 'p' .
+      runWriter .
+      runReader options .
+      runReader noneInScope .
+      evalWriter @Occs .
+      runReader dflags $
+      fillHoles fills mod'
+    log options.verbosity (ppr mod'')
+    pure $ ParsedResult (HsParsedModule mod'' files) msgs{psErrors = oldErrors <> newErrors}
   where
     log = \cases
       Quiet _ -> pure ()