mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-08-16 08:10:55 +03:00
Update dependencies
What? ===== This updates certain dependencies to ensure it can compile both via Stack and Cabal (which impacts the ability to install via Homebrew).
This commit is contained in:
parent
e8377f5498
commit
30950ad00b
@ -4,8 +4,9 @@ import qualified Data.Bifunctor as BF
|
|||||||
import Data.Monoid ((<>))
|
import Data.Monoid ((<>))
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
import Data.Void (Void)
|
||||||
import Text.Megaparsec
|
import Text.Megaparsec
|
||||||
import Text.Megaparsec.Text
|
import Text.Megaparsec.Char
|
||||||
import Unused.Projection.Transform
|
import Unused.Projection.Transform
|
||||||
|
|
||||||
data ParsedTransform = ParsedTransform
|
data ParsedTransform = ParsedTransform
|
||||||
@ -14,6 +15,8 @@ data ParsedTransform = ParsedTransform
|
|||||||
, ptPost :: Text
|
, ptPost :: Text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Parser = Parsec Void Text
|
||||||
|
|
||||||
translate :: Text -> Either String (Text -> Text)
|
translate :: Text -> Either String (Text -> Text)
|
||||||
translate template = applyTransform <$> parseTransform template
|
translate template = applyTransform <$> parseTransform template
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@ import qualified Data.Either as E
|
|||||||
import qualified Data.FileEmbed as FE
|
import qualified Data.FileEmbed as FE
|
||||||
import qualified Data.Yaml as Y
|
import qualified Data.Yaml as Y
|
||||||
import qualified System.Directory as D
|
import qualified System.Directory as D
|
||||||
import System.FilePath ((</>))
|
import System.FilePath ((</>))
|
||||||
import Unused.ResultsClassifier.Types (LanguageConfiguration, ParseConfigError(..))
|
import Unused.ResultsClassifier.Types (LanguageConfiguration, ParseConfigError(..))
|
||||||
import Unused.Util (safeReadFile)
|
import Unused.Util (safeReadFile)
|
||||||
|
|
||||||
loadConfig :: Either String [LanguageConfiguration]
|
loadConfig :: Either String [LanguageConfiguration]
|
||||||
loadConfig = Y.decodeEither defaultConfigFile
|
loadConfig = decodeEither defaultConfigFile
|
||||||
|
|
||||||
defaultConfigFile :: BS.ByteString
|
defaultConfigFile :: BS.ByteString
|
||||||
defaultConfigFile = $(FE.embedFile "data/config.yml")
|
defaultConfigFile = $(FE.embedFile "data/config.yml")
|
||||||
@ -24,24 +24,21 @@ defaultConfigFile = $(FE.embedFile "data/config.yml")
|
|||||||
loadAllConfigurations :: IO (Either [ParseConfigError] [LanguageConfiguration])
|
loadAllConfigurations :: IO (Either [ParseConfigError] [LanguageConfiguration])
|
||||||
loadAllConfigurations = do
|
loadAllConfigurations = do
|
||||||
homeDir <- D.getHomeDirectory
|
homeDir <- D.getHomeDirectory
|
||||||
|
|
||||||
let defaultConfig = addSourceToLeft "default config" loadConfig
|
let defaultConfig = addSourceToLeft "default config" loadConfig
|
||||||
|
|
||||||
localConfig <- loadConfigFromFile ".unused.yml"
|
localConfig <- loadConfigFromFile ".unused.yml"
|
||||||
userConfig <- loadConfigFromFile $ homeDir </> ".unused.yml"
|
userConfig <- loadConfigFromFile $ homeDir </> ".unused.yml"
|
||||||
|
|
||||||
let (lefts, rights) = E.partitionEithers [defaultConfig, localConfig, userConfig]
|
let (lefts, rights) = E.partitionEithers [defaultConfig, localConfig, userConfig]
|
||||||
|
return $
|
||||||
return $ if not (null lefts)
|
if not (null lefts)
|
||||||
then Left lefts
|
then Left lefts
|
||||||
else Right $ concat rights
|
else Right $ concat rights
|
||||||
|
|
||||||
loadConfigFromFile :: String -> IO (Either ParseConfigError [LanguageConfiguration])
|
loadConfigFromFile :: String -> IO (Either ParseConfigError [LanguageConfiguration])
|
||||||
loadConfigFromFile path =
|
loadConfigFromFile path =
|
||||||
either
|
either (const $ Right []) (addSourceToLeft path . decodeEither) <$> safeReadFile path
|
||||||
(const $ Right [])
|
|
||||||
(addSourceToLeft path . Y.decodeEither)
|
|
||||||
<$> safeReadFile path
|
|
||||||
|
|
||||||
addSourceToLeft :: String -> Either String c -> Either ParseConfigError c
|
addSourceToLeft :: String -> Either String c -> Either ParseConfigError c
|
||||||
addSourceToLeft = BF.first . ParseConfigError
|
addSourceToLeft = BF.first . ParseConfigError
|
||||||
|
|
||||||
|
decodeEither :: Y.FromJSON a => BS.ByteString -> Either String a
|
||||||
|
decodeEither = BF.first Y.prettyPrintParseException . Y.decodeEither'
|
||||||
|
@ -13,4 +13,4 @@ data SearchBackend
|
|||||||
|
|
||||||
newtype SearchResults = SearchResults
|
newtype SearchResults = SearchResults
|
||||||
{ fromResults :: [TermMatch]
|
{ fromResults :: [TermMatch]
|
||||||
} deriving (Monoid)
|
} deriving (Semigroup, Monoid)
|
||||||
|
@ -2,19 +2,14 @@
|
|||||||
# For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration/
|
# For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration/
|
||||||
|
|
||||||
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
|
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
|
||||||
resolver: lts-11.0
|
resolver: lts-12.6
|
||||||
|
|
||||||
# Local packages, usually specified by relative directory name
|
# Local packages, usually specified by relative directory name
|
||||||
packages:
|
packages:
|
||||||
- '.'
|
- '.'
|
||||||
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
|
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- cassava-0.4.5.1
|
- megaparsec-6.5.0
|
||||||
- hspec-2.5.0
|
|
||||||
- hspec-core-2.5.0
|
|
||||||
- hspec-discover-2.5.0
|
|
||||||
- inflections-0.3.0.0
|
|
||||||
- megaparsec-5.3.1
|
|
||||||
- terminal-progress-bar-0.1.1.1
|
- terminal-progress-bar-0.1.1.1
|
||||||
|
|
||||||
# Override default flag values for local packages and extra-deps
|
# Override default flag values for local packages and extra-deps
|
||||||
|
@ -75,12 +75,12 @@ library
|
|||||||
, bytestring
|
, bytestring
|
||||||
, text
|
, text
|
||||||
, unordered-containers
|
, unordered-containers
|
||||||
, cassava >= 0.4.5.0 && < 0.5
|
, cassava >= 0.5.1.0 && < 0.6
|
||||||
, vector
|
, vector
|
||||||
, mtl
|
, mtl
|
||||||
, transformers
|
, transformers
|
||||||
, megaparsec >= 5.1.2 && < 6
|
, megaparsec >= 6.5.0 && < 7
|
||||||
, inflections >= 0.3.0.0 && < 0.4
|
, inflections >= 0.4.0.3 && < 0.5
|
||||||
, file-embed
|
, file-embed
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
Loading…
Reference in New Issue
Block a user