stan 0.1.0.1 → 0.1.0.2
raw patch · 11 files changed
+173/−24 lines, 11 filesdep ~basedep ~bytestringdep ~ghc
Dependency ranges changed: base, bytestring, ghc, ghc-boot-th, hedgehog, optparse-applicative, pretty-simple
Files
- CHANGELOG.md +15/−0
- README.md +31/−12
- src/Stan/Ghc/Compat.hs +2/−0
- src/Stan/Ghc/Compat906.hs +1/−1
- src/Stan/Hie/Compat.hs +2/−0
- src/Stan/Hie/Compat904.hs +1/−1
- src/Stan/Hie/Debug.hs +2/−0
- src/Stan/Hie/Debug908.hs +99/−0
- src/Stan/Pattern/Type.hs +4/−0
- src/Stan/Report/Html.hs +8/−3
- stan.cabal +8/−7
CHANGELOG.md view
@@ -3,6 +3,21 @@ `stan` uses [PVP Versioning][1]. The change log is available [on GitHub][2]. +## 0.1.0.2++* Add prospective support for GHC 9.8++ * will only work with `Cabal` library version 3.10 -- if this causes+ problems for you please comment on the corresponding [`extensions`+ ticket](https://github.com/kowainik/extensions/issues/89)++ * thanks to @0rphee++ * we don't provide a binary release for 9.8.1 because `stan`'s+ dependencies have not yet caught up with 9.8.1. If you want to+ use `stan` with 9.8.1 you can install it from Hackage with `cabal+ install stan --allow-newer`.+ ## 0.1.0.1 * Add support for GHC 9.6 (will only work with `Cabal` library version
README.md view
@@ -193,37 +193,39 @@ [[Back to the Table of Contents] ↑](#table-of-contents) -Below are the steps to install Stan using the Stack build tool.+Below are the steps to install Stan from its repository using the Stack tool. > You need to have [Stack ⩾ 2.1.3](http://haskellstack.org) -First, you need to clone the repository.+First, you need to clone the repository and change to the `stan` directory: ```shell $ git clone https://github.com/kowainik/stan.git $ cd stan ``` -Then, you need to build it using Stack:+Then, using Stack, you need to build the package and copy the executable to the+desired location (typically one on your PATH). If Stack's `--local-bin-path`+option is omitted, Stack will copy the built executable to a+[default location](https://docs.haskellstack.org/en/stable/yaml_configuration/#local-bin-path): ```shell-$ stack build+$ stack --local-bin-path=<path_to_desired_location> install ``` -Finally, you can copy the resulting executable under the desired-location (that should be under the PATH environment variable), like-so:--```shell-$ cp "$(stack path --local-install-root)/bin/stan" ~/.local/bin/stan-```+Stack's build, including the version of GHC used, will be configured by a+`stack.yaml` file provided by the repository or the package from Hackage. If you+wish to build Stan with a different version of GHC than that assumed, you will+need to edit the configuration accordingly. ### Hackage [[Back to the Table of Contents] ↑](#table-of-contents) -Stan is available on Hackage. You can install the tool from there as well:+Stan is available on Hackage. +Using the Cabal build tool, you can install the tool from there as well:+ ```shell $ cabal v2-install stan --install-method=copy --overwrite-policy=always ```@@ -237,6 +239,23 @@ --install-method=copy \ --overwrite-policy=always \ --program-suffix=-8.10.1+```++Using the Stack tool, you can also install a version of Stan from Hackage:++First, you need to unpack the package locally and change to the package's+directory. The following example assumes `stan-0.1.0.1`:++```shell+$ stack unpack stan-0.1.0.1 # Specify 'stan' for the most recent version+$ cd stan-0.1.0.1 # The directory is named after the package version+```++Then, using Stack, you need to build the package and copy the executable to the+desired location (as above, for the repository example):++```shell+$ stack --local-bin-path=<path_to_desired_location> install ``` ### Homebrew
src/Stan/Ghc/Compat.hs view
@@ -12,4 +12,6 @@ import Stan.Ghc.Compat902 as Compat #elif __GLASGOW_HASKELL__ == 906 import Stan.Ghc.Compat906 as Compat+#elif __GLASGOW_HASKELL__ == 908+import Stan.Ghc.Compat906 as Compat #endif
src/Stan/Ghc/Compat906.hs view
@@ -4,7 +4,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} module Stan.Ghc.Compat906-#if __GLASGOW_HASKELL__ == 906+#if __GLASGOW_HASKELL__ == 906 || __GLASGOW_HASKELL__ == 908 ( -- * Modules Module , ModuleName
src/Stan/Hie/Compat.hs view
@@ -12,4 +12,6 @@ import Stan.Hie.Compat904 as Compat #elif __GLASGOW_HASKELL__ == 906 import Stan.Hie.Compat904 as Compat+#elif __GLASGOW_HASKELL__ == 908+import Stan.Hie.Compat904 as Compat #endif
src/Stan/Hie/Compat904.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE CPP #-} module Stan.Hie.Compat904-#if __GLASGOW_HASKELL__ == 904 || __GLASGOW_HASKELL__ == 906+#if __GLASGOW_HASKELL__ == 904 || __GLASGOW_HASKELL__ == 906 || __GLASGOW_HASKELL__ == 908 ( -- * Main HIE types ContextInfo (..) , HieArgs (..)
src/Stan/Hie/Debug.hs view
@@ -12,4 +12,6 @@ import Stan.Hie.Debug902 as Compat #elif __GLASGOW_HASKELL__ == 906 import Stan.Hie.Debug902 as Compat+#elif __GLASGOW_HASKELL__ == 908+import Stan.Hie.Debug908 as Compat #endif
+ src/Stan/Hie/Debug908.hs view
@@ -0,0 +1,99 @@+{-# LANGUAGE CPP #-}++{-# OPTIONS_GHC -fno-warn-orphans #-}++{-# LANGUAGE FlexibleInstances #-}++{- |+Copyright: (c) 2020 Kowainik+SPDX-License-Identifier: MPL-2.0+Maintainer: Kowainik <xrom.xkov@gmail.com>++Useful debugging and printing utilities for HIE types. They are+implemented in two ways:++1. Using derived 'Show' instances.+2. Using @ghc@ pretty-printing.++To make full use of derived 'Show' instances, add the @pretty-simple@+package to dependencies and use the @pPrint@ function from the+@Text.Pretty.Simple@ module.+-}++module Stan.Hie.Debug908+#if __GLASGOW_HASKELL__ == 908+ ( debugHieFile+ ) where++import Text.Pretty.Simple (pPrint)++import Stan.Core.ModuleName (fromGhcModule)+import Stan.Ghc.Compat (AvailInfo (..), FieldLabel (..), IfaceTyCon (..),+ IfaceTyConInfo (..), IfaceTyConSort (..), IfaceTyLit (..), Module,+ Name, PromotionFlag (..), TupleSort (..), isExternalName,+ moduleStableString, moduleUnitId, nameModule, nameOccName,+ nameStableString, occNameString, showTUnitId)+import Stan.Hie.Compat (HieAST (..), HieASTs (..), HieArgs (..), HieFile (..), HieType (..),+ IdentifierDetails (..), NodeInfo (..))+import Stan.NameMeta (NameMeta (..))++import qualified Text.Show++import GHC.Iface.Ext.Types (SourcedNodeInfo(..), NodeOrigin(..), ContextInfo(..), IEType(..), BindType(..), Scope(..), DeclType(..), TyVarScope(..), RecFieldContext(..), EvVarSource(..), EvBindDeps(..), DeclType(..), NodeAnnotation (..))+import GHC.Types.Var (Specificity(..))++debugHieFile :: FilePath -> [HieFile] -> IO ()+debugHieFile path hieFiles = do+ let mHieFile = find (\HieFile{..} -> hie_hs_file == path) hieFiles+ whenJust mHieFile pPrint++deriving stock instance Show a => Show (SourcedNodeInfo a)+deriving stock instance Show NodeOrigin+deriving stock instance Show ContextInfo+deriving stock instance Show IEType+deriving stock instance Show BindType+deriving stock instance Show Scope+deriving stock instance Show DeclType+deriving stock instance Show TyVarScope+deriving stock instance Show EvBindDeps+deriving stock instance Show EvVarSource+deriving stock instance Show RecFieldContext++deriving stock instance Show Specificity++-- orphan intances+deriving stock instance Show HieFile+deriving stock instance Show a => Show (HieType a)+deriving stock instance Show a => Show (HieAST a)+deriving newtype instance Show a => Show (HieASTs a)+deriving newtype instance Show a => Show (HieArgs a)+deriving stock instance Show a => Show (NodeInfo a)+deriving stock instance Show a => Show (IdentifierDetails a)+deriving stock instance Show IfaceTyCon+deriving stock instance Show IfaceTyConInfo+deriving stock instance Show IfaceTyConSort+deriving stock instance Show IfaceTyLit+deriving stock instance Show PromotionFlag+deriving stock instance Show TupleSort+deriving stock instance Show AvailInfo+deriving stock instance Show FieldLabel+deriving stock instance Show NodeAnnotation++instance Show Module where+ show = moduleStableString++instance Show Name where+ show nm =+ if isExternalName nm+ then show $ toNameMeta nm+ else nameStableString nm+ where+ toNameMeta :: Name -> NameMeta+ toNameMeta name =+ let nameMetaName = toText $ occNameString $ nameOccName name+ nameMetaModuleName = fromGhcModule $ nameModule name+ nameMetaPackage = showTUnitId $ moduleUnitId $ nameModule name+ in NameMeta{..}+#else+ () where+#endif
src/Stan/Pattern/Type.hs view
@@ -176,7 +176,11 @@ -- | 'PatternType' for pair @(,)@. pairPattern :: PatternType+#if __GLASGOW_HASKELL__ < 908 pairPattern = "(,)" `ghcPrimNameFrom` ghcTuple |:: [ (?), (?) ]+#elif __GLASGOW_HASKELL__ >= 908+pairPattern = "Tuple2" `ghcPrimNameFrom` ghcTuple |:: [ (?), (?) ]+#endif where #if __GLASGOW_HASKELL__ < 906 ghcTuple = "GHC.Tuple"
src/Stan/Report/Html.hs view
@@ -219,6 +219,7 @@ stanObservations :: Analysis -> Html stanObservations Analysis{..} = do+ let toRender = filter (not . null . fileInfoObservations) $ Map.elems analysisFileMap divClass "row" $ blockP $ fold [ "Based on the analysis results, Stan found several areas for improvement " , "in the analysed files. In Stan terminology, we call these findings "@@ -226,12 +227,16 @@ , "information about each observation, and find the possible ways to fix " , "them for your project." ]- traverse_ stanPerFile $- filter (not . null . fileInfoObservations) $ Map.elems analysisFileMap+ ul $ traverse_ tocPerFile toRender+ traverse_ stanPerFile toRender +tocPerFile :: FileInfo -> Html+tocPerFile FileInfo{fileInfoModuleName = ModuleName mName} =+ li $ span $ a ! A.class_ "ins-link" ! A.href (fromText $ "#" <> mName) $ toHtml mName+ stanPerFile :: FileInfo -> Html stanPerFile FileInfo{..} = divIdClass "file" "row" $ do- h3 ! A.class_ "grey-bg" $ toHtml $ "📄 " <> fileInfoPath+ h3 ! A.class_ "grey-bg" ! A.id (fromText $ unModuleName fileInfoModuleName) $ toHtml $ "📄 " <> fileInfoPath ul $ do li $ tableWithShadow "col-6" $ do tableRow "Module" $ code $ toHtml $ unModuleName fileInfoModuleName
stan.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: stan-version: 0.1.0.1+version: 0.1.0.2 synopsis: Haskell STatic ANalyser description: Stan is a Haskell __ST__atic __AN__alysis CLI tool.@@ -27,7 +27,7 @@ location: https://github.com/kowainik/stan.git common common-options- build-depends: base >= 4.13 && < 4.19 && (< 4.16.3.0 || >= 4.17)+ build-depends: base >= 4.13 && < 4.20 && (< 4.16.3.0 || >= 4.17) -- ^^ .hie files don't contain enough type -- information on ghc-9.2.[4-8] (base >= -- 4.16.3.0 && < 4.17)@@ -130,11 +130,12 @@ Stan.Hie.Debug810 Stan.Hie.Debug900 Stan.Hie.Debug902+ Stan.Hie.Debug908 build-depends: array ^>= 0.5 , base64 ^>= 0.4.1 , blaze-html ^>= 0.9.1- , bytestring >= 0.10 && < 0.12+ , bytestring >= 0.10 && < 0.13 , clay ^>= 0.14 , colourista >= 0.1 && < 0.3 , cryptohash-sha1 ^>= 0.11@@ -142,11 +143,11 @@ , directory ^>= 1.3 , extensions ^>= 0.0.0.1 || ^>= 0.1.0.0 , filepath ^>= 1.4- , ghc >= 8.8 && < 9.7- , ghc-boot-th >= 8.8 && < 9.7+ , ghc >= 8.8 && < 9.9+ , ghc-boot-th >= 8.8 && < 9.9 , gitrev ^>= 1.3.1 , microaeson ^>= 0.1.0.0- , optparse-applicative >= 0.15 && < 0.17+ , optparse-applicative >= 0.15 && < 0.19 , pretty-simple ^>= 4.0 , process ^>= 1.6.8.0 , slist >= 0.1 && < 0.3@@ -201,7 +202,7 @@ , containers , filepath ^>= 1.4 , ghc- , hedgehog >= 1.0 && < 1.4+ , hedgehog >= 1.0 && < 1.5 , hspec >= 2.7 && < 2.12 , hspec-hedgehog >= 0.0.1.2 , optparse-applicative