diff --git a/hie.yaml b/hie.yaml deleted file mode 100644 index 7959cec..0000000 --- a/hie.yaml +++ /dev/null @@ -1,5 +0,0 @@ -cradle: - direct: - arguments: - - -Wall - - -package ghc diff --git a/atomic-write.nix b/nix/haskell/atomic-write.nix similarity index 100% rename from atomic-write.nix rename to nix/haskell/atomic-write.nix diff --git a/cborg-json.nix b/nix/haskell/cborg-json.nix similarity index 100% rename from cborg-json.nix rename to nix/haskell/cborg-json.nix diff --git a/cborg.nix b/nix/haskell/cborg.nix similarity index 100% rename from cborg.nix rename to nix/haskell/cborg.nix diff --git a/dhall.nix b/nix/haskell/dhall.nix similarity index 100% rename from dhall.nix rename to nix/haskell/dhall.nix diff --git a/nix/haskell/prettyprinter.nix b/nix/haskell/prettyprinter.nix index edf7be1..32e59cc 100644 --- a/nix/haskell/prettyprinter.nix +++ b/nix/haskell/prettyprinter.nix @@ -1,21 +1,21 @@ { mkDerivation, ansi-wl-pprint, base, base-compat, bytestring -, containers, criterion, deepseq, doctest, mtl, pgp-wordlist -, QuickCheck, random, stdenv, tasty, tasty-hunit, tasty-quickcheck -, text, transformers +, containers, deepseq, doctest, gauge, mtl, pgp-wordlist +, QuickCheck, quickcheck-instances, random, stdenv, tasty +, tasty-hunit, tasty-quickcheck, text, transformers }: mkDerivation { pname = "prettyprinter"; - version = "1.4.0"; - sha256 = "7f1d9224f9e577eb24dda695beb6bc2f074e93a84a3c9f11bb578aa6ed39cb45"; + version = "1.6.1"; + sha256 = "3f9765764db7b55db8fb29b92ad26a02f08364e5947a89e2e1aa6d8a6087d781"; isLibrary = true; isExecutable = true; libraryHaskellDepends = [ base text ]; testHaskellDepends = [ - base bytestring doctest pgp-wordlist QuickCheck tasty tasty-hunit - tasty-quickcheck text + base bytestring doctest pgp-wordlist QuickCheck + quickcheck-instances tasty tasty-hunit tasty-quickcheck text ]; benchmarkHaskellDepends = [ - ansi-wl-pprint base base-compat containers criterion deepseq mtl + ansi-wl-pprint base base-compat containers deepseq gauge mtl QuickCheck random text transformers ]; homepage = "http://github.com/quchen/prettyprinter"; diff --git a/prettyprinter.nix b/prettyprinter.nix deleted file mode 100644 index 32e59cc..0000000 --- a/prettyprinter.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ mkDerivation, ansi-wl-pprint, base, base-compat, bytestring -, containers, deepseq, doctest, gauge, mtl, pgp-wordlist -, QuickCheck, quickcheck-instances, random, stdenv, tasty -, tasty-hunit, tasty-quickcheck, text, transformers -}: -mkDerivation { - pname = "prettyprinter"; - version = "1.6.1"; - sha256 = "3f9765764db7b55db8fb29b92ad26a02f08364e5947a89e2e1aa6d8a6087d781"; - isLibrary = true; - isExecutable = true; - libraryHaskellDepends = [ base text ]; - testHaskellDepends = [ - base bytestring doctest pgp-wordlist QuickCheck - quickcheck-instances tasty tasty-hunit tasty-quickcheck text - ]; - benchmarkHaskellDepends = [ - ansi-wl-pprint base base-compat containers deepseq gauge mtl - QuickCheck random text transformers - ]; - homepage = "http://github.com/quchen/prettyprinter"; - description = "A modern, easy to use, well-documented, extensible pretty-printer"; - license = stdenv.lib.licenses.bsd2; -} diff --git a/shell.nix b/shell.nix index b5c79cb..3eddd92 100644 --- a/shell.nix +++ b/shell.nix @@ -14,31 +14,14 @@ let ) ( self: super: - { dhall = - self.callPackage ./dhall.nix {}; - - weeder = + { weeder = self.callCabal2nix "weeder" ( cleanSource ./. ) {}; - - cborg = - self.callPackage ./cborg.nix {}; - - cborg-json = - self.callPackage ./cborg-json.nix {}; - - prettyprinter = - self.callPackage ./prettyprinter.nix {}; - - atomic-write = - self.callPackage ./atomic-write.nix {}; } ); }; in haskellPackages.weeder.env - # .overrideAttrs - # ( old: { buildInputs = old.buildInputs or [] ++ [ haskellPackages.ghcide ]; } ) diff --git a/tests/Main.hs b/tests/Main.hs deleted file mode 100644 index 5f5d3bd..0000000 --- a/tests/Main.hs +++ /dev/null @@ -1,179 +0,0 @@ -{-# language BlockArguments #-} -{-# language LambdaCase #-} -{-# language PackageImports #-} -{-# language NondecreasingIndentation #-} - -module Main where - -import "base" Control.Monad ( unless ) -import "base" Control.Monad.IO.Class ( liftIO ) -import "base" Data.Foldable ( for_, traverse_, toList ) - -import qualified "containers" Data.Set as Set - -import "directory" System.Directory ( doesPathExist, withCurrentDirectory, canonicalizePath, listDirectory, doesFileExist, doesDirectoryExist ) - -import "filepath" System.FilePath ( isExtensionOf, takeBaseName ) - -import "ghc" GHC - ( Target( Target, targetId, targetAllowObjCode, targetContents ) - , LoadHowMuch( LoadAllTargets ) - , TargetId ( TargetFile ) - , TypecheckedModule( TypecheckedModule, tm_internals_, tm_renamed_source ) - , addTarget - , getModSummary - , getSession - , getSessionDynFlags - , load - , mkModuleName - , parseModule - , runGhc - , setSessionDynFlags - , typecheckModule - ) -import "ghc" HieAst ( mkHieFile ) -import "ghc" HieTypes ( hie_asts, getAsts ) -import "ghc" HieDebug ( ppHie ) -import "ghc" HscTypes ( runHsc ) -import "ghc" Module - ( DefUnitId( DefUnitId ) - , Module( Module ) - , UnitId( DefiniteUnitId ) - , mkModuleName - , moduleNameString - , moduleName - , moduleStableString - , stringToInstalledUnitId - ) -import "ghc" OccName ( mkOccName, varName ) -import "ghc" Outputable ( showSDoc ) - -import "ghc-paths" GHC.Paths ( libdir ) - -import "tasty" Test.Tasty ( TestTree, defaultMain, testGroup ) - -import "tasty-hunit" Test.Tasty.HUnit ( testCase ) - -import "transformers" Control.Monad.Trans.State.Strict ( execState ) - -import "weeder" Weeder - ( allDeclarations - , Declaration( Declaration, declModule, declOccName ) - , analyseHieFile - , declarationStableName - , emptyAnalysis - , implicitRoots - , reachable - ) - -main :: IO () -main = do - discoverTests >>= defaultMain . testGroup "Tests" - - -discoverTests :: IO [ TestTree ] -discoverTests = - fmap ( map fileToTestCase ) ( getTestCasesIn "tests/test-cases" ) - - -fileToTestCase :: FilePath -> TestTree -fileToTestCase sourceFilePath = - testCase ( takeBaseName sourceFilePath ) - $ runGhc ( Just libdir ) do - dynFlags <- - getSessionDynFlags - - setSessionDynFlags dynFlags - - addTarget - Target - { targetId = TargetFile sourceFilePath Nothing - , targetAllowObjCode = False - , targetContents = Nothing - } - - load LoadAllTargets - - let - testModuleName = - mkModuleName "Test" - - modSummary <- - getModSummary testModuleName - - parseModule modSummary - >>= typecheckModule - >>= \case - TypecheckedModule{ tm_renamed_source = Just renamedSource, tm_internals_ = ( tcGblEnv, _ ) } -> do - hscEnv <- - getSession - - hieFile <- - liftIO ( runHsc hscEnv ( mkHieFile modSummary tcGblEnv renamedSource ) ) - - let - analysis = - execState ( analyseHieFile False hieFile ) emptyAnalysis - - testModule = - Module - ( DefiniteUnitId ( DefUnitId ( stringToInstalledUnitId "main" ) ) ) - testModuleName - - reachableSet = - reachable - analysis - ( Set.singleton - Declaration - { declModule = - testModule - , declOccName = - mkOccName varName "root" - } - ) - - dead = - Set.filter - ( \d -> declModule d == testModule ) - ( allDeclarations analysis Set.\\ reachableSet ) - - unless - ( Set.null dead ) - ( for_ dead \d -> - liftIO ( fail ( declarationStableName d <> " is dead, but should be alive" ) ) - ) - --- | Recursively search for .hie files in given directory -getTestCasesIn :: FilePath -> IO [FilePath] -getTestCasesIn path = do - exists <- - doesPathExist path - - if exists - then do - isFile <- - doesFileExist path - - if isFile && "hs" `isExtensionOf` path - then do - path' <- - canonicalizePath path - - return [ path' ] - - else do - isDir <- - doesDirectoryExist path - - if isDir - then do - cnts <- - listDirectory path - - withCurrentDirectory path ( foldMap getTestCasesIn cnts ) - - else - return [] - - else - return [] diff --git a/tests/test-cases/Default declarations retain references.hs b/tests/test-cases/Default declarations retain references.hs deleted file mode 100644 index d99c678..0000000 --- a/tests/test-cases/Default declarations retain references.hs +++ /dev/null @@ -1,15 +0,0 @@ -{-# language DefaultSignatures #-} - -module Test () where - -alive :: String -alive = "Alive" - -class C a where - cmethod :: a -> String - default cmethod :: a -> String - cmethod _ = alive - -data T - -instance C T diff --git a/tests/test-cases/Instances retain top level bindings.hs b/tests/test-cases/Instances retain top level bindings.hs deleted file mode 100644 index 3e8126e..0000000 --- a/tests/test-cases/Instances retain top level bindings.hs +++ /dev/null @@ -1,9 +0,0 @@ -module Test () where - -alive :: String -alive = "Alive" - -data T = T - -instance Show T where - show T = alive diff --git a/tests/test-cases/Rewrite rules retain references.hs b/tests/test-cases/Rewrite rules retain references.hs deleted file mode 100644 index c8b5c0e..0000000 --- a/tests/test-cases/Rewrite rules retain references.hs +++ /dev/null @@ -1,16 +0,0 @@ -{-# language DefaultSignatures #-} - -module Test ( foo ) where - -{-# noinline foo #-} -foo :: Bool -> Int -foo _ = 42 - -bar :: Int -bar = 42 - -{-# RULES - -"test rule" foo True = bar - -#-} diff --git a/tests/test-cases/Type signatures retain data types.hs b/tests/test-cases/Type signatures retain data types.hs deleted file mode 100644 index 78038e2..0000000 --- a/tests/test-cases/Type signatures retain data types.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Test ( root ) where - -data T - -root :: T -> () -root _ = ()