argon 0.3.1.0 → 0.3.1.1
raw patch · 12 files changed
+153/−1 lines, 12 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- argon.cabal +2/−1
- src/Argon/Preprocess.hs +2/−0
- test/data/andop.hs +1/−0
- test/data/case.hs +4/−0
- test/data/cpp-error.hs +5/−0
- test/data/cpp.hs +8/−0
- test/data/ifthenelse.hs +1/−0
- test/data/lambdacase.hs +5/−0
- test/data/multiif.hs +5/−0
- test/data/orop.hs +1/−0
- test/data/stack-setup.hs +118/−0
- test/data/syntaxerror.hs +1/−0
argon.cabal view
@@ -1,5 +1,5 @@ name: argon-version: 0.3.1.0+version: 0.3.1.1 synopsis: Measure your code's complexity homepage: http://github.com/rubik/argon bug-reports: http://github.com/rubik/argon/issues@@ -23,6 +23,7 @@ README.md CHANGELOG.md USAGE.txt+ test/data/*.hs tested-with: GHC >= 7.8 library
src/Argon/Preprocess.hs view
@@ -1,3 +1,5 @@+-- The following code is taken from ghc-exactprint, because adding a dependency+-- for just one module seemed excessive. {-# LANGUAGE CPP #-} {-# LANGUAGE RecordWildCards #-} -- | This module provides support for CPP and interpreter directives.
+ test/data/andop.hs view
@@ -0,0 +1,1 @@+g n = n < 68 && n `mod` 3 == 2 && n > 49
+ test/data/case.hs view
@@ -0,0 +1,4 @@+func n = case n of+ 2 -> 3+ 4 -> 6+ _ -> 42
+ test/data/cpp-error.hs view
@@ -0,0 +1,5 @@+{-# LANGUAGE CPP #-}+#if 0+f = 3+#else+f m n = 2
+ test/data/cpp.hs view
@@ -0,0 +1,8 @@+{-# LANGUAGE CPP #-}+#if 0+f = 3+#else+f m n = case 2*n of+ 3 -> if m == 4 || m - n < 0 then 32 else 42+ _ -> 41+#endif
+ test/data/ifthenelse.hs view
@@ -0,0 +1,1 @@+f n = if n == 4 then 24 else 20
+ test/data/lambdacase.hs view
@@ -0,0 +1,5 @@+{-# LANGUAGE LambdaCase #-}+g = \case+ 3 -> 4+ 2 -> 5+ _ -> 6
+ test/data/multiif.hs view
@@ -0,0 +1,5 @@+{-# LANGUAGE MultiWayIf #-}+f n = if | n `mod` 34 == 0 -> 3+ | n `div` 24 == 1 -> 24+ | n + 42 - 4 == 0 -> 2424+ | _ -> 42
+ test/data/orop.hs view
@@ -0,0 +1,1 @@+g n = n == 2 || n == 49 || n == 2489
+ test/data/stack-setup.hs view
@@ -0,0 +1,118 @@+{-# LANGUAGE TemplateHaskell #-}+-- Real example taken from Stack's source code (Setup.hs)+ensureCompiler sopts = do+ let wc = whichCompiler (soptsWantedCompiler sopts)+ when (getGhcVersion (soptsWantedCompiler sopts) < $(mkVersion "7.8")) $ do+ $logWarn "stack will almost certainly fail with GHC below version 7.8"+ $logWarn "Valiantly attempting to run anyway, but I know this is doomed"+ $logWarn "For more information, see: https://github.com/commercialhaskell/stack/issues/648"+ $logWarn ""++ -- Check the available GHCs+ menv0 <- getMinimalEnvOverride++ msystem <-+ if soptsUseSystem sopts+ then getSystemCompiler menv0 wc+ else return Nothing++ Platform expectedArch _ <- asks getPlatform++ let needLocal = case msystem of+ Nothing -> True+ Just _ | soptsSkipGhcCheck sopts -> False+ Just (system, arch) ->+ not (isWanted system) ||+ arch /= expectedArch+ isWanted = isWantedCompiler (soptsCompilerCheck sopts) (soptsWantedCompiler sopts)++ -- If we need to install a GHC, try to do so+ mtools <- if needLocal+ then do+ getSetupInfo' <- runOnce (getSetupInfo (soptsStackSetupYaml sopts) =<< asks getHttpManager)++ localPrograms <- asks $ configLocalPrograms . getConfig+ installed <- listInstalled localPrograms++ -- Install GHC+ ghcVariant <- asks getGHCVariant+ config <- asks getConfig+ ghcPkgName <- parsePackageNameFromString ("ghc" ++ ghcVariantSuffix ghcVariant)+ let installedCompiler =+ case wc of+ Ghc -> getInstalledTool installed ghcPkgName (isWanted . GhcVersion)+ Ghcjs -> getInstalledGhcjs installed isWanted+ compilerTool <- case installedCompiler of+ Just tool -> return tool+ Nothing+ | soptsInstallIfMissing sopts -> do+ si <- getSetupInfo'+ downloadAndInstallCompiler+ si+ (soptsWantedCompiler sopts)+ (soptsCompilerCheck sopts)+ (soptsGHCBindistURL sopts)+ | otherwise -> do+ throwM $ CompilerVersionMismatch+ msystem+ (soptsWantedCompiler sopts, expectedArch)+ ghcVariant+ (soptsCompilerCheck sopts)+ (soptsStackYaml sopts)+ (fromMaybe+ ("Try running \"stack setup\" to install the correct GHC into "+ <> T.pack (toFilePath (configLocalPrograms config)))+ $ soptsResolveMissingGHC sopts)++ -- Install msys2 on windows, if necessary+ platform <- asks getPlatform+ mmsys2Tool <- case platform of+ Platform _ Cabal.Windows | not (soptsSkipMsys sopts) ->+ case getInstalledTool installed $(mkPackageName "msys2") (const True) of+ Just tool -> return (Just tool)+ Nothing+ | soptsInstallIfMissing sopts -> do+ si <- getSetupInfo'+ osKey <- getOSKey platform+ VersionedDownloadInfo version info <-+ case Map.lookup osKey $ siMsys2 si of+ Just x -> return x+ Nothing -> error $ "MSYS2 not found for " ++ T.unpack osKey+ let tool = Tool (PackageIdentifier $(mkPackageName "msys2") version)+ Just <$> downloadAndInstallTool (configLocalPrograms config) si info tool (installMsys2Windows osKey)+ | otherwise -> do+ $logWarn "Continuing despite missing tool: msys2"+ return Nothing+ _ -> return Nothing++ return $ Just (compilerTool, mmsys2Tool)+ else return Nothing++ mpaths <- case mtools of+ Nothing -> return Nothing+ Just (compilerTool, mmsys2Tool) -> do+ let idents = catMaybes [Just compilerTool, mmsys2Tool]+ paths <- mapM extraDirs idents+ return $ Just $ mconcat paths++ menv <-+ case mpaths of+ Nothing -> return menv0+ Just ed -> do+ config <- asks getConfig+ let m = augmentPathMap (edBins ed) (unEnvOverride menv0)+ mkEnvOverride (configPlatform config) (removeHaskellEnvVars m)++ when (soptsUpgradeCabal sopts) $ do+ unless needLocal $ do+ $logWarn "Trying to upgrade Cabal library on a GHC not installed by stack."+ $logWarn "This may fail, caveat emptor!"+ upgradeCabal menv wc++ case mtools of+ Just (ToolGhcjs cv, _) -> ensureGhcjsBooted menv cv (soptsInstallIfMissing sopts)+ _ -> return ()++ when (soptsSanityCheck sopts) $ sanityCheck menv wc++ return mpaths
+ test/data/syntaxerror.hs view
@@ -0,0 +1,1 @@+g n = 2 +