Add support for GHC 8.6.3

This commit is contained in:
alexwl 2018-12-23 17:59:00 +03:00
parent 27024fa574
commit e6d0b7bf09
13 changed files with 833 additions and 123 deletions

View File

@ -43,12 +43,18 @@ cd haskell-code-explorer
To build Haskell Code Explorer Stack ([https://docs.haskellstack.org/en/stable/README/](https://docs.haskellstack.org/en/stable/README/)) is needed.
At the moment Haskell Code Explorer supports GHC 8.4.4, GHC 8.4.3, GHC 8.2.2, and 8.0.2.
At the moment Haskell Code Explorer supports GHC 8.6.3, GHC 8.4.4, GHC 8.4.3, GHC 8.2.2, and 8.0.2.
For GHC 8.6.3:
```bash
stack install
```
For GHC 8.4.4:
```bash
stack install
stack --stack-yaml=stack-8.4.4.yaml install
```
For GHC 8.4.3:

View File

@ -73,7 +73,10 @@ data Compression
| NoCompression
deriving (Show, Eq)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,4,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,3,0)
ghcVersion :: Version
ghcVersion = Version {versionBranch = [8, 6, 3, 0], versionTags = []}
#elif MIN_VERSION_GLASGOW_HASKELL(8,4,4,0)
ghcVersion :: Version
ghcVersion = Version {versionBranch = [8, 4, 4, 0], versionTags = []}
#elif MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)

View File

@ -132,8 +132,13 @@ namesFromRenamedSource =
fieldOccName :: Bool -> FieldOcc GhcRn -> NameOccurrence
#else
fieldOccName :: Bool -> FieldOcc Name -> NameOccurrence
#endif
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
fieldOccName _ (XFieldOcc _) = undefined
fieldOccName isBinder (FieldOcc name (L span _)) =
#else
fieldOccName isBinder (FieldOcc (L span _) name) =
#endif
NameOccurrence
{ locatedName = L span (Just name)
, description = "FieldOcc"
@ -147,6 +152,9 @@ conDeclFieldNames :: ConDeclField Name -> [NameOccurrence]
#endif
conDeclFieldNames ConDeclField {..} =
map (fieldOccName True . unLoc) cd_fld_names
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
conDeclFieldNames _ = []
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
hsRecFieldExprNames :: HsRecField' (FieldOcc GhcRn) (LHsExpr GhcRn) -> [NameOccurrence]
@ -164,14 +172,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
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]
@ -184,8 +197,12 @@ hsRecFieldPatNames HsRecField {..} = [fieldOccName False $ unLoc hsRecFieldLbl]
hsExprNames :: LHsExpr GhcRn -> [NameOccurrence]
#else
hsExprNames :: LHsExpr Name -> [NameOccurrence]
#endif
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsExprNames (L _span (HsVar _ name)) =
#else
hsExprNames (L _span (HsVar name)) =
#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "HsVar"
@ -201,28 +218,44 @@ hsExprNames (L span (ExplicitList _ _ exprs))
}
]
| otherwise = []
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsExprNames (L _span (RecordCon _ name _)) =
#else
hsExprNames (L _span (RecordCon name _conLike _instFun _binds)) =
#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "RecordCon"
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsExprNames (L _span (HsRecFld _ (Unambiguous name (L span _)))) =
#else
hsExprNames (L _span (HsRecFld (Unambiguous (L span _) name))) =
#endif
[ NameOccurrence
{ locatedName = L span (Just name)
, description = "HsRecFld"
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsExprNames (L _span (HsRecFld _ (Ambiguous _name (L span _)))) =
#else
hsExprNames (L _span (HsRecFld (Ambiguous (L span _) _name))) =
#endif
[ NameOccurrence
{ locatedName = L span Nothing
, description = "HsRecFld"
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsExprNames (L span (HsRnBracketOut _ (VarBr _ quote name) _)) =
#else
hsExprNames (L span (HsRnBracketOut (VarBr quote name) _)) =
#endif
case span of
RealSrcSpan realSpan ->
let start = realSrcSpanStart realSpan
@ -278,7 +311,11 @@ bindNames :: LHsBindLR GhcRn GhcRn -> [NameOccurrence]
#else
bindNames :: LHsBindLR Name Name -> [NameOccurrence]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
bindNames (L _span (PatSynBind _ PSB {..})) =
#else
bindNames (L _span (PatSynBind PSB {..})) =
#endif
[ NameOccurrence
{ locatedName = Just <$> psb_id
, description = "PatSynBind"
@ -318,8 +355,12 @@ importNames =
patNames :: LPat GhcRn -> [NameOccurrence]
#else
patNames :: LPat Name -> [NameOccurrence]
#endif
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
patNames (L _span (VarPat _ name)) =
#else
patNames (L _span (VarPat name)) =
#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "VarPat"
@ -333,14 +374,22 @@ patNames (L _span (ConPatIn name _)) =
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
patNames (L _span (AsPat _ name _)) =
#else
patNames (L _span (AsPat name _)) =
#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "AsPat"
, isBinder = True
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
patNames (L _span (NPlusKPat _ name _ _ _ _)) =
#else
patNames (L _span (NPlusKPat name _ _ _ _ _)) =
#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "NPlusKPat"
@ -354,8 +403,13 @@ patNames _ = []
sigNames :: LSig GhcRn -> [NameOccurrence]
#else
sigNames :: LSig Name -> [NameOccurrence]
#endif
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNames (L _span (TypeSig _ names _)) =
#else
sigNames (L _span (TypeSig names _)) =
#endif
map
(\n ->
NameOccurrence
@ -364,9 +418,11 @@ sigNames (L _span (TypeSig names _)) =
, isBinder = False
})
names
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
sigNames (L _span (PatSynSig names _)) =
map (\name -> NameOccurrence (Just <$> name) "PatSynSig" False) names
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
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
sigNames (L _span (PatSynSig name _)) =
[ NameOccurrence
@ -376,7 +432,11 @@ sigNames (L _span (PatSynSig name _)) =
}
]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNames (L _span (ClassOpSig _ _ names _)) =
#else
sigNames (L _span (ClassOpSig _ names _)) =
#endif
map
(\n ->
NameOccurrence
@ -385,7 +445,11 @@ sigNames (L _span (ClassOpSig _ names _)) =
, isBinder = True
})
names
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNames (L _span (FixSig _ (FixitySig _ names _))) =
#else
sigNames (L _span (FixSig (FixitySig names _))) =
#endif
map
(\n ->
NameOccurrence
@ -394,21 +458,33 @@ sigNames (L _span (FixSig (FixitySig names _))) =
, isBinder = False
})
names
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNames (L _span (InlineSig _ name _)) =
#else
sigNames (L _span (InlineSig name _)) =
#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "InlineSig"
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNames (L _span (SpecSig _ name _ _)) =
#else
sigNames (L _span (SpecSig name _ _)) =
#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "SpecSig"
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNames (L _span (MinimalSig _ _ (L _ boolFormula))) =
#else
sigNames (L _span (MinimalSig _ (L _ boolFormula))) =
#endif
map
(\n ->
NameOccurrence
@ -431,7 +507,9 @@ hsTypeNames :: LHsType GhcRn -> [NameOccurrence]
#else
hsTypeNames :: LHsType Name -> [NameOccurrence]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTypeNames (L _span (HsTyVar _ _promoted name)) =
#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
hsTypeNames (L _span (HsTyVar _promoted name)) =
#else
hsTypeNames (L _span (HsTyVar name)) =
@ -442,7 +520,11 @@ hsTypeNames (L _span (HsTyVar name)) =
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTypeNames (L span (HsTyLit _ lit)) =
#else
hsTypeNames (L span (HsTyLit lit)) =
#endif
let kind =
case lit of
HsNumTy _ _ -> typeNatKind
@ -453,14 +535,22 @@ hsTypeNames (L span (HsTyLit lit)) =
, kind = kind
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTypeNames (L _span (HsOpTy _ _ name _)) =
#else
hsTypeNames (L _span (HsOpTy _ name _)) =
#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "HsOpTy"
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTypeNames (L span (HsTupleTy _ tupleSort types))
#else
hsTypeNames (L span (HsTupleTy tupleSort types))
#endif
| null types =
let sort =
case tupleSort of
@ -486,20 +576,32 @@ hsTyVarBndrNames :: HsTyVarBndr GhcRn -> [NameOccurrence]
#else
hsTyVarBndrNames :: HsTyVarBndr Name -> [NameOccurrence]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTyVarBndrNames (UserTyVar _ n) =
#else
hsTyVarBndrNames (UserTyVar n) =
#endif
[ NameOccurrence
{ locatedName = Just <$> n
, description = "UserTyVar"
, isBinder = True
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTyVarBndrNames (KindedTyVar _ n _) =
#else
hsTyVarBndrNames (KindedTyVar n _) =
#endif
[ NameOccurrence
{ locatedName = Just <$> n
, description = "KindedTyVar"
, isBinder = True
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTyVarBndrNames _ = []
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
tyClDeclNames :: LTyClDecl GhcRn -> [NameOccurrence]
@ -543,7 +645,7 @@ tyClDeclNames _ = []
familyDeclNames :: FamilyDecl GhcRn -> [NameOccurrence]
#else
familyDeclNames :: FamilyDecl Name -> [NameOccurrence]
#endif
#endif
familyDeclNames FamilyDecl {..} =
[ NameOccurrence
{ locatedName = Just <$> fdLName
@ -551,7 +653,9 @@ familyDeclNames FamilyDecl {..} =
, isBinder = True
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
familyDeclNames _ = []
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
familyEqNames :: FamEqn GhcRn (HsTyPats GhcRn) (LHsType GhcRn) -> [NameOccurrence]
@ -562,6 +666,9 @@ familyEqNames FamEqn {feqn_tycon = tyCon} =
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
familyEqNames _ = []
#endif
dataEqNames :: FamEqn GhcRn (HsTyPats GhcRn) (HsDataDefn GhcRn) -> [NameOccurrence]
dataEqNames FamEqn {feqn_tycon = tyCon} =
@ -571,6 +678,10 @@ dataEqNames FamEqn {feqn_tycon = tyCon} =
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
dataEqNames _ = []
#endif
#else
tyFamilyEqNames :: TyFamEqn Name (HsTyPats Name) -> [NameOccurrence]
tyFamilyEqNames TyFamEqn {tfe_tycon = tyCon} =
@ -598,7 +709,7 @@ dataFamInstDeclNames DataFamInstDecl {dfid_tycon = tyCon} =
, isBinder = False
}
]
#endif
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
conDeclNames :: ConDecl GhcRn -> [NameOccurrence]
@ -623,6 +734,9 @@ conDeclNames con =
, isBinder = True
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
_ -> []
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
foreignDeclNames :: ForeignDecl GhcRn -> [NameOccurrence]
@ -642,13 +756,20 @@ roleAnnotationNames :: RoleAnnotDecl GhcRn -> [NameOccurrence]
#else
roleAnnotationNames :: RoleAnnotDecl Name -> [NameOccurrence]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
roleAnnotationNames (RoleAnnotDecl _ n _) =
#else
roleAnnotationNames (RoleAnnotDecl n _) =
#endif
[ NameOccurrence
{ locatedName = Just <$> n
, description = "RoleAnnotDecl"
, isBinder = False
}
]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
roleAnnotationNames _ = []
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
injectivityAnnotationNames :: InjectivityAnn GhcRn -> [NameOccurrence]
@ -665,3 +786,4 @@ injectivityAnnotationNames (InjectivityAnn lhsName rhsNames) =
, description = "InjectivityAnn"
, isBinder = False
}

File diff suppressed because it is too large Load Diff

View File

@ -69,7 +69,6 @@ import qualified Data.Generics.Uniplate.Data()
import qualified Data.HashMap.Strict as HM
import qualified Data.List as L
import Data.Maybe (fromMaybe, isJust, mapMaybe)
import Data.Ord (comparing)
import qualified Data.Text as T
import DataCon (dataConWorkId, flSelector)
import Documentation.Haddock.Parser (overIdentifier, parseParas)
@ -103,10 +102,9 @@ import GHC
, IE(..)
, TyThing(..)
, LHsDecl
, HsDecl(..)
, HsDecl(..)
, DocDecl(..)
, ConDecl(..)
, PostRn
, HsConDetails(..)
, ConDeclField(..)
, DataFamInstDecl(..)
@ -119,8 +117,16 @@ import GHC
, getLoc
, hsSigType
, getConNames
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
, NHsValBindsLR(..)
, getConArgs
, unpackHDS
, NoExt(..)
, extFieldOcc
#else
, getConDetails
, selectorFieldOcc
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
, tyClGroupTyClDecls
, LIEWrappedName
@ -275,11 +281,32 @@ instanceDeclToText :: DynFlags -> InstDecl Name -> T.Text
#endif
instanceDeclToText flags decl =
case decl of
ClsInstD ClsInstDecl {..} -> T.append "instance " (toText flags cid_poly_ty)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
XInstDecl _ -> ""
ClsInstD _ (XClsInstDecl _) -> ""
ClsInstD _ ClsInstDecl {..} ->
#else
ClsInstD ClsInstDecl {..} ->
#endif
T.append "instance " (toText flags cid_poly_ty)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
DataFamInstD _ di ->
let args =
T.intercalate " " . map (toText flags) . feqn_pats . hsib_body . dfid_eqn $ di
in T.concat
["data instance ", toText flags (unLoc $ feqn_tycon . hsib_body . dfid_eqn $ di), " ", args]
TyFamInstD _ ti ->
let args =
T.intercalate " " .
map (toText flags) . feqn_pats . hsib_body . tfid_eqn $
ti
in T.concat
["type instance ", toText flags $ tyFamInstDeclName ti, " ", args]
#elif MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
DataFamInstD di ->
let args =
T.intercalate " " . map (toText flags) . feqn_pats .hsib_body . dfid_eqn $ di
T.intercalate " " . map (toText flags) . feqn_pats . hsib_body . dfid_eqn $ di
in T.concat
["data instance ", toText flags (unLoc $ feqn_tycon . hsib_body . dfid_eqn $ di), " ", args]
TyFamInstD ti ->
@ -313,7 +340,7 @@ tyClDeclPrefix tyClDecl =
isNewTy DataDecl {tcdDataDefn = HsDataDefn {dd_ND = NewType}} = True
isNewTy _ = False
in case tyClDecl of
FamDecl _
FamDecl {}
| isDataFamilyDecl tyClDecl -> "data family "
| otherwise -> "type family "
SynDecl {} -> "type "
@ -321,6 +348,9 @@ tyClDeclPrefix tyClDecl =
| isNewTy tyClDecl -> "newtype "
| otherwise -> "data "
ClassDecl {} -> "class "
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
XTyClDecl _ -> ""
#endif
demangleOccName :: Name -> T.Text
demangleOccName name
@ -411,7 +441,11 @@ 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)
XValBindsLR (NValBinds binds _) -> concatMap (bagToList . snd) binds
#else
ValBindsOut binds _ -> concatMap (bagToList . snd) binds
#endif
_ -> []
hsPatSynDetails :: HsPatSynDetails a -> [a]
@ -450,15 +484,36 @@ ieLocNames :: IE pass -> [Located (IdP pass)]
#else
ieLocNames :: IE Name -> [Located Name]
#endif
ieLocNames (IEVar n) = [unwrapName n]
ieLocNames (IEThingAbs n) = [unwrapName n]
ieLocNames (IEThingAll n) = [unwrapName n]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
ieLocNames (XIE _) = []
ieLocNames (IEVar _ n) =
#else
ieLocNames (IEVar n) =
#endif
[unwrapName n]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
ieLocNames (IEThingAbs _ n) =
#else
ieLocNames (IEThingAbs n) =
#endif
[unwrapName n]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
ieLocNames (IEThingAll _ n) =
#else
ieLocNames (IEThingAll n) =
#endif
[unwrapName n]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
ieLocNames (IEThingWith _ n _ ns labels) =
#else
ieLocNames (IEThingWith n _ ns labels) =
#endif
unwrapName n : (map unwrapName ns ++ map (fmap flSelector) labels)
ieLocNames (IEModuleContents (L _ _)) = []
ieLocNames (IEGroup _ _) = []
ieLocNames (IEDoc _) = []
ieLocNames (IEDocNamed _) = []
ieLocNames IEModuleContents {} = []
ieLocNames IEGroup {} = []
ieLocNames IEDoc {} = []
ieLocNames IEDocNamed {} = []
--------------------------------------------------------------------------------
-- Lookups
@ -959,10 +1014,19 @@ collectDocs = go Nothing []
where
go Nothing _ [] = []
go (Just prev) docs [] = finished prev docs []
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
go prev docs (L _ (DocD _ (DocCommentNext str)):ds)
#else
go prev docs (L _ (DocD (DocCommentNext str)):ds)
#endif
| 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)
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
#endif
go Nothing docs (d:ds) = go (Just d) docs ds
go (Just prev) docs (d:ds) = finished prev docs (go (Just d) [] ds)
finished decl docs rest = (decl, reverse docs) : rest
@ -973,33 +1037,62 @@ ungroup :: HsGroup GhcRn -> [LHsDecl GhcRn]
ungroup :: HsGroup Name -> [LHsDecl Name]
#endif
ungroup group_ =
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
mkDecls (tyClGroupTyClDecls . hs_tyclds) (TyClD NoExt) group_ ++
#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
mkDecls (tyClGroupTyClDecls . hs_tyclds) TyClD group_ ++
#else
mkDecls (tyClGroupConcat . hs_tyclds) TyClD group_ ++
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
mkDecls hs_derivds (DerivD NoExt) group_ ++
mkDecls hs_defds (DefD NoExt) group_ ++
mkDecls hs_fords (ForD 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_ ++
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
mkDecls hsGroupInstDecls (InstD NoExt) group_ ++
#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
mkDecls hsGroupInstDecls InstD group_ ++
#else
mkDecls hs_instds InstD group_ ++
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
mkDecls (typesigs . hs_valds) (SigD NoExt) group_ ++
mkDecls (valbinds . hs_valds) (ValD NoExt) group_
#else
mkDecls (typesigs . hs_valds) SigD group_ ++
mkDecls (valbinds . hs_valds) ValD group_
#endif
where
#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)
valbinds (XValBindsLR (NValBinds binds _)) = concatMap bagToList . snd . unzip $ binds
#else
valbinds (ValBindsOut binds _) = concatMap bagToList . snd . unzip $ binds
#endif
valbinds _ = []
mkDecls :: (a -> [Located b]) -> (b -> c) -> a -> [Located c]
mkDecls field con struct = [L loc (con decl) | L loc decl <- field struct]
sortByLoc :: [Located a] -> [Located a]
sortByLoc = L.sortBy (comparing getLoc)
sortByLoc = L.sortOn getLoc
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
classDeclDocs :: TyClDecl GhcRn -> [(LHsDecl GhcRn, [HsDocString])]
@ -1009,10 +1102,18 @@ 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)
docs = mkDecls tcdDocs (DocD NoExt) class_
defs = mkDecls (bagToList . tcdMeths) (ValD NoExt) class_
sigs = mkDecls tcdSigs (SigD NoExt) class_
ats = mkDecls tcdATs ((TyClD NoExt) . (FamDecl NoExt)) class_
#else
docs = mkDecls tcdDocs DocD class_
defs = mkDecls (bagToList . tcdMeths) ValD class_
sigs = mkDecls tcdSigs SigD class_
ats = mkDecls tcdATs (TyClD . FamDecl) class_
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
conDeclDocs :: ConDecl GhcRn -> [(Name, [HsDocString], SrcSpan)]
@ -1025,18 +1126,30 @@ conDeclDocs conDecl =
conDecl
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
selectorDocs :: ConDecl pass -> [(PostRn pass (IdP pass), [HsDocString], SrcSpan)]
selectorDocs :: ConDecl GhcRn -> [(Name, [HsDocString], SrcSpan)]
#else
selectorDocs :: ConDecl name -> [(PostRn name name, [HsDocString], SrcSpan)]
selectorDocs :: ConDecl Name -> [(Name, [HsDocString], SrcSpan)]
#endif
selectorDocs con =
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
case getConArgs con of
#else
case getConDetails con of
#endif
RecCon (L _ flds) ->
concatMap
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
(\(L _ (ConDeclField _ fieldOccs _ mbDoc)) ->
#else
(\(L _ (ConDeclField fieldOccs _ mbDoc)) ->
#endif
map
(\(L span f) ->
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
(extFieldOcc f, maybe [] ((: []) . unLoc) mbDoc, span))
#else
(selectorFieldOcc f, maybe [] ((: []) . unLoc) mbDoc, span))
#endif
fieldOccs)
flds
_ -> []
@ -1050,14 +1163,27 @@ subordinateNamesWithDocs =
concatMap
(\(L span tyClDecl) ->
case tyClDecl of
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
TyClD _ classDecl@ClassDecl {..} ->
#else
TyClD classDecl@ClassDecl {..} ->
#endif
concatMap
(\(L _ decl, docs) -> map (, docs, span) $ getMainDeclBinder decl) $
classDeclDocs classDecl
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
TyClD _ DataDecl {..} ->
#else
TyClD DataDecl {..} ->
#endif
concatMap (\(L _ con) -> conDeclDocs con ++ selectorDocs con) $
dd_cons tcdDataDefn
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
InstD _ (DataFamInstD _ DataFamInstDecl {..}) ->
#else
InstD (DataFamInstD DataFamInstDecl {..}) ->
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
concatMap (conDeclDocs . unLoc) . dd_cons . feqn_rhs . hsib_body $ dfid_eqn
#else
@ -1076,14 +1202,35 @@ getMainDeclBinder :: HsDecl pass -> [IdP pass]
#else
getMainDeclBinder :: HsDecl name -> [name]
#endif
getMainDeclBinder (TyClD d) = [tcdName d]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
getMainDeclBinder (TyClD _ d) =
#else
getMainDeclBinder (TyClD d) =
#endif
[tcdName d]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
getMainDeclBinder (ValD _ d) =
#else
getMainDeclBinder (ValD d) =
#endif
case collectHsBindBinders d of
[] -> []
(name:_) -> [name]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
getMainDeclBinder (SigD _ d) = sigNameNoLoc d
#else
getMainDeclBinder (SigD d) = sigNameNoLoc d
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
getMainDeclBinder (ForD _ (ForeignImport _ name _ _)) = [unLoc name]
#else
getMainDeclBinder (ForD (ForeignImport name _ _ _)) = [unLoc name]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
getMainDeclBinder (ForD _ ForeignExport {}) = []
#else
getMainDeclBinder (ForD ForeignExport {}) = []
#endif
getMainDeclBinder _ = []
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
@ -1091,20 +1238,45 @@ sigNameNoLoc :: Sig pass -> [IdP pass]
#else
sigNameNoLoc :: Sig name -> [name]
#endif
sigNameNoLoc (TypeSig ns _) = map unLoc ns
sigNameNoLoc (ClassOpSig _ ns _) = map unLoc ns
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
sigNameNoLoc (PatSynSig ns _) = map unLoc ns
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNameNoLoc (TypeSig _ ns _) = map unLoc ns
#else
sigNameNoLoc (PatSynSig n _) = [unLoc n]
sigNameNoLoc (TypeSig ns _) = map unLoc ns
#endif
sigNameNoLoc (SpecSig n _ _) = [unLoc n]
sigNameNoLoc (InlineSig n _) = [unLoc n]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNameNoLoc (ClassOpSig _ _ ns _) = map unLoc ns
#else
sigNameNoLoc (ClassOpSig _ ns _) = map unLoc ns
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNameNoLoc (PatSynSig _ ns _) = map unLoc ns
#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
sigNameNoLoc (PatSynSig ns _) = map unLoc ns
#else
sigNameNoLoc (PatSynSig n _) = [unLoc n]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNameNoLoc (SpecSig _ n _ _) = [unLoc n]
#else
sigNameNoLoc (SpecSig n _ _) = [unLoc n]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNameNoLoc (InlineSig _ n _) = [unLoc n]
#else
sigNameNoLoc (InlineSig n _) = [unLoc n]
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
sigNameNoLoc (FixSig _ (FixitySig _ ns _)) = map unLoc ns
#else
sigNameNoLoc (FixSig (FixitySig ns _)) = map unLoc ns
#endif
sigNameNoLoc _ = []
clsInstDeclSrcSpan :: ClsInstDecl a -> SrcSpan
clsInstDeclSrcSpan ClsInstDecl {cid_poly_ty = ty} = getLoc (hsSigType ty)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
clsInstDeclSrcSpan (XClsInstDecl _) = UnhelpfulSpan "XClsinstdecl"
#endif
hsDocsToDocH :: DynFlags -> GlobalRdrEnv -> [HsDocString] -> Doc Name
hsDocsToDocH flags rdrEnv =
@ -1116,7 +1288,11 @@ hsDocsToDocH flags rdrEnv =
#else
. parseParas
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
. concatMap unpackHDS
#else
. concatMap (unpackFS . (\(HsDocString s) -> s))
#endif
parseIdent :: DynFlags -> String -> Maybe RdrName
parseIdent dflags str0 =

View File

@ -25,7 +25,6 @@ import qualified Data.IntMap.Strict as IM
import qualified Data.IntervalMap.Strict as IVM
import qualified Data.List as L hiding (span)
import Data.Maybe (fromMaybe, mapMaybe)
import Data.Ord (comparing)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
import HsExtension (GhcRn)
#endif
@ -241,7 +240,7 @@ createModuleInfo (fileMap, defSiteMap, moduleNameMap) (flags, typecheckedModule,
(HM.fromList .
(( HCE.HaskellFilePath $ HCE.getHaskellModulePath modulePath
, modulePath) :) .
map (\includedFile -> (includedFile, modulePath)) $
map (, modulePath) $
includedFiles)
fileMap
, HM.union (HM.singleton modulePath defSites) defSiteMap
@ -279,9 +278,11 @@ prepareSourceCode ::
-> (HCE.SourceCodeTransformation, T.Text)
prepareSourceCode sourceCodePreprocessing originalSourceCode modSum modulePath =
let sourceCodeAfterPreprocessing =
case TE.decodeUtf8'
(fromMaybe (error "ms_hspp_buf is Nothing") $
stringBufferToByteString <$> ms_hspp_buf modSum) of
case TE.decodeUtf8' $
maybe
(error "ms_hspp_buf is Nothing")
stringBufferToByteString
(ms_hspp_buf modSum) of
Right text -> T.replace "\t" " " text
Left err ->
error $
@ -322,12 +323,12 @@ createDefinitionSiteMap flags currentPackageId compId defSiteMap fileMap globalR
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
allDecls :: [GenLocated SrcSpan (HsDecl GhcRn)]
#endif
allDecls = L.sortBy (comparing getLoc) . ungroup $ hsGroup
allDecls = L.sortOn getLoc . ungroup $ hsGroup
(instanceDeclsWithDocs, valueAndTypeDeclsWithDocs) =
L.partition
(\(L _ decl, _) ->
case decl of
InstD _ -> True
InstD {} -> True
_ -> False) $
collectDocs allDecls
--------------------------------------------------------------------------------
@ -340,7 +341,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)
InstD _ (ClsInstD _ inst) -> Just (clsInstDeclSrcSpan inst, docs)
#else
InstD (ClsInstD inst) -> Just (clsInstDeclSrcSpan inst, docs)
#endif
_ -> Nothing) $
instanceDeclsWithDocs
nameLocation :: Maybe SrcSpan -> Name -> HCE.LocationInfo
@ -563,7 +568,7 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation =
(lineNumber loc)
fords = map foreignFunToDeclaration $ hs_fords hsGroup
--------------------------------------------------------------------------------
in L.sortBy (comparing HCE.lineNumber) $ vals ++ tyclds ++ insts ++ fords
in L.sortOn HCE.lineNumber $ vals ++ tyclds ++ insts ++ fords
foldAST :: Environment -> TypecheckedModule -> SourceInfo
foldAST environment typecheckedModule =
@ -616,7 +621,11 @@ foldAST environment typecheckedModule =
(\(L span ie) ->
#endif
case ie of
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
IEModuleContents _ (L _ modName) ->
#else
IEModuleContents (L _ modName) ->
#endif
Just
( modName
, span
@ -632,7 +641,7 @@ foldAST environment typecheckedModule =
addImportedAndExportedModulesToIdOccMap ::
HCE.IdentifierOccurrenceMap -> HCE.IdentifierOccurrenceMap
addImportedAndExportedModulesToIdOccMap =
IM.map (L.sortBy $ comparing fst) .
IM.map (L.sortOn fst) .
addModules
(envTransformation environment)
(importedModules ++ exportedModules)

View File

@ -443,7 +443,7 @@ indexBuildComponent sourceCodePreprocessing currentPackageId componentId deps@(f
(flags', _, _) <-
parseDynamicFlagsCmdLine
flags
(L.map noLoc . L.filter ((/=) "-Werror") $ options) -- -Werror flag makes warnings fatal
(L.map noLoc . L.filter ("-Werror" /=) $ options) -- -Werror flag makes warnings fatal
(flags'', _) <- liftIO $ initPackages flags'
logFn <- askLoggerIO
let logAction ::

8
stack-8.4.4.yaml Normal file
View File

@ -0,0 +1,8 @@
resolver: lts-12.16
packages:
- '.'
- location: vendor/cabal-helper-0.8.1.2
extra-dep: true
allow-newer: true
extra-deps:
- cabal-plan-0.4.0.0

View File

@ -1,4 +1,4 @@
resolver: lts-12.16
resolver: nightly-2018-12-21
packages:
- '.'
- location: vendor/cabal-helper-0.8.1.2

View File

@ -155,8 +155,10 @@ moduleInfoSpec modInfo =
HCE.idOccMap (modInfo :: HCE.ModuleInfo) `shouldBe` testIdOccMap
stackYamlArg :: [String]
#if MIN_VERSION_GLASGOW_HASKELL(8,4,4,0)
#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
stackYamlArg = []
#elif MIN_VERSION_GLASGOW_HASKELL(8,4,4,0)
stackYamlArg = ["--stack-yaml=stack-8.4.4.yaml"]
#elif MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
stackYamlArg = ["--stack-yaml=stack-8.4.3.yaml" ]
#elif MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)

View File

@ -0,0 +1 @@
resolver: lts-12.16

View File

@ -1 +1 @@
resolver: lts-12.16
resolver: nightly-2018-12-21

View File

@ -380,8 +380,10 @@ invokeHelper QueryEnv {..} args = do
getPackageId :: MonadQuery m => m (String, Version)
getPackageId = ask >>= \QueryEnv {..} -> do
[ Just (ChResponseVersion pkgName pkgVer) ] <- readHelper [ "package-id" ]
return (pkgName, pkgVer)
helper <- readHelper [ "package-id" ]
case helper of
[ Just (ChResponseVersion pkgName pkgVer) ] -> return (pkgName, pkgVer)
_ -> error "getPackageId : readHelper"
getSomeConfigState :: MonadQuery m => m SomeLocalBuildInfo
getSomeConfigState = ask >>= \QueryEnv {..} -> do