mirror of
https://github.com/ocharles/weeder.git
synced 2024-11-26 08:47:14 +03:00
Compare commits
2 Commits
5bc013b1e3
...
01c900f742
Author | SHA1 | Date | |
---|---|---|---|
|
01c900f742 | ||
|
59c83d8dc8 |
@ -1,5 +1,10 @@
|
||||
## Changelog for Weeder
|
||||
|
||||
### [`2.5.0`][v2.5.0] - *2023-01-23*
|
||||
|
||||
- Weeder has been upgraded to support GHC 9.4 (only). As this changes the
|
||||
format of `.hie` files accepted, this is a major version bump. Thanks to @tfausak!
|
||||
|
||||
### [`2.4.1`][v2.4.1] - *2023-01-05*
|
||||
|
||||
- Build with `lens-5.2`
|
||||
|
@ -1,2 +1,10 @@
|
||||
packages:
|
||||
weeder.cabal
|
||||
|
||||
-- https://github.com/well-typed/cborg/pull/304
|
||||
source-repository-package
|
||||
type: git
|
||||
location: https://github.com/scarf-sh/cborg
|
||||
tag: 8dae0d21e6f17e30785f35bb3ef5eb611863a904
|
||||
subdir: cborg
|
||||
--sha256: sha256-SAHFIlN5QKQKJFhHliXvXOQhrqvsE/TLvY2rkftXkHM=
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ compiler-nix-name ? "ghc925" }:
|
||||
{ compiler-nix-name ? "ghc943" }:
|
||||
let
|
||||
haskellNix = import (import ./nix/sources.nix)."haskell.nix" {};
|
||||
|
||||
|
@ -5,10 +5,10 @@
|
||||
"homepage": "https://input-output-hk.github.io/haskell.nix",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "haskell.nix",
|
||||
"rev": "e339ff5b2862443f19971c524a09169c10706aaa",
|
||||
"sha256": "0r6sjxl89i297ibvqx4zs5dvkjd9hhp4zyspalva94mbzaxl8404",
|
||||
"rev": "9cd5fc04b9577d951eca4718b4066f4259bcba5e",
|
||||
"sha256": "0rydx3z29g80kp51s4wlkh3r8zfnjdnmbbgikhsbalplpnqm8kmz",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/input-output-hk/haskell.nix/archive/e339ff5b2862443f19971c524a09169c10706aaa.tar.gz",
|
||||
"url": "https://github.com/input-output-hk/haskell.nix/archive/9cd5fc04b9577d951eca4718b4066f4259bcba5e.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"niv": {
|
||||
|
@ -1,7 +1,6 @@
|
||||
{-# language ApplicativeDo #-}
|
||||
{-# language BlockArguments #-}
|
||||
{-# language FlexibleContexts #-}
|
||||
{-# language LambdaCase #-}
|
||||
{-# language NamedFieldPuns #-}
|
||||
{-# language OverloadedStrings #-}
|
||||
|
||||
@ -9,16 +8,11 @@
|
||||
|
||||
module Weeder.Main ( main, mainWithConfig ) where
|
||||
|
||||
-- algebraic-graphs
|
||||
import Algebra.Graph.Export.Dot ( export, defaultStyleViaShow )
|
||||
|
||||
-- base
|
||||
import Control.Exception ( evaluate )
|
||||
import Control.Monad ( guard, unless, when )
|
||||
import Control.Monad.IO.Class ( liftIO )
|
||||
import Data.Bool
|
||||
import Data.Foldable
|
||||
import Data.IORef ( atomicModifyIORef, newIORef, readIORef )
|
||||
import Data.List ( isSuffixOf )
|
||||
import Data.Version ( showVersion )
|
||||
import System.Exit ( exitFailure )
|
||||
@ -40,13 +34,12 @@ import System.Directory ( canonicalizePath, doesDirectoryExist, doesFileExist, d
|
||||
import System.FilePath ( isExtensionOf )
|
||||
|
||||
-- ghc
|
||||
import GHC.Iface.Ext.Binary ( HieFileResult( HieFileResult, hie_file_result ), NameCacheUpdater( NCU ), readHieFileWithVersion )
|
||||
import GHC.Iface.Ext.Binary ( HieFileResult( HieFileResult, hie_file_result ), readHieFileWithVersion )
|
||||
import GHC.Iface.Ext.Types ( HieFile( hie_hs_file ), hieVersion )
|
||||
import GHC.Unit.Module ( moduleName, moduleNameString )
|
||||
import GHC.Types.Name.Cache ( initNameCache, NameCache )
|
||||
import GHC.Types.Name ( occNameString )
|
||||
import GHC.Types.SrcLoc ( RealSrcLoc, realSrcSpanStart, srcLocLine )
|
||||
import GHC.Types.Unique.Supply ( mkSplitUniqSupply )
|
||||
|
||||
-- regex-tdfa
|
||||
import Text.Regex.TDFA ( (=~) )
|
||||
@ -124,13 +117,13 @@ mainWithConfig hieExt hieDirectories requireHsFiles Config{ rootPatterns, typeCl
|
||||
then getFilesIn ".hs" "./."
|
||||
else pure []
|
||||
|
||||
nameCacheUpdater <-
|
||||
mkNameCacheUpdater
|
||||
nameCache <-
|
||||
initNameCache 'z' []
|
||||
|
||||
analysis <-
|
||||
flip execStateT emptyAnalysis do
|
||||
for_ hieFilePaths \hieFilePath -> do
|
||||
hieFileResult <- liftIO ( readCompatibleHieFileOrExit nameCacheUpdater hieFilePath )
|
||||
hieFileResult <- liftIO ( readCompatibleHieFileOrExit nameCache hieFilePath )
|
||||
let hsFileExists = any ( hie_hs_file hieFileResult `isSuffixOf` ) hsFilePaths
|
||||
when (requireHsFiles ==> hsFileExists) do
|
||||
analyseHieFile hieFileResult
|
||||
@ -220,9 +213,9 @@ getFilesIn ext path = do
|
||||
|
||||
|
||||
-- | Read a .hie file, exiting if it's an incompatible version.
|
||||
readCompatibleHieFileOrExit :: NameCacheUpdater -> FilePath -> IO HieFile
|
||||
readCompatibleHieFileOrExit nameCacheUpdater path = do
|
||||
res <- readHieFileWithVersion (\(v, _) -> v == hieVersion) nameCacheUpdater path
|
||||
readCompatibleHieFileOrExit :: NameCache -> FilePath -> IO HieFile
|
||||
readCompatibleHieFileOrExit nameCache path = do
|
||||
res <- readHieFileWithVersion (\(v, _) -> v == hieVersion) nameCache path
|
||||
case res of
|
||||
Right HieFileResult{ hie_file_result } ->
|
||||
return hie_file_result
|
||||
@ -237,20 +230,6 @@ readCompatibleHieFileOrExit nameCacheUpdater path = do
|
||||
exitFailure
|
||||
|
||||
|
||||
mkNameCacheUpdater :: IO NameCacheUpdater
|
||||
mkNameCacheUpdater = do
|
||||
nameCache <- do
|
||||
uniqSupply <- mkSplitUniqSupply 'z'
|
||||
return ( initNameCache uniqSupply [] )
|
||||
|
||||
nameCacheRef <- newIORef nameCache
|
||||
|
||||
let update_nc f = do r <- atomicModifyIORef nameCacheRef f
|
||||
_ <- evaluate =<< readIORef nameCacheRef
|
||||
return r
|
||||
return (NCU update_nc)
|
||||
|
||||
|
||||
infixr 5 ==>
|
||||
|
||||
|
||||
@ -258,4 +237,3 @@ infixr 5 ==>
|
||||
(==>) :: Bool -> Bool -> Bool
|
||||
True ==> x = x
|
||||
False ==> _ = True
|
||||
|
||||
|
@ -5,7 +5,7 @@ name: weeder
|
||||
author: Ollie Charles <ollie@ocharles.org.uk>
|
||||
maintainer: Ollie Charles <ollie@ocharles.org.uk>
|
||||
build-type: Simple
|
||||
version: 2.4.1
|
||||
version: 2.5.0
|
||||
copyright: Neil Mitchell 2017-2020, Oliver Charles 2020-2023
|
||||
synopsis: Detect dead code
|
||||
description: Find declarations.
|
||||
@ -19,19 +19,19 @@ extra-doc-files:
|
||||
library
|
||||
build-depends:
|
||||
, algebraic-graphs ^>= 0.4 || ^>= 0.5 || ^>= 0.6
|
||||
, base ^>= 4.16.0.0
|
||||
, base ^>= 4.17.0.0
|
||||
, bytestring ^>= 0.10.9.0 || ^>= 0.11.0.0
|
||||
, containers ^>= 0.6.2.1
|
||||
, dhall ^>= 1.30.0 || ^>= 1.31.0 || ^>= 1.32.0 || ^>= 1.33.0 || ^>= 1.34.0 || ^>= 1.35.0 || ^>= 1.36.0 || ^>= 1.37.0 || ^>= 1.40.0 || ^>= 1.41
|
||||
, directory ^>= 1.3.3.2
|
||||
, filepath ^>= 1.4.2.1
|
||||
, generic-lens ^>= 2.2.0.0
|
||||
, ghc ^>= 9.2
|
||||
, ghc ^>= 9.4
|
||||
, lens ^>= 5.1 || ^>= 5.2
|
||||
, mtl ^>= 2.2.2
|
||||
, optparse-applicative ^>= 0.14.3.0 || ^>= 0.15.1.0 || ^>= 0.16.0.0 || ^>= 0.17
|
||||
, regex-tdfa ^>= 1.2.0.0 || ^>= 1.3.1.0
|
||||
, text ^>= 1.2.3.0
|
||||
, text ^>= 2.0.1
|
||||
, transformers ^>= 0.5.6.2 || ^>= 0.6
|
||||
hs-source-dirs: src
|
||||
exposed-modules:
|
||||
|
Loading…
Reference in New Issue
Block a user