From af41ab40e1fc4888d1873a9ffe681ddafdfb4ee0 Mon Sep 17 00:00:00 2001 From: Avi Dessauer Date: Wed, 21 Aug 2019 06:03:31 -0400 Subject: Delete trailing whitespace (#42) --- src/HaskellCodeExplorer/AST/RenamedSource.hs | 84 +++++----- src/HaskellCodeExplorer/AST/TypecheckedSource.hs | 200 +++++++++++------------ src/HaskellCodeExplorer/GhcUtils.hs | 142 ++++++++-------- src/HaskellCodeExplorer/ModuleInfo.hs | 60 +++---- src/HaskellCodeExplorer/PackageInfo.hs | 30 ++-- src/HaskellCodeExplorer/Preprocessor.hs | 12 +- src/HaskellCodeExplorer/Types.hs | 40 ++--- 7 files changed, 284 insertions(+), 284 deletions(-) (limited to 'src/HaskellCodeExplorer') diff --git a/src/HaskellCodeExplorer/AST/RenamedSource.hs b/src/HaskellCodeExplorer/AST/RenamedSource.hs index 68aeddb..1f42874 100644 --- a/src/HaskellCodeExplorer/AST/RenamedSource.hs +++ b/src/HaskellCodeExplorer/AST/RenamedSource.hs @@ -21,7 +21,7 @@ import GHC #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) #else , DataFamInstDecl(..) -#endif +#endif , FamilyDecl(..) , FieldOcc(..) , FixitySig(..) @@ -33,7 +33,7 @@ import GHC , HsPatSynDetails #else , HsPatSynDetails(..) -#endif +#endif , HsRecField'(..) , HsTupleSort(..) , HsTyLit(..) @@ -43,7 +43,7 @@ import GHC , IE(..) , LHsBindLR , LHsExpr -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) #else , LHsQTyVars(..) #endif @@ -52,7 +52,7 @@ import GHC , LSig , LTyClDecl , Located - , HsBracket(..) + , HsBracket(..) #if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) , HsMatchContext(..) , Match(..) @@ -83,7 +83,7 @@ import HsExtension (GhcRn) import HaskellCodeExplorer.GhcUtils (hsPatSynDetails, ieLocNames) import Prelude hiding (span) import TysWiredIn - ( nilDataConName + ( nilDataConName , tupleTyConName , typeNatKind , typeSymbolKind @@ -97,7 +97,7 @@ import SrcLoc , srcLocFile , srcLocLine , SrcSpan(..) - ) + ) data NameOccurrence = NameOccurrence { locatedName :: Located (Maybe Name) , description :: T.Text @@ -125,7 +125,7 @@ namesFromRenamedSource = tyFamilyEqNames `extQ` tyFamilyDefEqNames `extQ` dataFamInstDeclNames `extQ` -#endif +#endif conDeclNames `extQ` importNames `extQ` hsTyVarBndrNames `extQ` @@ -159,18 +159,18 @@ fieldOccName isBinder (FieldOcc (L span _) name) = conDeclFieldNames :: ConDeclField GhcRn -> [NameOccurrence] #else conDeclFieldNames :: ConDeclField Name -> [NameOccurrence] -#endif +#endif conDeclFieldNames ConDeclField {..} = map (fieldOccName True . unLoc) cd_fld_names #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -conDeclFieldNames _ = [] -#endif +conDeclFieldNames _ = [] +#endif #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) hsRecFieldExprNames :: HsRecField' (FieldOcc GhcRn) (LHsExpr GhcRn) -> [NameOccurrence] #else hsRecFieldExprNames :: HsRecField' (FieldOcc Name) (LHsExpr Name) -> [NameOccurrence] -#endif +#endif hsRecFieldExprNames HsRecField {..} = [fieldOccName False $ unLoc hsRecFieldLbl] #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) @@ -182,19 +182,19 @@ hsRecAmbFieldExprNames HsRecField {..} = let (L span recField) = hsRecFieldLbl mbName = case recField of - Ambiguous _ _ -> Nothing + Ambiguous _ _ -> Nothing #if MIN_VERSION_GLASGOW_HASKELL(8,6,3,0) Unambiguous name _ -> Just name _ -> Nothing #else Unambiguous _ name -> Just name -#endif +#endif in [ NameOccurrence { locatedName = L span mbName , description = "AmbiguousFieldOcc" , isBinder = False } - ] + ] #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) hsRecFieldPatNames :: HsRecField' (FieldOcc GhcRn) (LPat GhcRn) -> [NameOccurrence] @@ -261,7 +261,7 @@ hsExprNames (L _span (HsRecFld (Ambiguous (L span _) _name))) = , isBinder = False } ] -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) hsExprNames (L span (HsRnBracketOut _ (VarBr _ quote name) _)) = #else hsExprNames (L span (HsRnBracketOut (VarBr quote name) _)) = @@ -292,20 +292,20 @@ hsExprNames _ = [] #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) matchGroupNames :: MatchGroup GhcRn (LHsExpr GhcRn) -> [NameOccurrence] #else -matchGroupNames :: MatchGroup Name (LHsExpr Name) -> [NameOccurrence] +matchGroupNames :: MatchGroup Name (LHsExpr Name) -> [NameOccurrence] #endif matchGroupNames = -#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) mapMaybe (fmap toNameOcc . matchContextName . m_ctxt . unLoc) . #else mapMaybe (fmap toNameOcc . matchFixityName . m_fixity . unLoc) . #endif unLoc . mg_alts where -#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) --matchContextName :: HsMatchContext Name -> Maybe (Located Name) matchContextName (FunRhs name _ _bool) = Just name - matchContextName _ = Nothing + matchContextName _ = Nothing #else --matchFixityName :: MatchFixity Name -> Maybe (Located Name) matchFixityName NonFunBindMatch = Nothing @@ -314,7 +314,7 @@ matchGroupNames = --toNameOcc :: Located Name -> NameOccurrence toNameOcc n = NameOccurrence - {locatedName = Just <$> n, description = "Match", isBinder = True} + {locatedName = Just <$> n, description = "Match", isBinder = True} #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) bindNames :: LHsBindLR GhcRn GhcRn -> [NameOccurrence] @@ -384,7 +384,7 @@ patNames (L _span (ConPatIn name _)) = , isBinder = False } ] -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) patNames (L _span (AsPat _ name _)) = #else patNames (L _span (AsPat name _)) = @@ -395,7 +395,7 @@ patNames (L _span (AsPat name _)) = , isBinder = True } ] -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) patNames (L _span (NPlusKPat _ name _ _ _ _)) = #else patNames (L _span (NPlusKPat name _ _ _ _ _)) = @@ -428,9 +428,9 @@ sigNames (L _span (TypeSig names _)) = , isBinder = False }) names - + #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -sigNames (L _span (PatSynSig _ names _)) = map (\name -> NameOccurrence (Just <$> name) "PatSynSig" False) names +sigNames (L _span (PatSynSig _ names _)) = map (\name -> NameOccurrence (Just <$> name) "PatSynSig" False) names #elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) sigNames (L _span (PatSynSig names _)) = map (\name -> NameOccurrence (Just <$> name) "PatSynSig" False) names #else @@ -490,7 +490,7 @@ sigNames (L _span (SpecSig name _ _)) = , isBinder = False } ] -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) sigNames (L _span (MinimalSig _ _ (L _ boolFormula))) = #else sigNames (L _span (MinimalSig _ (L _ boolFormula))) = @@ -516,9 +516,9 @@ sigNames (L _ _) = [] hsTypeNames :: LHsType GhcRn -> [NameOccurrence] #else hsTypeNames :: LHsType Name -> [NameOccurrence] -#endif +#endif #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -hsTypeNames (L _span (HsTyVar _ _promoted name)) = +hsTypeNames (L _span (HsTyVar _ _promoted name)) = #elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) hsTypeNames (L _span (HsTyVar _promoted name)) = #else @@ -530,7 +530,7 @@ hsTypeNames (L _span (HsTyVar name)) = , isBinder = False } ] -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) hsTypeNames (L span (HsTyLit _ lit)) = #else hsTypeNames (L span (HsTyLit lit)) = @@ -545,7 +545,7 @@ hsTypeNames (L span (HsTyLit lit)) = , kind = kind } ] -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) hsTypeNames (L _span (HsOpTy _ _ name _)) = #else hsTypeNames (L _span (HsOpTy _ name _)) = @@ -556,7 +556,7 @@ hsTypeNames (L _span (HsOpTy _ name _)) = , isBinder = False } ] -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) hsTypeNames (L span (HsTupleTy _ tupleSort types)) #else hsTypeNames (L span (HsTupleTy tupleSort types)) @@ -575,7 +575,7 @@ hsTypeNames (L span (HsTupleTy tupleSort types)) } ] | otherwise = [] ---https://ghc.haskell.org/trac/ghc/ticket/13737 +--https://ghc.haskell.org/trac/ghc/ticket/13737 --hsTypeNames (L span (HsExplicitListTy _kind types)) = ... --hsTypeNames (L span (HsExplicitTupleTy _kind types)) = ... hsTypeNames _ = [] @@ -586,18 +586,18 @@ hsTyVarBndrNames :: HsTyVarBndr GhcRn -> [NameOccurrence] #else hsTyVarBndrNames :: HsTyVarBndr Name -> [NameOccurrence] #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) hsTyVarBndrNames (UserTyVar _ n) = #else hsTyVarBndrNames (UserTyVar n) = -#endif +#endif [ NameOccurrence { locatedName = Just <$> n , description = "UserTyVar" , isBinder = True } ] -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) hsTyVarBndrNames (KindedTyVar _ n _) = #else hsTyVarBndrNames (KindedTyVar n _) = @@ -610,14 +610,14 @@ hsTyVarBndrNames (KindedTyVar n _) = ] #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) hsTyVarBndrNames _ = [] -#endif - +#endif + #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) tyClDeclNames :: LTyClDecl GhcRn -> [NameOccurrence] #else tyClDeclNames :: LTyClDecl Name -> [NameOccurrence] -#endif +#endif tyClDeclNames (L _span DataDecl {..}) = [ NameOccurrence { locatedName = Just <$> tcdLName @@ -692,7 +692,7 @@ dataEqNames FamEqn {feqn_tycon = tyCon} = dataEqNames _ = [] #endif -#else +#else tyFamilyEqNames :: TyFamEqn Name (HsTyPats Name) -> [NameOccurrence] tyFamilyEqNames TyFamEqn {tfe_tycon = tyCon} = [ NameOccurrence @@ -744,7 +744,7 @@ conDeclNames con = , isBinder = True } ] -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) _ -> [] #endif @@ -752,7 +752,7 @@ conDeclNames con = foreignDeclNames :: ForeignDecl GhcRn -> [NameOccurrence] #else foreignDeclNames :: ForeignDecl Name -> [NameOccurrence] -#endif +#endif foreignDeclNames decl = [ NameOccurrence { locatedName = Just <$> fd_name decl @@ -766,7 +766,7 @@ roleAnnotationNames :: RoleAnnotDecl GhcRn -> [NameOccurrence] #else roleAnnotationNames :: RoleAnnotDecl Name -> [NameOccurrence] #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) roleAnnotationNames (RoleAnnotDecl _ n _) = #else roleAnnotationNames (RoleAnnotDecl n _) = @@ -796,4 +796,4 @@ injectivityAnnotationNames (InjectivityAnn lhsName rhsNames) = , description = "InjectivityAnn" , isBinder = False } - + diff --git a/src/HaskellCodeExplorer/AST/TypecheckedSource.hs b/src/HaskellCodeExplorer/AST/TypecheckedSource.hs index 50ab061..4321469 100644 --- a/src/HaskellCodeExplorer/AST/TypecheckedSource.hs +++ b/src/HaskellCodeExplorer/AST/TypecheckedSource.hs @@ -92,7 +92,7 @@ import HsSyn , ListPatTc (..) , OverLitTc (..) , MatchGroupTc (..) - , NHsValBindsLR (..) + , NHsValBindsLR (..) #endif ) import HscTypes (TypeEnv, lookupTypeEnv) @@ -119,7 +119,7 @@ import Type #if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) , nonDetCmpTypes #else - , cmpTypes + , cmpTypes #endif , eqTypes , eqType @@ -202,10 +202,10 @@ exprSort (ExplicitTuple _ args _) exprSort (ExplicitTuple args _) #endif | null args = Simple - | otherwise = Composite -exprSort (ExplicitList _ _ args) + | otherwise = Composite +exprSort (ExplicitList _ _ args) | null args = Simple - | otherwise = Composite + | otherwise = Composite exprSort _ = Composite @@ -220,7 +220,7 @@ patSort (ListPat pats _ _) #endif | null pats = Simple | otherwise = Composite -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) patSort (TuplePat _ pats _) #else patSort (TuplePat pats _ _) @@ -247,7 +247,7 @@ splitFunTySafe srcSpan astNode typ = modify' (\st -> st {astStateTypeErrors = typeError : astStateTypeErrors st}) return Nothing - + -- | Splits a type of a function of two arguments, adds -- 'TypeError' to 'ASTState' in case of a failure. splitFunTy2Safe :: @@ -261,7 +261,7 @@ splitFunTy2Safe srcSpan astNode typ = do Just (arg2, ty2) -> return $ Just (arg1, arg2, ty2) Nothing -> return Nothing Nothing -> return Nothing - + -- | Returns result type of a function, adds 'TypeError' to -- 'ASTState' in case of a failure. funResultTySafe :: SrcSpan -> T.Text -> Type -> State ASTState (Maybe Type) @@ -313,7 +313,7 @@ addExprInfo span mbType descr sort = do , isBinder = False , instanceResolution = Nothing , idOccType = - case mbHsWrapper of + case mbHsWrapper of Just w -> mkType flags <$> (applyWrapper w <$> mbType) Nothing -> mkType flags <$> mbType , typeArguments = Nothing @@ -380,7 +380,7 @@ instance Ord InstTypes where compare (InstTypes ts1) (InstTypes ts2) = cmpTypes ts1 ts2 #endif --- | Creates an instance resolution tree +-- | Creates an instance resolution tree traceInstanceResolution :: Environment -> Class @@ -398,7 +398,7 @@ traceInstanceResolution environment c ts = go c ts S.empty (take clsTyVarCount types) of Right (inst, instTypes) -> -- A successful match is a ClsInst, together with the types at which - -- the dfun_id in the ClsInst should be instantiated + -- the dfun_id in the ClsInst should be instantiated let instWithTypes = (is_dfun_name inst, InstTypes instTypes) in if not $ S.member instWithTypes seenInstances then let (typeVars, predTypes, _class, _types) = @@ -481,8 +481,8 @@ mkIdentifierInfo environment identifier mbNameFromRenamedSource = [ HCE.packageIdToText currentPackageId , HCE.getHaskellModuleName moduleName , case nameSpace of - HCE.VarName -> T.pack $ show HCE.Val - HCE.DataName -> T.pack $ show HCE.Val + HCE.VarName -> T.pack $ show HCE.Val + HCE.DataName -> T.pack $ show HCE.Val _ -> T.pack $ show HCE.Typ , nameToText name ] @@ -493,7 +493,7 @@ mkIdentifierInfo environment identifier mbNameFromRenamedSource = "|" [ HCE.packageIdToText packageId , HCE.getHaskellModuleName moduleName - , T.pack $ show entity + , T.pack $ show entity , n ] _ -> Nothing @@ -546,7 +546,7 @@ restoreHsWrapper action = do wrapper <- astStateHsWrapper <$> get res <- action modify' $ \s -> s {astStateHsWrapper = wrapper} - return res + return res tidyIdentifier :: Id -> State ASTState (Id, Maybe (Type, [Type])) tidyIdentifier identifier = do @@ -575,7 +575,7 @@ tidyType typ = do modify' (\s -> s {astStateTidyEnv = tidyEnv'}) return typ' -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldTypecheckedSource :: LHsBinds GhcTc -> State ASTState () #else foldTypecheckedSource :: LHsBinds Id -> State ASTState () @@ -633,7 +633,7 @@ foldLHsExpr (L span (HsOverLit OverLit {ol_type})) = then Simple else Composite) return $ Just typ -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L span (HsLit _ lit)) = #else foldLHsExpr (L span (HsLit lit)) = @@ -672,14 +672,14 @@ foldLHsExpr (L span expr@(HsLamCase _typ MG {..})) = addExprInfo span (Just typ) "HsLamCase" (exprSort expr) mapM_ foldLMatch $ unLoc mg_alts return $ Just typ -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L span expr@(HsApp _ fun arg)) = do #else foldLHsExpr (L span expr@(HsApp fun arg)) = do #endif funTy <- foldLHsExpr fun _argTy <- foldLHsExpr arg - typ <- maybe (return Nothing) (funResultTySafe span "HsApp") funTy + typ <- maybe (return Nothing) (funResultTySafe span "HsApp") funTy addExprInfo span typ "HsApp" (exprSort expr) return typ #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) @@ -691,18 +691,18 @@ foldLHsExpr (L span ex@(HsAppTypeOut expr _)) = do typ <- foldLHsExpr expr addExprInfo span typ "HsAppType" (exprSort ex) return typ -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L span expr@(OpApp _ left op right)) = do #else foldLHsExpr (L span expr@(OpApp left op _fixity right)) = do #endif opTyp <- foldLHsExpr op - typ <- maybe (return Nothing) (funResultTy2Safe span "HsApp") opTyp + typ <- maybe (return Nothing) (funResultTy2Safe span "HsApp") opTyp _ <- foldLHsExpr left _ <- foldLHsExpr right addExprInfo span typ "OpApp" (exprSort expr) return typ -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L span e@(NegApp _ expr _syntaxExp)) = do #else foldLHsExpr (L span e@(NegApp expr _syntaxExp)) = do @@ -710,7 +710,7 @@ foldLHsExpr (L span e@(NegApp expr _syntaxExp)) = do typ <- foldLHsExpr expr addExprInfo span typ "NegApp" (exprSort e) return typ -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L _span (HsPar _ expr)) = foldLHsExpr expr #else foldLHsExpr (L _span (HsPar expr)) = foldLHsExpr expr @@ -722,7 +722,7 @@ foldLHsExpr (L span expr@(SectionL operand operator)) = do #endif opType <- foldLHsExpr operator _ <- foldLHsExpr operand - mbTypes <- maybe (return Nothing) (splitFunTy2Safe span "SectionL") opType + mbTypes <- maybe (return Nothing) (splitFunTy2Safe span "SectionL") opType let typ = case mbTypes of Just (_arg1, arg2, res) -> Just $ mkFunTy arg2 res @@ -736,7 +736,7 @@ foldLHsExpr (L span e@(SectionR operator operand)) = do #endif opType <- foldLHsExpr operator _ <- foldLHsExpr operand - mbTypes <- maybe (return Nothing) (splitFunTy2Safe span "SectionR") opType + mbTypes <- maybe (return Nothing) (splitFunTy2Safe span "SectionR") opType let typ = case mbTypes of Just (arg1, _arg2, res) -> Just $ mkFunTy arg1 res @@ -769,7 +769,7 @@ foldLHsExpr (L _span (ExplicitSum _ _ expr _types)) = do #endif -- TODO _ <- foldLHsExpr expr - return Nothing + return Nothing #endif #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L span e@(HsCase _ expr (MG (MatchGroupTc {..}) mg_alts _))) = @@ -798,7 +798,7 @@ foldLHsExpr (L span e@(HsMultiIf typ grhss)) = addExprInfo span (Just typ') "HsMultiIf" (exprSort e) mapM_ foldLGRHS grhss return $ Just typ' -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L span e@(HsLet _ (L _ binds) expr)) = do #else foldLHsExpr (L span e@(HsLet (L _ binds) expr)) = do @@ -807,7 +807,7 @@ foldLHsExpr (L span e@(HsLet (L _ binds) expr)) = do typ <- foldLHsExpr expr addExprInfo span typ "HsLet" (exprSort e) return typ -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L span expr@(HsDo typ _context (L _ stmts))) = #else foldLHsExpr (L span expr@(HsDo _context (L _ stmts) typ)) = @@ -843,12 +843,12 @@ foldLHsExpr (L span e@(RecordCon (L _ _) _conLike conExpr binds)) = do addExprInfo span mbConType "RecordCon" (exprSort e) _ <- foldHsRecFields binds return mbConType -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L span e@(RecordUpd (RecordUpdTc cons _inputTys outTys _wrapper) expr binds)) = #else foldLHsExpr (L span e@(RecordUpd expr binds cons _inputTys outTys _wrapper)) = #endif - restoreTidyEnv $ do + restoreTidyEnv $ do -- cons is a non-empty list of DataCons that have all the upd'd fields let typ = conLikeResTy (head cons) outTys typ' <- tidyType typ @@ -879,7 +879,7 @@ foldLHsExpr (L span e@(ArithSeq postTcExpr _mbSyntaxExpr seqInfo)) = do addExprInfo span typ "ArithSeq" (exprSort e) return typ #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -#else +#else foldLHsExpr (L span e@(PArrSeq postTcExpr _seqInfo)) = do typ <- foldLHsExpr (L (UnhelpfulSpan $ mkFastString "PArrSeq") postTcExpr) addExprInfo span typ "ArithSeq" (exprSort e) @@ -914,7 +914,7 @@ foldLHsExpr (L span expr@(HsProc pat cmd)) = do _ <- foldLHsCmdTop cmd addExprInfo span Nothing "HsProc" (exprSort expr) return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) foldLHsExpr (L span e@(HsStatic _ expr)) = do #else foldLHsExpr (L span e@(HsStatic expr)) = do @@ -932,7 +932,7 @@ foldLHsExpr (L span e@(HsTick _ expr)) = do typ <- foldLHsExpr expr addExprInfo span typ "HsTick" (exprSort e) return typ -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L span e@(HsBinTick _ _ _ expr)) = do #else foldLHsExpr (L span e@(HsBinTick _ _ expr)) = do @@ -940,7 +940,7 @@ foldLHsExpr (L span e@(HsBinTick _ _ expr)) = do typ <- foldLHsExpr expr addExprInfo span typ "HsBinTick" (exprSort e) return typ -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsExpr (L span e@(HsTickPragma _ _ _ _ expr)) = do #else foldLHsExpr (L span e@(HsTickPragma _ _ _ expr)) = do @@ -962,7 +962,7 @@ foldLHsExpr (L span (HsWrap wrapper expr)) = Simple -> modify' (\s -> s {astStateHsWrapper = Just wrapper}) Composite -> return () -- Not sure if it is possible typ <- foldLHsExpr (L span expr) - return $ applyWrapper wrapper <$> typ + return $ applyWrapper wrapper <$> typ #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldHsRecFields :: HsRecFields GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type) @@ -977,12 +977,12 @@ foldHsRecFields HsRecFields {..} = do mapM_ foldLHsRecField $ userWritten rec_flds return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldLHsRecField :: LHsRecField GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type) #else foldLHsRecField :: LHsRecField Id (LHsExpr Id) -> State ASTState (Maybe Type) #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsRecField (L _span (HsRecField (L _idSpan (XFieldOcc _)) _ _)) = return Nothing foldLHsRecField (L span (HsRecField (L idSpan (FieldOcc identifier _)) arg pun)) = #else @@ -995,7 +995,7 @@ foldLHsRecField (L span (HsRecField (L idSpan (FieldOcc _ identifier)) arg pun)) unless pun $ void (foldLHsExpr arg) return . Just . varType $ identifier' -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldLHsRecUpdField :: LHsRecUpdField GhcTc -> State ASTState (Maybe Type) #else foldLHsRecUpdField :: LHsRecUpdField Id -> State ASTState (Maybe Type) @@ -1023,7 +1023,7 @@ data TupArg | TupArgMissing deriving (Show, Eq) -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldLHsTupArg :: LHsTupArg GhcTc -> State ASTState (Maybe Type, TupArg) #else foldLHsTupArg :: LHsTupArg Id -> State ASTState (Maybe Type, TupArg) @@ -1056,10 +1056,10 @@ foldLMatch (L _span Match {..}) = do _ <- foldGRHSs m_grhss return Nothing #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -foldLMatch (L _span _) = return Nothing +foldLMatch (L _span _) = return Nothing #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldLMatchCmd :: LMatch GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type) #else foldLMatchCmd :: LMatch Id (LHsCmd Id) -> State ASTState (Maybe Type) @@ -1069,10 +1069,10 @@ foldLMatchCmd (L _span Match {..}) = do _ <- foldGRHSsCmd m_grhss return Nothing #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -foldLMatchCmd (L _span _) = return Nothing +foldLMatchCmd (L _span _) = return Nothing #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldGRHSsCmd :: GRHSs GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type) #else foldGRHSsCmd :: GRHSs Id (LHsCmd Id) -> State ASTState (Maybe Type) @@ -1082,8 +1082,8 @@ foldGRHSsCmd GRHSs {..} = do _ <- foldHsLocalBindsLR (unLoc grhssLocalBinds) return Nothing #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -foldGRHSsCmd (_) = return Nothing -#endif +foldGRHSsCmd (_) = return Nothing +#endif #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldGRHSs :: GRHSs GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type) @@ -1095,7 +1095,7 @@ foldGRHSs GRHSs {..} = do _ <- foldHsLocalBindsLR (unLoc grhssLocalBinds) return Nothing #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -foldGRHSs (_) = return Nothing +foldGRHSs (_) = return Nothing #endif #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) @@ -1120,7 +1120,7 @@ foldLStmtLR (L _span (BindStmt pat body _ _ _)) = do _ <- foldLPat pat _ <- foldLHsExpr body return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLStmtLR (L span (BodyStmt _ body _ _)) = do #else foldLStmtLR (L span (BodyStmt body _ _ _)) = do @@ -1128,14 +1128,14 @@ foldLStmtLR (L span (BodyStmt body _ _ _)) = do mbTyp <- foldLHsExpr body addExprInfo span mbTyp "BodyStmt" Composite return mbTyp -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLStmtLR (L _ (LetStmt _ (L _ binds))) = do #else foldLStmtLR (L _ (LetStmt (L _ binds))) = do #endif _ <- foldHsLocalBindsLR binds return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLStmtLR (L _ (ParStmt _ blocks _ _)) = do #else foldLStmtLR (L _ (ParStmt blocks _ _ _)) = do @@ -1143,7 +1143,7 @@ foldLStmtLR (L _ (ParStmt blocks _ _ _)) = do mapM_ foldParStmtBlock blocks return Nothing foldLStmtLR (L _ TransStmt {..}) = do - mapM_ foldLStmtLR trS_stmts + mapM_ foldLStmtLR trS_stmts _ <- maybe (return Nothing) foldLHsExpr trS_by _ <- foldLHsExpr trS_using return Nothing @@ -1162,7 +1162,7 @@ foldLStmtLR (L span (ApplicativeStmt args _ typ)) = return Nothing #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -foldApplicativeArg :: ApplicativeArg GhcTc -> State ASTState (Maybe Type) +foldApplicativeArg :: ApplicativeArg GhcTc -> State ASTState (Maybe Type) #elif MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldApplicativeArg :: ApplicativeArg GhcTc GhcTc -> State ASTState (Maybe Type) #else @@ -1183,14 +1183,14 @@ foldApplicativeArg appArg = _ <- foldLPat pat _ <- foldLHsExpr expr return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) ApplicativeArgMany _ exprStmts _ pat -> do #else ApplicativeArgMany exprStmts _ pat -> do #endif mapM_ foldLStmtLR exprStmts _ <- foldLPat pat - return Nothing + return Nothing #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldLStmtLRCmd :: LStmtLR GhcTc GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type) @@ -1214,7 +1214,7 @@ foldLStmtLRCmd (L _ (BindStmt pat body _ _ _)) = do _ <- foldLPat pat _ <- foldLHsCmd body return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLStmtLRCmd (L span (BodyStmt _ body _ _)) = do #else foldLStmtLRCmd (L span (BodyStmt body _ _ _)) = do @@ -1222,14 +1222,14 @@ foldLStmtLRCmd (L span (BodyStmt body _ _ _)) = do typ <- foldLHsCmd body addExprInfo span typ "BodyStmt Cmd" Composite return typ -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLStmtLRCmd (L _ (LetStmt _ (L _ binds))) = do #else foldLStmtLRCmd (L _ (LetStmt (L _ binds))) = do #endif _ <- foldHsLocalBindsLR binds return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLStmtLRCmd (L _ (ParStmt _ blocks _ _)) = do #else foldLStmtLRCmd (L _ (ParStmt blocks _ _ _)) = do @@ -1253,14 +1253,14 @@ foldLStmtLRCmd (L span (ApplicativeStmt args _ typ)) = typ' <- tidyType typ mapM_ (foldApplicativeArg . snd) args addExprInfo span (Just typ') "ApplicativeStmt Cmd" Composite - return Nothing + return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldLGRHS :: LGRHS GhcTc (LHsExpr GhcTc) -> State ASTState (Maybe Type) #else foldLGRHS :: LGRHS Id (LHsExpr Id) -> State ASTState (Maybe Type) #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLGRHS (L _span (XGRHS _)) = return Nothing foldLGRHS (L _span (GRHS _ guards body)) = do #else @@ -1270,12 +1270,12 @@ foldLGRHS (L _span (GRHS guards body)) = do mapM_ foldLStmtLR guards return typ -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldLGRHSCmd :: LGRHS GhcTc (LHsCmd GhcTc) -> State ASTState (Maybe Type) #else foldLGRHSCmd :: LGRHS Id (LHsCmd Id) -> State ASTState (Maybe Type) #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLGRHSCmd (L _span (XGRHS _)) = return Nothing foldLGRHSCmd (L _span (GRHS _ guards body)) = do #else @@ -1283,14 +1283,14 @@ foldLGRHSCmd (L _span (GRHS guards body)) = do #endif typ <- foldLHsCmd body mapM_ foldLStmtLR guards - return typ + return typ #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldParStmtBlock :: ParStmtBlock GhcTc GhcTc -> State ASTState (Maybe Type) #else foldParStmtBlock :: ParStmtBlock Id Id -> State ASTState (Maybe Type) #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldParStmtBlock (XParStmtBlock _) = return Nothing foldParStmtBlock (ParStmtBlock _ exprStmts _ids _syntaxExpr) = do #else @@ -1299,12 +1299,12 @@ foldParStmtBlock (ParStmtBlock exprStmts _ids _syntaxExpr) = do mapM_ foldLStmtLR exprStmts return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldHsLocalBindsLR :: HsLocalBindsLR GhcTc GhcTc -> State ASTState (Maybe Type) #else foldHsLocalBindsLR :: HsLocalBindsLR Id Id -> State ASTState (Maybe Type) #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldHsLocalBindsLR (XHsLocalBindsLR _) = return Nothing foldHsLocalBindsLR (HsValBinds _ binds) = do #else @@ -1315,26 +1315,26 @@ foldHsLocalBindsLR (HsValBinds binds) = do foldHsLocalBindsLR HsIPBinds {} = return Nothing foldHsLocalBindsLR EmptyLocalBinds {} = return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldHsValBindsLR :: HsValBindsLR GhcTc GhcTc -> State ASTState (Maybe Type) #else foldHsValBindsLR :: HsValBindsLR Id Id -> State ASTState (Maybe Type) #endif #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -foldHsValBindsLR (ValBinds _ _binds _) = do +foldHsValBindsLR (ValBinds _ _binds _) = do return Nothing foldHsValBindsLR (XValBindsLR (NValBinds binds _)) = do _ <- mapM_ (foldLHsBindsLR . snd) binds - return Nothing -#else + return Nothing +#else foldHsValBindsLR (ValBindsIn _ _) = return Nothing foldHsValBindsLR (ValBindsOut binds _) = do mapM_ (foldLHsBindsLR . snd) binds return Nothing -#endif +#endif -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldLHsBindsLR :: LHsBinds GhcTc -> State ASTState () #else foldLHsBindsLR :: LHsBinds Id -> State ASTState () @@ -1412,11 +1412,11 @@ foldLHsBindLR (L _ (PatSynBind PSB {..})) _ = mapM_ (\(RecordPatSynField selId patVar) -> addId selId >> addId patVar) - recs + recs #endif return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldLPat :: LPat GhcTc -> State ASTState (Maybe Type) #else foldLPat :: LPat Id -> State ASTState (Maybe Type) @@ -1436,7 +1436,7 @@ foldLPat (L span pat@(WildPat typ)) = do typ' <- tidyType typ addExprInfo span (Just typ') "WildPat" (patSort pat) return $ Just typ' -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLPat (L span p@(LazyPat _ pat)) = do #else foldLPat (L span p@(LazyPat pat)) = do @@ -1454,12 +1454,12 @@ foldLPat (L span p@(AsPat (L idSpan identifier) pat)) = do addExprInfo span (Just . varType $ identifier') "AsPat" (patSort p) _ <- foldLPat pat return . Just . varType $ identifier' -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLPat (L _span (ParPat _ pat)) = foldLPat pat #else foldLPat (L _span (ParPat pat)) = foldLPat pat #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLPat (L span p@(BangPat _ pat)) = do #else foldLPat (L span p@(BangPat pat)) = do @@ -1487,14 +1487,14 @@ foldLPat (L span pat@(TuplePat pats boxity types)) = do mapM_ foldLPat pats return $ Just typ' #if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLPat (L _span (SumPat _ pat _ _)) = do #else foldLPat (L _span (SumPat pat _ _ _types)) = do #endif -- TODO _ <- foldLPat pat - return Nothing + return Nothing #endif #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) #else @@ -1503,10 +1503,10 @@ foldLPat (L span pat@(PArrPat pats typ)) = do addExprInfo span (Just typ') "PArrPat" (patSort pat) mapM_ foldLPat pats return $ Just typ' -#endif +#endif foldLPat (L _span (ConPatIn _ _)) = return Nothing foldLPat (L span pat@ConPatOut {..}) = do - let (L idSpan conLike) = pat_con + let (L idSpan conLike) = pat_con conId = case conLike of RealDataCon dc -> dataConWorkId dc @@ -1518,7 +1518,7 @@ foldLPat (L span pat@ConPatOut {..}) = do addExprInfo span (Just typ') "ConPatOut" (patSort pat) _ <- foldHsConPatDetails pat_args return . Just . varType $ identifier' -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLPat (L span p@(ViewPat typ expr pat)) = do #else foldLPat (L span p@(ViewPat expr pat typ)) = do @@ -1529,7 +1529,7 @@ foldLPat (L span p@(ViewPat expr pat typ)) = do _ <- foldLHsExpr expr return $ Just typ' foldLPat (L _ SplicePat {}) = return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLPat (L span (LitPat _ hsLit)) = do #else foldLPat (L span (LitPat hsLit)) = do @@ -1543,7 +1543,7 @@ foldLPat (L span (LitPat hsLit)) = do then Simple else Composite) return $ Just typ' -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLPat (L span pat@(NPat _ (L _spanLit (OverLit (OverLitTc {..}) _ _)) _ _)) = do #else foldLPat (L span pat@(NPat (L _spanLit OverLit {ol_type}) _ _ _)) = do @@ -1573,15 +1573,15 @@ foldLPat (L span pat@(NPlusKPat (L idSpan identifier) (L litSpan OverLit {ol_typ foldLPat (L _span (SigPat typ pat)) = do typ' <- tidyType typ _ <- foldLPat pat - return $ Just typ' + return $ Just typ' #else -foldLPat (L _span (SigPatIn _ _)) = return Nothing +foldLPat (L _span (SigPatIn _ _)) = return Nothing foldLPat (L _span (SigPatOut pat typ)) = do typ' <- tidyType typ _ <- foldLPat pat return $ Just typ' #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLPat (L span p@(CoPat _ _ pat typ)) = do #else foldLPat (L span p@(CoPat _ pat typ)) = do @@ -1589,9 +1589,9 @@ foldLPat (L span p@(CoPat _ pat typ)) = do typ' <- tidyType typ addExprInfo span (Just typ') "CoPat" (patSort p) _ <- foldLPat (L span pat) - return Nothing + return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldHsConPatDetails :: HsConPatDetails GhcTc -> State ASTState (Maybe Type) @@ -1599,7 +1599,7 @@ foldHsConPatDetails foldHsConPatDetails :: HsConPatDetails Id -> State ASTState (Maybe Type) -#endif +#endif foldHsConPatDetails (PrefixCon args) = do mapM_ foldLPat args return Nothing @@ -1639,15 +1639,15 @@ foldLHsRecFieldPat (L _ (HsRecField (L idSpan (FieldOcc _ identifier)) arg pun)) unless pun $ void $ foldLPat arg return . Just . varType $ identifier' #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) -foldLHsRecFieldPat (L _ (HsRecField (L _idSpan (XFieldOcc _)) _arg _pun)) = return Nothing -#endif +foldLHsRecFieldPat (L _ (HsRecField (L _idSpan (XFieldOcc _)) _arg _pun)) = return Nothing +#endif #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foldLHsCmdTop :: LHsCmdTop GhcTc -> State ASTState (Maybe Type) #else foldLHsCmdTop :: LHsCmdTop Id -> State ASTState (Maybe Type) #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsCmdTop (L _span (XCmdTop _)) = return Nothing foldLHsCmdTop (L span (HsCmdTop _ cmd)) = do #else @@ -1662,7 +1662,7 @@ foldLHsCmd :: LHsCmd GhcTc -> State ASTState (Maybe Type) #else foldLHsCmd :: LHsCmd Id -> State ASTState (Maybe Type) #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsCmd (L _ (XCmd _)) = return Nothing foldLHsCmd (L _ (HsCmdLam _ (XMatchGroup _))) = return Nothing foldLHsCmd (L _ (HsCmdCase _ _ (XMatchGroup _))) = return Nothing @@ -1674,7 +1674,7 @@ foldLHsCmd (L _ (HsCmdArrApp expr1 expr2 _ _ _)) = do _ <- foldLHsExpr expr2 return Nothing #if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsCmd (L _ (HsCmdArrForm _ expr _ _ topCmds)) = do #else foldLHsCmd (L _ (HsCmdArrForm expr _ _ topCmds)) = do @@ -1700,7 +1700,7 @@ foldLHsCmd (L _ (HsCmdLam MG {..})) = do #endif mapM_ foldLMatchCmd $ unLoc mg_alts return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsCmd (L _ (HsCmdCase _ expr MG {..})) = do #else foldLHsCmd (L _ (HsCmdCase expr MG {..})) = do @@ -1715,7 +1715,7 @@ foldLHsCmd (L _ (HsCmdPar cmd)) = do #endif _ <- foldLHsCmd cmd return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsCmd (L _ (HsCmdIf _ _ expr cmd1 cmd2)) = do #else foldLHsCmd (L _ (HsCmdIf _ expr cmd1 cmd2)) = do @@ -1724,7 +1724,7 @@ foldLHsCmd (L _ (HsCmdIf _ expr cmd1 cmd2)) = do _ <- foldLHsCmd cmd2 _ <- foldLHsExpr expr return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsCmd (L _ (HsCmdLet _ (L _ binds) cmd)) = do #else foldLHsCmd (L _ (HsCmdLet (L _ binds) cmd)) = do @@ -1732,17 +1732,17 @@ foldLHsCmd (L _ (HsCmdLet (L _ binds) cmd)) = do _ <- foldLHsCmd cmd _ <- foldHsLocalBindsLR binds return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsCmd (L _ (HsCmdDo _ stmts)) = do #else foldLHsCmd (L _ (HsCmdDo stmts _)) = do #endif mapM_ foldLStmtLRCmd $ unLoc stmts return Nothing -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) foldLHsCmd (L span (HsCmdWrap _ _ cmd)) = do #else foldLHsCmd (L span (HsCmdWrap _ cmd)) = do -#endif +#endif _ <- foldLHsCmd (L span cmd) return Nothing diff --git a/src/HaskellCodeExplorer/GhcUtils.hs b/src/HaskellCodeExplorer/GhcUtils.hs index 031f411..bb89832 100644 --- a/src/HaskellCodeExplorer/GhcUtils.hs +++ b/src/HaskellCodeExplorer/GhcUtils.hs @@ -20,7 +20,7 @@ module HaskellCodeExplorer.GhcUtils , occNameNameSpace , identifierKey , nameKey - , mbIdDetails + , mbIdDetails -- * Syntax manipulation , hsGroupVals , hsPatSynDetails @@ -32,18 +32,18 @@ module HaskellCodeExplorer.GhcUtils , isHsBoot , moduleLocationInfo , nameLocationInfo - , occNameLocationInfo - , nameDocumentation + , occNameLocationInfo + , nameDocumentation , srcSpanToLineAndColNumbers -- * Type-related functions - , tyThingToId + , tyThingToId , tidyIdentifierType , patSynId , applyWrapper - , wrapperTypes - , tyVarsOfType + , wrapperTypes + , tyVarsOfType , tyConsOfType - , updateOccNames + , updateOccNames , mkType -- * Documentation processing , collectDocs @@ -80,7 +80,7 @@ import DynFlags () import FastString (mkFastString, unpackFS) import GHC ( DynFlags -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) , HsDocString #else , HsDocString (..) @@ -91,12 +91,12 @@ import GHC , SrcSpan(..) , RealSrcSpan(..) , ClsInstDecl(..) - , TyClDecl(..) - , HsDataDefn(..) + , TyClDecl(..) + , HsDataDefn(..) , NewOrData(..) , Id - , HsGroup(..) - , HsBindLR(..) + , HsGroup(..) + , HsBindLR(..) , HsValBindsLR(..) #if MIN_VERSION_GLASGOW_HASKELL(8,4,1,0) , HsPatSynDetails @@ -104,18 +104,18 @@ import GHC , HsPatSynDetails(..) #endif , Located - , IE(..) + , IE(..) , TyThing(..) - , LHsDecl + , LHsDecl , HsDecl(..) - , DocDecl(..) + , DocDecl(..) , ConDecl(..) - , HsConDetails(..) - , ConDeclField(..) + , HsConDetails(..) + , ConDeclField(..) , DataFamInstDecl(..) - , LSig - , Sig(..) - , ForeignDecl(..) + , LSig + , Sig(..) + , ForeignDecl(..) , FixitySig(..) , tcdName , collectHsBindBinders @@ -127,12 +127,12 @@ import GHC , getConArgs , unpackHDS , NoExt(..) - , extFieldOcc + , extFieldOcc #else , getConDetails , selectorFieldOcc #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) , tyClGroupTyClDecls , LIEWrappedName , hsGroupInstDecls @@ -157,10 +157,10 @@ import GHC , isGoodSrcSpan , isLocalId , isDataFamilyDecl - , tyFamInstDeclName + , tyFamInstDeclName , idType , hsib_body -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) #else , tfe_pats #endif @@ -169,7 +169,7 @@ import GHC import qualified HaskellCodeExplorer.Types as HCE import HscTypes (TypeEnv, lookupTypeEnv) -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) import HsExtension (GhcRn,IdP) #endif import IdInfo (IdDetails(..)) @@ -232,8 +232,8 @@ import Type , mkInvForAllTys #if !MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) , mkNamedBinder -#endif - , piResultTy +#endif + , piResultTy , pprSigmaType , splitFunTy_maybe , tidyOpenType @@ -355,8 +355,8 @@ tyClDeclPrefix tyClDecl = ClassDecl {} -> "class " #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) XTyClDecl _ -> "" -#endif - +#endif + demangleOccName :: Name -> T.Text demangleOccName name | isDerivedOccName (nameOccName name) = @@ -382,7 +382,7 @@ demangleOccName name | otherwise = occName in removePrefix $ nameToText name | otherwise = nameToText name - + stringBufferToByteString :: StringBuffer -> BS.ByteString stringBufferToByteString (StringBuffer buf len cur) = BSI.fromForeignPtr buf cur len @@ -392,12 +392,12 @@ nameSort n = if isExternalName n then HCE.External else HCE.Internal - + occNameNameSpace :: OccName -> HCE.NameSpace occNameNameSpace n | isDataConNameSpace (occNameSpace n) = HCE.DataName | isTvNameSpace (occNameSpace n) = HCE.TvName - | isValNameSpace (occNameSpace n) = HCE.VarName + | isValNameSpace (occNameSpace n) = HCE.VarName | otherwise = HCE.TcClsName -- Two 'Id''s may have different types even though they have the same 'Unique'. @@ -431,7 +431,7 @@ mbIdDetails v CoVarId -> Just HCE.CoVarId #if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) JoinId _ -> Just HCE.JoinId -#endif +#endif mbIdDetails _ = Nothing -------------------------------------------------------------------------------- @@ -446,7 +446,7 @@ hsGroupVals :: HsGroup Name -> [GenLocated SrcSpan (HsBindLR Name Name)] hsGroupVals hsGroup = filter (isGoodSrcSpan . getLoc) $ case hs_valds hsGroup of -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) XValBindsLR (NValBinds binds _) -> concatMap (bagToList . snd) binds #else ValBindsOut binds _ -> concatMap (bagToList . snd) binds @@ -457,7 +457,7 @@ hsPatSynDetails :: HsPatSynDetails a -> [a] hsPatSynDetails patDetails = #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) case patDetails of - InfixCon name1 name2 -> [name1, name2] + InfixCon name1 name2 -> [name1, name2] PrefixCon fields -> fields RecCon fields -> concatMap (\field -> [recordPatSynSelectorId field, recordPatSynPatVar field]) @@ -494,7 +494,7 @@ ieLocNames :: IE Name -> [Located Name] ieLocNames (XIE _) = [] ieLocNames (IEVar _ n) = #else -ieLocNames (IEVar n) = +ieLocNames (IEVar n) = #endif [unwrapName n] #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) @@ -533,7 +533,7 @@ lookupIdInTypeEnv typeEnv name = do | isExternalName name = lookupTypeEnv typeEnv name | otherwise = Nothing case mbTyThing of - Just tyThing -> tyThingToId tyThing + Just tyThing -> tyThingToId tyThing _ -> Nothing lookupNameModuleAndPackage :: @@ -568,7 +568,7 @@ lookupNameModuleAndPackage flags currentPackageId name = -------------------------------------------------------------------------------- isHsBoot :: HCE.HaskellModulePath -> Bool -isHsBoot = T.isSuffixOf "-boot" . HCE.getHaskellModulePath +isHsBoot = T.isSuffixOf "-boot" . HCE.getHaskellModulePath moduleLocationInfo :: DynFlags @@ -619,7 +619,7 @@ moduleLocationInfo flags moduleNameMap currentPackageId compId moduleName = else HCE.ComponentId "lib") Nothing -> currentPackageLocation _ -> currentPackageLocation - + isDefinedInCurrentModule :: HCE.SourceCodeTransformation -> HCE.HaskellFilePath -> Bool isDefinedInCurrentModule transformation file = @@ -628,7 +628,7 @@ isDefinedInCurrentModule transformation file = HCE.getHaskellModulePath $ HCE.filePath (transformation :: HCE.SourceCodeTransformation) in HCE.getHaskellFilePath file == modPath || (file `elem` includedFiles) - + nameLocationInfo :: DynFlags -> HCE.PackageId @@ -660,7 +660,7 @@ nameLocationInfo flags currentPackageId compId transformation fileMap defSiteMap eitherEnd = HCE.fromOriginalLineNumber transformation - (filePath, srcSpanEndLine srcSpan) + (filePath, srcSpanEndLine srcSpan) in case (,) eitherStart eitherEnd of (Right startLine,Right endLine) -> let modulePath = HCE.filePath (transformation :: HCE.SourceCodeTransformation) @@ -739,7 +739,7 @@ mkLocatableEntity name mbInstanceHead case occNameNameSpace . nameOccName $ name of HCE.VarName -> HCE.Val HCE.DataName -> HCE.Val - _ -> HCE.Typ + _ -> HCE.Typ occNameLocationInfo :: DynFlags @@ -823,9 +823,9 @@ lookupNameDocumentation name defSiteMap = srcSpanToFilePath :: SrcSpan -> Maybe HCE.HaskellFilePath srcSpanToFilePath (RealSrcSpan s) = - Just . HCE.HaskellFilePath . T.pack . normalise . unpackFS . srcSpanFile $ s + Just . HCE.HaskellFilePath . T.pack . normalise . unpackFS . srcSpanFile $ s srcSpanToFilePath (UnhelpfulSpan _) = Nothing - + srcSpanToLineAndColNumbers :: HCE.SourceCodeTransformation -> SrcSpan @@ -894,7 +894,7 @@ applyWrapper (WpEvLam v) t = mkFunTy (evVarPred v) t applyWrapper (WpEvApp _ev) t = case splitFunTy_maybe t of Just (_arg,res) -> res Nothing -> t -#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) applyWrapper (WpTyLam v) t = mkForAllTy v Required t #else applyWrapper (WpTyLam v) t = mkForAllTy (mkNamedBinder Invisible v) t @@ -929,10 +929,10 @@ mkType flags typ = else Nothing) #if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) -typeToText :: DynFlags -> Type -> T.Text +typeToText :: DynFlags -> Type -> T.Text typeToText flags = T.pack . showSDoc flags . pprIfaceType . toIfaceType #else -typeToText :: DynFlags -> Type -> T.Text +typeToText :: DynFlags -> Type -> T.Text typeToText = toText #endif @@ -947,7 +947,7 @@ toTypeComponents flags typ = updateOccNames (\unique occName -> ";," ++ occName ++ "," ++ unique ++ ";") typ - -- Dirty but simple way to extract a list of TypeComponent from a type signature. + -- Dirty but simple way to extract a list of TypeComponent from a type signature. -- Assumptions : -- 1. Character ';' cannot appear anywhere in a type signature -- 2. Character ',' cannot appear in an 'OccName' @@ -984,11 +984,11 @@ updateOccNames update = everywhere (mkT updateType) (occNameSpace oldOccName) (update unique (occNameString oldOccName)) in mkInternalName (nameUnique oldName) newOccName (nameSrcSpan oldName) - + -- | This function doesn't look through type synonyms tyConsOfType :: Type -> [Id] tyConsOfType = -#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) nonDetEltsUniqSet . everything unionUniqSets (emptyVarSet `mkQ` tyCon) #else uniqSetToList . everything unionUniqSets (emptyVarSet `mkQ` tyCon) @@ -999,7 +999,7 @@ tyConsOfType = tyCon _ = emptyUniqSet tyVarsOfType :: (Data a) => a -> [Id] -#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) tyVarsOfType = nonDetEltsUniqSet . everything unionVarSet (emptyVarSet `mkQ` tyVar) #else tyVarsOfType = varSetElems . everything unionVarSet (emptyVarSet `mkQ` tyVar) @@ -1027,7 +1027,7 @@ collectDocs = go Nothing [] | Nothing <- prev = go Nothing (str : docs) ds | Just decl <- prev = finished decl docs (go Nothing [str] ds) -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) go prev docs (L _ (DocD _ (DocCommentPrev str)):ds) = go prev (str : docs) ds #else go prev docs (L _ (DocD (DocCommentPrev str)):ds) = go prev (str : docs) ds @@ -1043,9 +1043,9 @@ ungroup :: HsGroup Name -> [LHsDecl Name] #endif ungroup group_ = #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) - mkDecls (tyClGroupTyClDecls . hs_tyclds) (TyClD NoExt) group_ ++ + mkDecls (tyClGroupTyClDecls . hs_tyclds) (TyClD NoExt) group_ ++ #elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) - mkDecls (tyClGroupTyClDecls . hs_tyclds) TyClD group_ ++ + mkDecls (tyClGroupTyClDecls . hs_tyclds) TyClD group_ ++ #else mkDecls (tyClGroupConcat . hs_tyclds) TyClD group_ ++ #endif @@ -1054,17 +1054,17 @@ ungroup group_ = mkDecls hs_derivds (DerivD NoExt) group_ ++ mkDecls hs_defds (DefD NoExt) group_ ++ mkDecls hs_fords (ForD NoExt) group_ ++ - mkDecls hs_docs (DocD NoExt) group_ ++ + mkDecls hs_docs (DocD NoExt) group_ ++ #else mkDecls hs_derivds DerivD group_ ++ mkDecls hs_defds DefD group_ ++ mkDecls hs_fords ForD group_ ++ mkDecls hs_docs DocD group_ ++ #endif - + #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) mkDecls hsGroupInstDecls (InstD NoExt) group_ ++ -#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) +#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) mkDecls hsGroupInstDecls InstD group_ ++ #else mkDecls hs_instds InstD group_ ++ @@ -1076,17 +1076,17 @@ ungroup group_ = #else mkDecls (typesigs . hs_valds) SigD group_ ++ mkDecls (valbinds . hs_valds) ValD group_ -#endif +#endif + - where -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) typesigs (XValBindsLR (NValBinds _ sigs)) = filter isUserLSig sigs #else typesigs (ValBindsOut _ sigs) = filter isUserLSig sigs #endif typesigs _ = [] -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) valbinds (XValBindsLR (NValBinds binds _)) = concatMap (bagToList . snd) binds #else valbinds (ValBindsOut binds _) = concatMap (bagToList . snd) binds @@ -1107,7 +1107,7 @@ classDeclDocs :: TyClDecl Name -> [(LHsDecl Name, [HsDocString])] classDeclDocs class_ = collectDocs . sortByLoc $ decls where decls = docs ++ defs ++ sigs ++ ats -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) docs = mkDecls tcdDocs (DocD NoExt) class_ defs = mkDecls (bagToList . tcdMeths) (ValD NoExt) class_ sigs = mkDecls tcdSigs (SigD NoExt) class_ @@ -1136,7 +1136,7 @@ selectorDocs :: ConDecl GhcRn -> [(Name, [HsDocString], SrcSpan)] selectorDocs :: ConDecl Name -> [(Name, [HsDocString], SrcSpan)] #endif selectorDocs con = -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) case getConArgs con of #else case getConDetails con of @@ -1159,7 +1159,7 @@ selectorDocs con = flds _ -> [] -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) subordinateNamesWithDocs :: [GenLocated SrcSpan (HsDecl GhcRn)] -> [(Name, [HsDocString], SrcSpan)] #else subordinateNamesWithDocs :: [GenLocated SrcSpan (HsDecl Name)] -> [(Name, [HsDocString], SrcSpan)] @@ -1189,14 +1189,14 @@ subordinateNamesWithDocs = InstD (DataFamInstD DataFamInstDecl {..}) -> #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) concatMap (conDeclDocs . unLoc) . dd_cons . feqn_rhs . hsib_body $ dfid_eqn #else concatMap (conDeclDocs . unLoc) . dd_cons $ dfid_defn #endif _ -> []) - + isUserLSig :: LSig name -> Bool isUserLSig (L _ TypeSig {}) = True isUserLSig (L _ ClassOpSig {}) = True @@ -1239,8 +1239,8 @@ getMainDeclBinder (ForD ForeignExport {}) = [] getMainDeclBinder _ = [] #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) -sigNameNoLoc :: Sig pass -> [IdP pass] -#else +sigNameNoLoc :: Sig pass -> [IdP pass] +#else sigNameNoLoc :: Sig name -> [name] #endif #if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) @@ -1293,7 +1293,7 @@ hsDocsToDocH flags rdrEnv = #else . parseParas #endif -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) . concatMap unpackHDS #else . concatMap (unpackFS . (\(HsDocString s) -> s)) @@ -1368,7 +1368,7 @@ rename dflags gre = rn DocEmpty -> DocEmpty DocString str -> DocString str DocHeader (Header l t) -> DocHeader $ Header l (rn t) -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) DocTable t -> DocTable (rn <$> t) #endif @@ -1400,4 +1400,4 @@ makeAnchorId (f:r) = escape isAlpha f ++ concatMap (escape isLegal) r isLegal ':' = True isLegal '_' = True isLegal '.' = True - isLegal c = isAscii c && isAlphaNum c + isLegal c = isAscii c && isAlphaNum c diff --git a/src/HaskellCodeExplorer/ModuleInfo.hs b/src/HaskellCodeExplorer/ModuleInfo.hs index f449eee..fd8f61a 100644 --- a/src/HaskellCodeExplorer/ModuleInfo.hs +++ b/src/HaskellCodeExplorer/ModuleInfo.hs @@ -74,13 +74,13 @@ import HsDecls , InstDecl , TyClDecl #endif - , InstDecl(..) + , InstDecl(..) , group_tyclds , tyClDeclLName , tcdName #if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) , hsGroupInstDecls -#endif +#endif ) import HsDoc(HsDocString) import HsImpExp (IE(..), ImportDecl(..)) @@ -101,9 +101,9 @@ import Module(Module(..)) import Name (Name, OccName, getSrcSpan, nameOccName, nameSrcSpan, nameUnique) import Prelude hiding(id,span) import RdrName(GlobalRdrEnv) -import SrcLoc (isOneLineSpan) +import SrcLoc (isOneLineSpan) import TcRnTypes (tcVisibleOrphanMods, tcg_inst_env, tcg_rdr_env, tcg_type_env) -import qualified Text.Blaze.Html5 as H +import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as A #if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) import UniqDFM (eltsUDFM) @@ -118,14 +118,14 @@ type ModuleDependencies = ( HM.HashMap HCE.HaskellFilePath HCE.HaskellModulePath , HM.HashMap HCE.HaskellModulePath HCE.DefinitionSiteMap , HM.HashMap HCE.HaskellModuleName (HM.HashMap HCE.ComponentId HCE.HaskellModulePath)) - + type ModuleGhcData = ( DynFlags , TypecheckedModule , HomePackageTable , ExternalPackageState , ModSummary) - + createModuleInfo :: ModuleDependencies -- ^ Modules that have already been indexed -> ModuleGhcData -- ^ Data types from GHC @@ -156,7 +156,7 @@ createModuleInfo (fileMap, defSiteMap, moduleNameMap) (flags, typecheckedModule, currentModuleTyThings = typeEnvElts $ tcg_type_env tcGblEnv homePackageTyThings = concatMap (typeEnvElts . md_types . hm_details) $ -#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) eltsUDFM homePackageTable #else eltsUFM homePackageTable @@ -182,7 +182,7 @@ createModuleInfo (fileMap, defSiteMap, moduleNameMap) (flags, typecheckedModule, currentPackageId compId defSiteMap - fileMap + fileMap globalRdrEnv transformation modInfo @@ -316,7 +316,7 @@ createDefinitionSiteMap :: -> HCE.SourceCodeTransformation -> ModuleInfo -> [Name] -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) -> HsGroup GhcRn #else -> HsGroup Name @@ -345,11 +345,11 @@ createDefinitionSiteMap flags currentPackageId compId defSiteMap fileMap globalR mapMaybe (\(L _n decl, docs) -> case decl of -#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0) InstD _ (ClsInstD _ inst) -> Just (clsInstDeclSrcSpan inst, docs) -#else +#else InstD (ClsInstD inst) -> Just (clsInstDeclSrcSpan inst, docs) -#endif +#endif _ -> Nothing) $ instanceDeclsWithDocs nameLocation :: Maybe SrcSpan -> Name -> HCE.LocationInfo @@ -432,7 +432,7 @@ createDefinitionSiteMap flags currentPackageId compId defSiteMap fileMap globalR , map (\(n, _, _) -> n) allNamesWithDocumentation) occNameToHtml :: - DynFlags + DynFlags -> HCE.PackageId -> HCE.ComponentId -> (ModuleName, OccName) @@ -468,7 +468,7 @@ nameToHtml flags packageId compId transformation files defSiteMap name = name in H.span H.! H.dataAttribute "location" location H.! A.class_ "link" $ H.toHtml (nameToText name) - + docWithNamesToHtml :: DynFlags -> HCE.PackageId @@ -485,7 +485,7 @@ docWithNamesToHtml flags packageId compId transformation fileMap defSiteMap = createDeclarations :: DynFlags -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) -> HsGroup GhcRn #else -> HsGroup Name @@ -507,9 +507,9 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation = Nothing -> Nothing -- | Top-level functions -------------------------------------------------------------------------------- -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) valToDeclarations :: GenLocated SrcSpan (HsBindLR GhcRn GhcRn) -> [HCE.Declaration] -#endif +#endif valToDeclarations (L loc bind) = map (\name -> @@ -523,9 +523,9 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation = vals = concatMap valToDeclarations $ hsGroupVals hsGroup -- | Data, newtype, type, type family, data family or class declaration -------------------------------------------------------------------------------- -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) tyClToDeclaration :: GenLocated SrcSpan (TyClDecl GhcRn) -> HCE.Declaration -#endif +#endif tyClToDeclaration (L loc tyClDecl) = HCE.Declaration HCE.TyClD @@ -539,9 +539,9 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation = hsGroup -- | Instances -------------------------------------------------------------------------------- -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) instToDeclaration :: GenLocated SrcSpan (InstDecl GhcRn) -> HCE.Declaration -#endif +#endif instToDeclaration (L loc inst) = HCE.Declaration HCE.InstD @@ -550,7 +550,7 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation = True (lineNumber loc) insts = -#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) map instToDeclaration . filter (isGoodSrcSpan . getLoc) . hsGroupInstDecls $ #else map instToDeclaration . filter (isGoodSrcSpan . getLoc) . hs_instds $ @@ -558,10 +558,10 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation = hsGroup -- | Foreign functions -------------------------------------------------------------------------------- -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) foreignFunToDeclaration :: GenLocated SrcSpan (ForeignDecl GhcRn) -> HCE.Declaration -#endif +#endif foreignFunToDeclaration (L loc fd) = let name = unLoc $ fd_name fd in HCE.Declaration @@ -590,14 +590,14 @@ foldAST environment typecheckedModule = -- - type signatures -- - type/data/newtype declarations -- - class declarations - + -- Both typechecked source and renamed source are used to populate -- 'IdentifierInfoMap' and 'IdentifierOccurrenceMap' (idInfoMap, idOccMap) = L.foldl' (addIdentifierToMaps environment astStateIdSrcSpanMap) (HM.empty, astStateIdOccMap) - (namesFromRenamedSource renamed) + (namesFromRenamedSource renamed) flags = envDynFlags environment packageId = envPackageId environment compId = envComponentId environment @@ -619,7 +619,7 @@ foldAST environment typecheckedModule = case mbExported of Just lieNames -> mapMaybe -#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) (\(L span ie,_) -> #else (\(L span ie) -> @@ -733,7 +733,7 @@ addIdentifierToMaps environment idSrcSpanMap idMaps@(idInfoMap, idOccMap) nameOc lineNumber startCol endCol - Nothing -> idMaps + Nothing -> idMaps addIdentifierToMaps _ _ idMaps _ = idMaps addNameToMaps :: @@ -791,7 +791,7 @@ lookupIdByNameOccurrence :: -> NameOccurrence -> Maybe (Id, Maybe (Type, [Type])) lookupIdByNameOccurrence environment idSrcSpanMap (NameOccurrence (L span mbName) _ _) = - case M.lookup span idSrcSpanMap of + case M.lookup span idSrcSpanMap of Just (identifier, mbTypes) -> Just (identifier, mbTypes) Nothing -> case mbName of @@ -806,7 +806,7 @@ lookupIdByNameOccurrence environment idSrcSpanMap (NameOccurrence (L span mbName Nothing -> Nothing Nothing -> Nothing lookupIdByNameOccurrence _ _ TyLitOccurrence {..} = Nothing - + updateIdMap :: Environment -> [(Id, Maybe Name)] diff --git a/src/HaskellCodeExplorer/PackageInfo.hs b/src/HaskellCodeExplorer/PackageInfo.hs index dbfbfc7..5bc30b7 100644 --- a/src/HaskellCodeExplorer/PackageInfo.hs +++ b/src/HaskellCodeExplorer/PackageInfo.hs @@ -54,7 +54,7 @@ import Distribution.Helper , packageId , runQuery , sourceDirs - , compilerVersion + , compilerVersion ) import DynFlags ( DynFlags(..) @@ -86,7 +86,7 @@ import GHC , topSortModuleGraph , typecheckModule , moduleNameString - , moduleName + , moduleName ) import GHC.Paths (libdir) import GhcMonad (GhcT(..), liftIO) @@ -98,7 +98,7 @@ import Outputable (PprStyle, SDoc, neverQualify, showSDocForUser) import Packages (initPackages) import Prelude hiding (id) import System.Directory - ( doesFileExist + ( doesFileExist , findExecutable , setCurrentDirectory , getCurrentDirectory @@ -116,7 +116,7 @@ import System.FilePath , takeExtension , takeBaseName , takeDirectory - , splitDirectories + , splitDirectories ) import System.FilePath.Find (find,always,(==?),fileName) import System.Process (readProcess) @@ -158,7 +158,7 @@ createPackageInfo packageDirectoryPath mbDistDirRelativePath sourceCodePreproces [ "GHC version mismatch. haskell-code-indexer: " , T.pack $ showVersion ghcVersion , ", package: " - , T.pack $ showVersion packageCompilerVersion + , T.pack $ showVersion packageCompilerVersion ] liftIO exitFailure logInfoN $ T.append "Indexing " $ HCE.packageIdToText currentPackageId @@ -270,10 +270,10 @@ ghcVersion = makeVersion [8, 6, 5, 0] #elif MIN_VERSION_GLASGOW_HASKELL(8,6,4,0) ghcVersion :: Version ghcVersion = makeVersion [8, 6, 4, 0] -#elif MIN_VERSION_GLASGOW_HASKELL(8,6,3,0) +#elif MIN_VERSION_GLASGOW_HASKELL(8,6,3,0) ghcVersion :: Version ghcVersion = makeVersion [8, 6, 3, 0] -#elif MIN_VERSION_GLASGOW_HASKELL(8,4,4,0) +#elif MIN_VERSION_GLASGOW_HASKELL(8,4,4,0) ghcVersion :: Version ghcVersion = makeVersion [8, 4, 4, 0] #elif MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) @@ -286,7 +286,7 @@ ghcVersion = makeVersion [8, 2, 2, 0] ghcVersion :: Version ghcVersion = makeVersion [8, 0, 2, 0] #endif - + buildDirectoryTree :: FilePath -> [FilePath] -> (FilePath -> Bool) -> IO HCE.DirTree buildDirectoryTree path ignoreDirectories isHaskellModule = do (_dir DT.:/ tree) <- DT.readDirectoryWith (const . return $ ()) path @@ -316,7 +316,7 @@ buildDirectoryTree path ignoreDirectories isHaskellModule = do HCE.File name filePath (isHaskellModule filePath) toDirTree (DT.Failed name err) = HCE.File (name ++ " : " ++ show err) "" False - + addTopLevelIdentifiersFromModule :: HCE.Trie Char HCE.ExternalIdentifierInfo -> HCE.ModuleInfo @@ -327,8 +327,8 @@ addTopLevelIdentifiersFromModule trieIdInfo HCE.ModuleInfo {..} = HCE.insertToTrie S.insert (T.unpack demangledOccName) idInfo trie) trieIdInfo externalIds - -addReferencesFromModule :: + +addReferencesFromModule :: HM.HashMap HCE.ExternalId (S.Set HCE.IdentifierSrcSpan) -> HCE.ModuleInfo -> HM.HashMap HCE.ExternalId (S.Set HCE.IdentifierSrcSpan) @@ -406,7 +406,7 @@ findDistDirectory packagePath = do Left $ "Found multiple possible dist directories : \n" ++ show setupConfigPaths ++ " \nPlease specify --dist option" - + eachIdentifierOccurrence :: forall a. a @@ -450,7 +450,7 @@ ghandleSync onError = case fromException ex of Just (asyncEx :: SomeAsyncException) -> throw asyncEx _ -> onError ex) - + indexBuildComponent :: HCE.SourceCodePreprocessing -- ^ Before or after preprocessor -> HCE.PackageId -- ^ Current package id @@ -588,7 +588,7 @@ indexBuildComponent sourceCodePreprocessing currentPackageId componentId deps@(f return (indexedModules, (fileMap', defSiteMap', modNameMap'))) ([], (fileMap, defSiteMap, modNameMap)) modSumWithPath - + findHaskellModulePath :: FilePath -> [FilePath] -> ModSummary -> IO (Maybe HCE.HaskellModulePath) findHaskellModulePath buildDir srcDirs modSum = @@ -603,7 +603,7 @@ findHaskellModulePath buildDir srcDirs modSum = else path _ -> path in case removeTmpDir <$> L.stripPrefix buildDir modulePath of - -- File is in the build directory + -- File is in the build directory Just path | takeExtension path == ".hs-boot" -> do let possiblePaths = path : map ( path) srcDirs diff --git a/src/HaskellCodeExplorer/Preprocessor.hs b/src/HaskellCodeExplorer/Preprocessor.hs index 8dcf548..d998976 100644 --- a/src/HaskellCodeExplorer/Preprocessor.hs +++ b/src/HaskellCodeExplorer/Preprocessor.hs @@ -19,7 +19,7 @@ import HaskellCodeExplorer.Types , HaskellModulePath(..) , LinePragma(..) , SourceCodeTransformation(..) - , haskellPreprocessorExtensions + , haskellPreprocessorExtensions ) import System.FilePath (normalise,takeExtension,takeFileName) @@ -86,13 +86,13 @@ createSourceCodeTransformation currentModulePath originalSourceCode sourceCodeAf -- | Parses line pragma linePragmaParser :: AT.Parser (Int, Maybe T.Text) linePragmaParser = pragma1 <|> pragma2 - where + where pragma1 :: AT.Parser (Int, Maybe T.Text) pragma1 = parser "#" "line" - + pragma2 :: AT.Parser (Int, Maybe T.Text) pragma2 = parser "{-#" "LINE" - + parser :: T.Text -> T.Text -> AT.Parser (Int, Maybe T.Text) parser start line = do _ <- AT.string start @@ -103,9 +103,9 @@ linePragmaParser = pragma1 <|> pragma2 _ <- AT.takeWhile (== ' ') mbName <- (Just <$> fileName) <|> return Nothing return (num, mbName) - + fileName :: AT.Parser T.Text - fileName = AT.string "\"" *> AT.takeTill (== '\"') <* AT.string "\"" + fileName = AT.string "\"" *> AT.takeTill (== '\"') <* AT.string "\"" data Line = FirstLine | LastLine Int | Pragma LinePragma deriving (Show,Eq) diff --git a/src/HaskellCodeExplorer/Types.hs b/src/HaskellCodeExplorer/Types.hs index a21a483..b42db87 100644 --- a/src/HaskellCodeExplorer/Types.hs +++ b/src/HaskellCodeExplorer/Types.hs @@ -36,7 +36,7 @@ import qualified Data.IntervalMap.Strict as IVM import qualified Data.List as L import Data.Maybe (fromMaybe, isJust) import Data.Serialize (Get, Serialize(..)) -import qualified Data.Set as S +import qualified Data.Set as S import qualified Data.Text as T import Data.Text.Encoding (decodeUtf8, encodeUtf8) import Data.Text.Lazy (toStrict) @@ -51,8 +51,8 @@ import Documentation.Haddock.Types #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) , Table(..) , TableCell(..) - , TableRow(..) -#endif + , TableRow(..) +#endif ) import GHC.Generics (Generic) import Prelude hiding (id) @@ -185,7 +185,7 @@ data ModuleInfo = ModuleInfo -- ^ Information about each identifier in the module , declarations :: [Declaration] , definitionSiteMap :: DefinitionSiteMap - -- ^ Definition site of each top-level value, type, and type class instance + -- ^ Definition site of each top-level value, type, and type class instance , externalIds :: [ExternalIdentifierInfo] } deriving (Show, Eq, Generic, Data) @@ -226,7 +226,7 @@ haskellPreprocessorExtensions = toCompactPackageInfo :: PackageInfo ModuleInfo -> PackageInfo CompactModuleInfo toCompactPackageInfo PackageInfo {..} = PackageInfo - { id = id + { id = id , moduleMap = HM.map toCompactModuleInfo moduleMap , moduleNameMap = moduleNameMap , directoryTree = directoryTree @@ -322,11 +322,11 @@ instance Ord ExternalIdentifierInfo where case compare (demangledOccName i1) (demangledOccName i2) of GT -> GT LT -> LT - EQ -> + EQ -> compare (internalId (i1 :: IdentifierInfo)) (internalId (i2 :: IdentifierInfo)) - + data ExpressionInfo = ExpressionInfo { description :: T.Text , exprType :: Maybe Type @@ -372,7 +372,7 @@ data InstanceResolution = , types :: [Type] -- ^ Types at which type variables of a class are instantiated , location :: LocationInfo - , instances :: [InstanceResolution] + , instances :: [InstanceResolution] } | Stop deriving (Show,Eq,Ord,Generic,Data) @@ -426,7 +426,7 @@ fromOriginalLineNumber SourceCodeTransformation {fileIndex = index} (originalFil , " in " , T.pack $ show index ] - + data Declaration = Declaration { sort :: DeclarationSort , name :: T.Text @@ -563,7 +563,7 @@ instance NFData SourceCodeTransformation instance NFData IdentifierInfo instance NFData InternalId instance NFData ExternalId -instance NFData ExternalIdentifierInfo +instance NFData ExternalIdentifierInfo instance NFData InstanceResolution instance NFData IdDetails instance NFData NameSpace @@ -626,7 +626,7 @@ instance A.ToJSON ModuleInfo where , ("occurrences", A.toJSON $ idOccurrencesHashMap idOccMap) , ("declarations", A.toJSON declarations) ] - + idOccurrencesHashMap :: IM.IntMap [((Int, Int), IdentifierOccurrence)] -> HM.HashMap T.Text IdentifierOccurrence @@ -638,7 +638,7 @@ idOccurrencesHashMap = (\((startCol, endCol), occ) -> (occurrenceLocationToText lineNum startCol endCol, occ)) occs) . - IM.toList + IM.toList idOccurrenceList :: IM.IntMap [((Int, Int), IdentifierOccurrence)] @@ -651,7 +651,7 @@ idOccurrenceList = (\((startCol, endCol), occ) -> (occurrenceLocationToText lineNum startCol endCol, occ)) occs) . - IM.toList + IM.toList occurrenceLocationToText :: Int -> Int -> Int -> T.Text occurrenceLocationToText lineNum startCol endCol = @@ -710,7 +710,7 @@ tokenize -> [((Int, Int), a)] -- ^ Identifier locations -- The end position is defined to be the column /after/ the end of the -- span. That is, a span of (1,1)-(1,2) is one character long, and a - -- span of (1,1)-(1,1) is zero characters long. + -- span of (1,1)-(1,1) is zero characters long. -> [(T.Text, (Int, Int), Maybe a)] tokenize line = L.reverse . @@ -807,14 +807,14 @@ docToHtml modToHtml idToHtml = toStrict . renderHtml . toH in Html.table $ Html.thead (mapM_ (tableRowToH Html.th) hs) >> Html.tbody (mapM_ (tableRowToH Html.td) bs) -#endif - +#endif + instance A.ToJSON HaskellModuleName where toJSON (HaskellModuleName name) = A.String name instance A.ToJSON HaskellModulePath where toJSON (HaskellModulePath path) = A.String path instance A.ToJSON HaskellFilePath where - toJSON (HaskellFilePath path) = A.String path + toJSON (HaskellFilePath path) = A.String path instance A.ToJSON LinePragma where toJSON = A.genericToJSON omitNothingOptions instance A.ToJSON FileLocation where @@ -824,7 +824,7 @@ instance A.ToJSON IdentifierInfo where instance A.ToJSON InternalId where toJSON (InternalId text) = A.toJSON text instance A.ToJSON ExternalId where - toJSON (ExternalId text) = A.toJSON text + toJSON (ExternalId text) = A.toJSON text instance A.ToJSON ExternalIdentifierInfo where toJSON (ExternalIdentifierInfo info) = A.toJSON info instance A.ToJSON InstanceResolution where @@ -842,7 +842,7 @@ instance A.ToJSON IdDetails where toJSON = A.genericToJSON omitNothingOptions instance A.ToJSON NameSpace where toJSON = A.genericToJSON omitNothingOptions -instance A.ToJSON Declaration +instance A.ToJSON Declaration instance A.ToJSON NameSort instance A.ToJSON OccName where toJSON (OccName name) = A.String name @@ -870,7 +870,7 @@ instance A.ToJSON Type where toJSON = A.genericToJSON omitNothingOptions instance A.ToJSON ExpressionInfo where toJSON = A.genericToJSON omitNothingOptions -instance A.ToJSON DirTree +instance A.ToJSON DirTree instance A.ToJSON DefinitionSite where toJSON = A.genericToJSON omitNothingOptions instance A.ToJSON IdentifierSrcSpan -- cgit v1.2.3