fix for varid bug in showExports & processExports
This commit is contained in:
parent
f023f4fc06
commit
fc7ce47e93
@ -61,13 +61,23 @@ splitPkgMdl pkgmdl = case break (==':') pkgmdl of
|
|||||||
(mdl,"") -> (Nothing,mdl)
|
(mdl,"") -> (Nothing,mdl)
|
||||||
(pkg,_:mdl) -> (Just pkg,mdl)
|
(pkg,_:mdl) -> (Just pkg,mdl)
|
||||||
|
|
||||||
|
-- Haskell 2010:
|
||||||
|
-- small -> ascSmall | uniSmall | _
|
||||||
|
-- ascSmall -> a | b | ... | z
|
||||||
|
-- uniSmall -> any Unicode lowercase letter
|
||||||
|
-- varid -> (small {small | large | digit | ' })
|
||||||
|
|
||||||
|
isNotOp :: String -> Bool
|
||||||
|
isNotOp (h:_) = isAlpha h || (h == '_')
|
||||||
|
isNotOp _ = error "isNotOp"
|
||||||
|
|
||||||
processExports :: IOish m => ModuleInfo -> GhcModT m [String]
|
processExports :: IOish m => ModuleInfo -> GhcModT m [String]
|
||||||
processExports minfo = do
|
processExports minfo = do
|
||||||
opt <- options
|
opt <- options
|
||||||
let
|
let
|
||||||
removeOps
|
removeOps
|
||||||
| operators opt = id
|
| operators opt = id
|
||||||
| otherwise = filter (isAlpha . head . getOccString)
|
| otherwise = filter (isNotOp . getOccString)
|
||||||
mapM (showExport opt minfo) $ removeOps $ G.modInfoExports minfo
|
mapM (showExport opt minfo) $ removeOps $ G.modInfoExports minfo
|
||||||
|
|
||||||
showExport :: IOish m => Options -> ModuleInfo -> Name -> GhcModT m String
|
showExport :: IOish m => Options -> ModuleInfo -> Name -> GhcModT m String
|
||||||
@ -87,10 +97,10 @@ showExport opt minfo e = do
|
|||||||
typeName <- tyResult >>= showThing dflag
|
typeName <- tyResult >>= showThing dflag
|
||||||
(" :: " ++ typeName) `justIf` detailed opt
|
(" :: " ++ typeName) `justIf` detailed opt
|
||||||
| otherwise = return Nothing
|
| otherwise = return Nothing
|
||||||
formatOp nm@(n:_)
|
formatOp nm
|
||||||
| isAlpha n = nm
|
| null nm = error "formatOp"
|
||||||
| otherwise = "(" ++ nm ++ ")"
|
| isNotOp nm = nm
|
||||||
formatOp "" = error "formatOp"
|
| otherwise = "(" ++ nm ++ ")"
|
||||||
inOtherModule :: IOish m => Name -> GhcModT m (Maybe TyThing)
|
inOtherModule :: IOish m => Name -> GhcModT m (Maybe TyThing)
|
||||||
inOtherModule nm = G.getModuleInfo (G.nameModule nm) >> G.lookupGlobalName nm
|
inOtherModule nm = G.getModuleInfo (G.nameModule nm) >> G.lookupGlobalName nm
|
||||||
justIf :: a -> Bool -> Maybe a
|
justIf :: a -> Bool -> Maybe a
|
||||||
|
Loading…
Reference in New Issue
Block a user