From fc7ce47e93c766ee87022db1e14eaf2768632e11 Mon Sep 17 00:00:00 2001 From: klapaucius Date: Fri, 19 Sep 2014 17:29:42 +0600 Subject: [PATCH] fix for varid bug in showExports & processExports --- Language/Haskell/GhcMod/Browse.hs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Language/Haskell/GhcMod/Browse.hs b/Language/Haskell/GhcMod/Browse.hs index 7ff0d17..b5fc4aa 100644 --- a/Language/Haskell/GhcMod/Browse.hs +++ b/Language/Haskell/GhcMod/Browse.hs @@ -61,13 +61,23 @@ splitPkgMdl pkgmdl = case break (==':') pkgmdl of (mdl,"") -> (Nothing,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 minfo = do opt <- options let removeOps | operators opt = id - | otherwise = filter (isAlpha . head . getOccString) + | otherwise = filter (isNotOp . getOccString) mapM (showExport opt minfo) $ removeOps $ G.modInfoExports minfo showExport :: IOish m => Options -> ModuleInfo -> Name -> GhcModT m String @@ -87,10 +97,10 @@ showExport opt minfo e = do typeName <- tyResult >>= showThing dflag (" :: " ++ typeName) `justIf` detailed opt | otherwise = return Nothing - formatOp nm@(n:_) - | isAlpha n = nm - | otherwise = "(" ++ nm ++ ")" - formatOp "" = error "formatOp" + formatOp nm + | null nm = error "formatOp" + | isNotOp nm = nm + | otherwise = "(" ++ nm ++ ")" inOtherModule :: IOish m => Name -> GhcModT m (Maybe TyThing) inOtherModule nm = G.getModuleInfo (G.nameModule nm) >> G.lookupGlobalName nm justIf :: a -> Bool -> Maybe a