packages feed

hlint-plugin 1.0.1 → 1.0.2

raw patch · 3 files changed

+24/−21 lines, 3 filesdep ~ghcPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: ghc

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,11 @@+1.0.2++- [Fix performance of `argsSettings`](https://github.com/MercuryTechnologies/hlint-plugin/pull/13)+  - Before this change `hlint-plugin` would read in the hlint settings file for+    each Haskell module that was compiled and now it correctly caches those+    reads, which greatly improves the performance of the plugin.+- Small improvements to package description+ 1.0.1  - Small improvements to package description
hlint-plugin.cabal view
@@ -1,9 +1,9 @@ cabal-version:      3.0 name:               hlint-plugin-version:            1.0.1+version:            1.0.2 synopsis:           GHC plugin for hlint description:-    This package provides an GHC plugin that runs `hlint` on the compiled+    This package provides a GHC plugin that runs `hlint` on the compiled     module.  The main advantages of doing this are: (A) better integration with     GHC tooling, (B) only linting modules that change, and (C) only parsing the     module once.@@ -32,16 +32,16 @@     if impl(ghc >= 9.0 && < 9.2)         hs-source-dirs: ghc90         build-depends: hlint >= 3.3   && < 3.4-                     , ghc   >= 9.0.2 && < 9.2+                     , ghc   >= 9.0   && < 9.2     if impl(ghc >= 9.2 && < 9.4)         hs-source-dirs: ghc92         build-depends: hlint >= 3.4   && < 3.5-                     , ghc   >= 9.2.1 && < 9.4+                     , ghc   >= 9.2   && < 9.4     if impl(ghc >= 9.4 && < 9.6)         hs-source-dirs: ghc94         build-depends: hlint >= 3.5   && < 3.6-                     , ghc   >= 9.4.1 && < 9.6+                     , ghc   >= 9.4   && < 9.6     if impl(ghc >= 9.6 && < 9.8)         hs-source-dirs: ghc96         build-depends: hlint >= 3.6   && < 3.7-                     , ghc   >= 9.6.1 && < 9.8+                     , ghc   >= 9.6   && < 9.8
src/HLint/Plugin/Settings.hs view
@@ -20,18 +20,16 @@     ) where  import Control.Concurrent.MVar (MVar)-import Data.IORef (IORef) import Data.Map (Map) import Language.Haskell.HLint (Classify, Hint, ParseFlags)  import qualified Control.Concurrent.MVar as MVar-import qualified Data.IORef as IORef import qualified Data.Map as Map import qualified Language.Haskell.HLint as HLint import qualified System.IO.Unsafe as Unsafe -cache :: IORef (Map [String] (IO (ParseFlags, [Classify], Hint)))-cache = Unsafe.unsafePerformIO (IORef.newIORef Map.empty)+cache :: MVar (Map [String] (ParseFlags, [Classify], Hint))+cache = Unsafe.unsafePerformIO (MVar.newMVar Map.empty) {-# NOINLINE cache #-}  semaphore :: MVar ()@@ -44,17 +42,14 @@ argsSettings     :: [String]     -> IO (ParseFlags, [Classify], Hint)-argsSettings key = do-    io <- IORef.atomicModifyIORef' cache \m -> do+argsSettings key =+    MVar.modifyMVar cache \m -> do         case Map.lookup key m of-            Nothing      -> do-                let io =-                        Unsafe.unsafeInterleaveIO do-                            MVar.withMVar semaphore \_ -> HLint.argsSettings key--                (Map.insert key io m, io)+            Nothing -> do+                value <- Unsafe.unsafeInterleaveIO do+                    MVar.withMVar semaphore \_ -> HLint.argsSettings key -            Just io ->-                (m, io)+                pure (Map.insert key value m, value) -    io+            Just value ->+                pure (m, value)