Skip to content

Commit

Permalink
Changes to avoid GHC warnings on building
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Oct 14, 2023
1 parent bbab16c commit 0163ff6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Stan/Ghc/Compat810.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ import qualified Data.Text as T
showTUnitId :: UnitId -> Text
showTUnitId = T.pack . unitIdString
#else
where
() where
#endif
1 change: 1 addition & 0 deletions src/Stan/Hie.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Stan.Hie
) where

import Colourista (errorMessage, infoMessage, warningMessage)
import Prelude hiding (span)
import System.Directory (doesDirectoryExist, doesFileExist)
import System.Directory.Recursive (getDirRecursive)
import System.FilePath (takeExtension)
Expand Down
18 changes: 9 additions & 9 deletions src/Stan/Hie/MatchAst.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Stan.Hie.MatchAst
) where

import Data.Char (toLower)

import Prelude hiding (span)
import Stan.Core.List (checkWith)
import Stan.Ghc.Compat (nameOccName, occNameString)
import Stan.Hie (slice)
Expand Down Expand Up @@ -54,7 +54,7 @@ hieMatchPatternAst hie@HieFile{..} node@Node{..} = \case
hieMatchPatternAst hie node p1
&& hieMatchPatternAst hie node p2
PatternAstConstant lit ->
Set.member literalAnns (Set.map toNodeAnnotation (nodeAnnotations nodeInfo))
Set.member literalAnns (Set.map toNodeAnnotation (nodeAnnotations nodeInfo'))
&& ( let span = slice nodeSpan hie_hs_src in case lit of
ExactNum n -> (span >>= readMaybe . decodeUtf8) == Just n
ExactStr s -> span == Just s
Expand All @@ -65,26 +65,26 @@ hieMatchPatternAst hie@HieFile{..} node@Node{..} = \case
PatternAstName nameMeta patType ->
any (matchNameAndType nameMeta patType)
$ Map.assocs
$ nodeIdentifiers nodeInfo
$ nodeIdentifiers nodeInfo'
PatternAstNode tags ->
matchAnnotations tags nodeInfo
matchAnnotations tags nodeInfo'
PatternAstNodeExact tags patChildren ->
matchAnnotations tags nodeInfo
matchAnnotations tags nodeInfo'
&& checkWith (hieMatchPatternAst hie) nodeChildren patChildren
PatternAstVarName varName -> isJust $ find
(\case
Right x -> varName `Str.isInfixOf` map toLower (occNameString $ nameOccName x)
Left _ -> False
)
$ Map.keys $ nodeIdentifiers nodeInfo
$ Map.keys $ nodeIdentifiers nodeInfo'
PatternAstIdentifierDetailsDecl declType -> any (any (isDecl declType) . identInfo) $
Map.elems $ nodeIdentifiers nodeInfo
Map.elems $ nodeIdentifiers nodeInfo'
where
matchAnnotations :: Set NodeAnnotation -> NodeInfo TypeIndex -> Bool
matchAnnotations tags NodeInfo{..} =
tags `Set.isSubsetOf` Set.map toNodeAnnotation nodeAnnotations

nodeInfo = Stan.Hie.Compat.nodeInfo node
nodeInfo' = Stan.Hie.Compat.nodeInfo node

matchNameAndType
:: NameMeta
Expand All @@ -93,7 +93,7 @@ hieMatchPatternAst hie@HieFile{..} node@Node{..} = \case
-> Bool
matchNameAndType nameMeta patType ids =
hieMatchNameMeta nameMeta ids
&& case nodeType nodeInfo of
&& case nodeType nodeInfo' of
[] -> False
t : _ -> hieMatchPatternType hie_types patType t

Expand Down
1 change: 1 addition & 0 deletions src/Stan/Pattern/Ast.hs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ foo :: Some -> Type
typeSig :: PatternAst
typeSig = PatternAstNode $ one (mkNodeAnnotation "TypeSig" "Sig")

absBinds :: NodeAnnotation
absBinds =
#if __GLASGOW_HASKELL__ < 904
mkNodeAnnotation "AbsBinds" "HsBindLR"
Expand Down
2 changes: 2 additions & 0 deletions src/Stan/Pattern/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ listFunPattern :: PatternType
listFunPattern = listPattern |-> (?)

-- | 'PatternType' for 'Integer'.
integerPattern :: PatternType
integerPattern =
#if __GLASGOW_HASKELL__ < 900
integerPattern810
Expand All @@ -115,6 +116,7 @@ integerPattern =
#endif

-- | 'PatternType' for 'Natural'.
naturalPattern :: PatternType
naturalPattern =
#if __GLASGOW_HASKELL__ < 900
naturalPattern810
Expand Down

0 comments on commit 0163ff6

Please sign in to comment.