Skip to content

Commit 42410bf

Browse files
committed
Drop dependency on Shake
1 parent a3d70bb commit 42410bf

File tree

26 files changed

+83
-123
lines changed

26 files changed

+83
-123
lines changed

ghcide/src/Development/IDE/Core/RuleTypes.hs

-33
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module Development.IDE.Core.RuleTypes(
1818
import Control.DeepSeq
1919
import Control.Lens
2020
import Data.Aeson.Types (Value)
21-
import Data.Binary
2221
import Data.Hashable
2322
import qualified Data.Map as M
2423
import Data.Time.Clock.POSIX
@@ -82,7 +81,6 @@ data GetKnownTargets = GetKnownTargets
8281
deriving (Show, Generic, Eq, Ord)
8382
instance Hashable GetKnownTargets
8483
instance NFData GetKnownTargets
85-
instance Binary GetKnownTargets
8684
type instance RuleResult GetKnownTargets = KnownTargets
8785

8886
-- | Convert to Core, requires TypeCheck*
@@ -92,13 +90,11 @@ data GenerateCore = GenerateCore
9290
deriving (Eq, Show, Typeable, Generic)
9391
instance Hashable GenerateCore
9492
instance NFData GenerateCore
95-
instance Binary GenerateCore
9693

9794
data GetImportMap = GetImportMap
9895
deriving (Eq, Show, Typeable, Generic)
9996
instance Hashable GetImportMap
10097
instance NFData GetImportMap
101-
instance Binary GetImportMap
10298

10399
type instance RuleResult GetImportMap = ImportMap
104100
newtype ImportMap = ImportMap
@@ -287,7 +283,6 @@ instance Hashable GetModificationTime where
287283
hashWithSalt salt _ = salt
288284

289285
instance NFData GetModificationTime
290-
instance Binary GetModificationTime
291286

292287
pattern GetModificationTime :: GetModificationTime
293288
pattern GetModificationTime = GetModificationTime_ {missingFileDiagnostics=True}
@@ -310,14 +305,12 @@ data GetFileContents = GetFileContents
310305
deriving (Eq, Show, Generic)
311306
instance Hashable GetFileContents
312307
instance NFData GetFileContents
313-
instance Binary GetFileContents
314308

315309
data GetFileExists = GetFileExists
316310
deriving (Eq, Show, Typeable, Generic)
317311

318312
instance NFData GetFileExists
319313
instance Hashable GetFileExists
320-
instance Binary GetFileExists
321314

322315
data FileOfInterestStatus
323316
= OnDisk
@@ -326,13 +319,11 @@ data FileOfInterestStatus
326319
deriving (Eq, Show, Typeable, Generic)
327320
instance Hashable FileOfInterestStatus
328321
instance NFData FileOfInterestStatus
329-
instance Binary FileOfInterestStatus
330322

331323
data IsFileOfInterestResult = NotFOI | IsFOI FileOfInterestStatus
332324
deriving (Eq, Show, Typeable, Generic)
333325
instance Hashable IsFileOfInterestResult
334326
instance NFData IsFileOfInterestResult
335-
instance Binary IsFileOfInterestResult
336327

337328
type instance RuleResult IsFileOfInterest = IsFileOfInterestResult
338329

@@ -359,19 +350,16 @@ data GetParsedModule = GetParsedModule
359350
deriving (Eq, Show, Typeable, Generic)
360351
instance Hashable GetParsedModule
361352
instance NFData GetParsedModule
362-
instance Binary GetParsedModule
363353

364354
data GetParsedModuleWithComments = GetParsedModuleWithComments
365355
deriving (Eq, Show, Typeable, Generic)
366356
instance Hashable GetParsedModuleWithComments
367357
instance NFData GetParsedModuleWithComments
368-
instance Binary GetParsedModuleWithComments
369358

370359
data GetLocatedImports = GetLocatedImports
371360
deriving (Eq, Show, Typeable, Generic)
372361
instance Hashable GetLocatedImports
373362
instance NFData GetLocatedImports
374-
instance Binary GetLocatedImports
375363

376364
-- | Does this module need to be compiled?
377365
type instance RuleResult NeedsCompilation = Maybe LinkableType
@@ -380,122 +368,102 @@ data NeedsCompilation = NeedsCompilation
380368
deriving (Eq, Show, Typeable, Generic)
381369
instance Hashable NeedsCompilation
382370
instance NFData NeedsCompilation
383-
instance Binary NeedsCompilation
384371

385372
data GetDependencyInformation = GetDependencyInformation
386373
deriving (Eq, Show, Typeable, Generic)
387374
instance Hashable GetDependencyInformation
388375
instance NFData GetDependencyInformation
389-
instance Binary GetDependencyInformation
390376

391377
data GetModuleGraph = GetModuleGraph
392378
deriving (Eq, Show, Typeable, Generic)
393379
instance Hashable GetModuleGraph
394380
instance NFData GetModuleGraph
395-
instance Binary GetModuleGraph
396381

397382
data ReportImportCycles = ReportImportCycles
398383
deriving (Eq, Show, Typeable, Generic)
399384
instance Hashable ReportImportCycles
400385
instance NFData ReportImportCycles
401-
instance Binary ReportImportCycles
402386

403387
data GetDependencies = GetDependencies
404388
deriving (Eq, Show, Typeable, Generic)
405389
instance Hashable GetDependencies
406390
instance NFData GetDependencies
407-
instance Binary GetDependencies
408391

409392
data TypeCheck = TypeCheck
410393
deriving (Eq, Show, Typeable, Generic)
411394
instance Hashable TypeCheck
412395
instance NFData TypeCheck
413-
instance Binary TypeCheck
414396

415397
data GetDocMap = GetDocMap
416398
deriving (Eq, Show, Typeable, Generic)
417399
instance Hashable GetDocMap
418400
instance NFData GetDocMap
419-
instance Binary GetDocMap
420401

421402
data GetHieAst = GetHieAst
422403
deriving (Eq, Show, Typeable, Generic)
423404
instance Hashable GetHieAst
424405
instance NFData GetHieAst
425-
instance Binary GetHieAst
426406

427407
data GetBindings = GetBindings
428408
deriving (Eq, Show, Typeable, Generic)
429409
instance Hashable GetBindings
430410
instance NFData GetBindings
431-
instance Binary GetBindings
432411

433412
data GhcSession = GhcSession
434413
deriving (Eq, Show, Typeable, Generic)
435414
instance Hashable GhcSession
436415
instance NFData GhcSession
437-
instance Binary GhcSession
438416

439417
data GhcSessionDeps = GhcSessionDeps deriving (Eq, Show, Typeable, Generic)
440418
instance Hashable GhcSessionDeps
441419
instance NFData GhcSessionDeps
442-
instance Binary GhcSessionDeps
443420

444421
data GetModIfaceFromDisk = GetModIfaceFromDisk
445422
deriving (Eq, Show, Typeable, Generic)
446423
instance Hashable GetModIfaceFromDisk
447424
instance NFData GetModIfaceFromDisk
448-
instance Binary GetModIfaceFromDisk
449425

450426
data GetModIfaceFromDiskAndIndex = GetModIfaceFromDiskAndIndex
451427
deriving (Eq, Show, Typeable, Generic)
452428
instance Hashable GetModIfaceFromDiskAndIndex
453429
instance NFData GetModIfaceFromDiskAndIndex
454-
instance Binary GetModIfaceFromDiskAndIndex
455430

456431
data GetModIface = GetModIface
457432
deriving (Eq, Show, Typeable, Generic)
458433
instance Hashable GetModIface
459434
instance NFData GetModIface
460-
instance Binary GetModIface
461435

462436
data GetModIfaceWithoutLinkable = GetModIfaceWithoutLinkable
463437
deriving (Eq, Show, Typeable, Generic)
464438
instance Hashable GetModIfaceWithoutLinkable
465439
instance NFData GetModIfaceWithoutLinkable
466-
instance Binary GetModIfaceWithoutLinkable
467440

468441
data IsFileOfInterest = IsFileOfInterest
469442
deriving (Eq, Show, Typeable, Generic)
470443
instance Hashable IsFileOfInterest
471444
instance NFData IsFileOfInterest
472-
instance Binary IsFileOfInterest
473445

474446
data GetModSummaryWithoutTimestamps = GetModSummaryWithoutTimestamps
475447
deriving (Eq, Show, Typeable, Generic)
476448
instance Hashable GetModSummaryWithoutTimestamps
477449
instance NFData GetModSummaryWithoutTimestamps
478-
instance Binary GetModSummaryWithoutTimestamps
479450

480451
data GetModSummary = GetModSummary
481452
deriving (Eq, Show, Typeable, Generic)
482453
instance Hashable GetModSummary
483454
instance NFData GetModSummary
484-
instance Binary GetModSummary
485455

486456
-- | Get the vscode client settings stored in the ide state
487457
data GetClientSettings = GetClientSettings
488458
deriving (Eq, Show, Typeable, Generic)
489459
instance Hashable GetClientSettings
490460
instance NFData GetClientSettings
491-
instance Binary GetClientSettings
492461

493462
type instance RuleResult GetClientSettings = Hashed (Maybe Value)
494463

495464
data AddWatchedFile = AddWatchedFile deriving (Eq, Show, Typeable, Generic)
496465
instance Hashable AddWatchedFile
497466
instance NFData AddWatchedFile
498-
instance Binary AddWatchedFile
499467

500468

501469
-- A local rule type to get caching. We want to use newCache, but it has
@@ -516,7 +484,6 @@ instance NFData IdeGhcSession where rnf !_ = ()
516484
data GhcSessionIO = GhcSessionIO deriving (Eq, Show, Typeable, Generic)
517485
instance Hashable GhcSessionIO
518486
instance NFData GhcSessionIO
519-
instance Binary GhcSessionIO
520487

521488
makeLensesWith
522489
(lensRules & lensField .~ mappingNamer (pure . (++ "L")))

ghcide/src/Development/IDE/Core/Rules.hs

+1-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ import Control.Monad.Trans.Maybe
7070
import Data.Aeson (Result (Success),
7171
toJSON)
7272
import qualified Data.Aeson.Types as A
73-
import Data.Binary hiding (get, put)
7473
import qualified Data.Binary as B
7574
import qualified Data.ByteString as BS
7675
import Data.ByteString.Encoding as T
@@ -114,7 +113,7 @@ import Development.IDE.GHC.ExactPrint
114113
import Development.IDE.GHC.Util hiding
115114
(modifyDynFlags)
116115
import Development.IDE.Graph
117-
import Development.IDE.Graph.Classes hiding (get, put)
116+
import Development.IDE.Graph.Classes
118117
import Development.IDE.Import.DependencyInformation
119118
import Development.IDE.Import.FindImports
120119
import qualified Development.IDE.Spans.AtPoint as AtPoint
@@ -1092,6 +1091,5 @@ data IsHiFileStable = IsHiFileStable
10921091
deriving (Eq, Show, Typeable, Generic)
10931092
instance Hashable IsHiFileStable
10941093
instance NFData IsHiFileStable
1095-
instance Binary IsHiFileStable
10961094

10971095
type instance RuleResult IsHiFileStable = SourceModified

ghcide/src/Development/IDE/Core/Shake.hs

-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ import Development.IDE.GHC.Compat (NameCacheUpdater (..),
114114
import Development.IDE.GHC.Orphans ()
115115
import Development.IDE.Graph hiding (ShakeValue)
116116
import qualified Development.IDE.Graph as Shake
117-
import Development.IDE.Graph.Classes
118117
import Development.IDE.Graph.Database
119118
import Development.IDE.Graph.Rule
120119
import Development.IDE.Types.Action
@@ -960,8 +959,6 @@ instance Hashable k => Hashable (QDisk k)
960959

961960
instance NFData k => NFData (QDisk k)
962961

963-
instance Binary k => Binary (QDisk k)
964-
965962
instance Show k => Show (QDisk k) where
966963
show (QDisk k file) =
967964
show k ++ "; " ++ fromNormalizedFilePath file

ghcide/src/Development/IDE/GHC/ExactPrint.hs

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ data GetAnnotatedParsedSource = GetAnnotatedParsedSource
8181

8282
instance Hashable GetAnnotatedParsedSource
8383
instance NFData GetAnnotatedParsedSource
84-
instance Binary GetAnnotatedParsedSource
8584
type instance RuleResult GetAnnotatedParsedSource = Annotated ParsedSource
8685

8786
-- | Get the latest version of the annotated parse source with comments.

ghcide/src/Development/IDE/Plugin/CodeAction/RuleTypes.hs

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module Development.IDE.Plugin.CodeAction.RuleTypes
55
) where
66

77
import Control.DeepSeq (NFData)
8-
import Data.Binary (Binary)
98
import Data.Hashable (Hashable)
109
import Data.Typeable (Typeable)
1110
import Development.IDE.Graph (RuleResult)
@@ -21,4 +20,3 @@ newtype PackageExports = PackageExports HscEnvEq
2120

2221
instance Hashable PackageExports
2322
instance NFData PackageExports
24-
instance Binary PackageExports

ghcide/src/Development/IDE/Plugin/Completions.hs

-2
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,11 @@ data LocalCompletions = LocalCompletions
109109
deriving (Eq, Show, Typeable, Generic)
110110
instance Hashable LocalCompletions
111111
instance NFData LocalCompletions
112-
instance Binary LocalCompletions
113112

114113
data NonLocalCompletions = NonLocalCompletions
115114
deriving (Eq, Show, Typeable, Generic)
116115
instance Hashable NonLocalCompletions
117116
instance NFData NonLocalCompletions
118-
instance Binary NonLocalCompletions
119117

120118
-- | Generate code actions.
121119
getCompletionsLSP

ghcide/src/Development/IDE/Plugin/TypeLenses.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ showDocRdrEnv :: DynFlags -> GlobalRdrEnv -> SDoc -> String
233233
showDocRdrEnv dflags rdrEnv = showSDocForUser dflags (mkPrintUnqualified dflags rdrEnv)
234234

235235
data GetGlobalBindingTypeSigs = GetGlobalBindingTypeSigs
236-
deriving (Generic, Show, Eq, Ord, Hashable, NFData, Binary)
236+
deriving (Generic, Show, Eq, Ord, Hashable, NFData)
237237

238238
data GlobalBindingTypeSig = GlobalBindingTypeSig
239239
{ gbName :: Name

ghcide/src/Development/IDE/Types/HscEnvEq.hs

-6
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ instance NFData HscEnvEq where
139139
instance Hashable HscEnvEq where
140140
hashWithSalt s = hashWithSalt s . envUnique
141141

142-
-- Fake instance needed to persuade Shake to accept this type as a key.
143-
-- No harm done as ghcide never persists these keys currently
144-
instance Binary HscEnvEq where
145-
put _ = error "not really"
146-
get = error "not really"
147-
148142
-- | Given an action, produce a wrapped action that runs at most once.
149143
-- The action is run in an async so it won't be killed by async exceptions
150144
-- If the function raises an exception, the same exception will be reraised each time.

ghcide/src/Development/IDE/Types/Shake.hs

+2-14
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ import Data.HashMap.Strict
2323
import Data.Hashable
2424
import Data.Vector (Vector)
2525
import Development.IDE.Core.PositionMapping
26-
import Development.IDE.Graph (Key (..), RuleResult,
27-
ShakeException (shakeExceptionInner))
26+
import Development.IDE.Graph (Key (..), RuleResult)
2827
import qualified Development.IDE.Graph as Shake
29-
import Development.IDE.Graph.Classes
3028
import Development.IDE.Types.Diagnostics
3129
import Development.IDE.Types.Location
3230
import GHC.Generics
@@ -60,28 +58,18 @@ instance Exception BadDependency
6058

6159
isBadDependency :: SomeException -> Bool
6260
isBadDependency x
63-
| Just (x :: ShakeException) <- fromException x = isBadDependency $ shakeExceptionInner x
6461
| Just (_ :: BadDependency) <- fromException x = True
6562
| otherwise = False
6663

6764
toKey :: Shake.ShakeValue k => k -> NormalizedFilePath -> Key
6865
toKey = (Key.) . curry Q
6966

70-
toNoFileKey :: (Show k, Typeable k, Eq k, Hashable k, Binary k) => k -> Key
67+
toNoFileKey :: (Show k, Typeable k, Eq k, Hashable k) => k -> Key
7168
toNoFileKey k = Key $ Q (k, emptyFilePath)
7269

7370
newtype Q k = Q (k, NormalizedFilePath)
7471
deriving newtype (Eq, Hashable, NFData)
7572

76-
instance Binary k => Binary (Q k) where
77-
put (Q (k, fp)) = put (k, fp)
78-
get = do
79-
(k, fp) <- get
80-
-- The `get` implementation of NormalizedFilePath
81-
-- does not handle empty file paths so we
82-
-- need to handle this ourselves here.
83-
pure (Q (k, toNormalizedFilePath' fp))
84-
8573
instance Show k => Show (Q k) where
8674
show (Q (k, file)) = show k ++ "; " ++ fromNormalizedFilePath file
8775

ghcide/test/exe/Main.hs

-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import Control.Monad
2121
import Control.Monad.IO.Class (MonadIO, liftIO)
2222
import Data.Aeson (fromJSON, toJSON)
2323
import qualified Data.Aeson as A
24-
import qualified Data.Binary as Binary
2524
import Data.Default
2625
import Data.Foldable
2726
import Data.List.Extra
@@ -34,7 +33,6 @@ import Development.IDE.Core.PositionMapping (PositionResult (..),
3433
fromCurrent,
3534
positionResultToMaybe,
3635
toCurrent)
37-
import Development.IDE.Core.Shake (Q (..))
3836
import Development.IDE.GHC.Compat (GhcVersion (..),
3937
ghcVersion)
4038
import Development.IDE.GHC.Util
@@ -5647,8 +5645,6 @@ unitTests = do
56475645
, testCase "from empty path URI" $ do
56485646
let uri = Uri "file://"
56495647
uriToFilePath' uri @?= Just ""
5650-
, testCase "Key with empty file path roundtrips via Binary" $
5651-
Binary.decode (Binary.encode (Q ((), emptyFilePath))) @?= Q ((), emptyFilePath)
56525648
, testCase "showDiagnostics prints ranges 1-based (like vscode)" $ do
56535649
let diag = ("", Diagnostics.ShowDiag, Diagnostic
56545650
{ _range = Range

hls-graph/hls-graph.cabal

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ library
5959
, base >=4.12 && <5
6060
, bytestring
6161
, containers
62+
, deepseq
6263
, directory
6364
, extra
6465
, filepath
66+
, hashable
6567
, js-dgtable
6668
, js-flot
6769
, js-jquery
6870
, primitive
69-
, shake >= 0.19.4
7071
, time
7172
, transformers
7273
, unordered-containers

0 commit comments

Comments
 (0)