hlint suggestions.

This commit is contained in:
Kazu Yamamoto 2014-08-14 11:11:02 +09:00
parent 4090b301f7
commit 2875275fc0
5 changed files with 19 additions and 20 deletions

View File

@ -76,7 +76,7 @@ parseCabalFile :: (MonadIO m, Error e, MonadError e m)
=> FilePath => FilePath
-> m PackageDescription -> m PackageDescription
parseCabalFile file = do parseCabalFile file = do
cid <- liftIO $ getGHCId cid <- liftIO getGHCId
epgd <- liftIO $ readPackageDescription silent file epgd <- liftIO $ readPackageDescription silent file
case toPkgDesc cid epgd of case toPkgDesc cid epgd of
Left deps -> fail $ show deps ++ " are not installed" Left deps -> fail $ show deps ++ " are not installed"

View File

@ -36,7 +36,7 @@ checkSyntax files = withErrorHandler sessionName $
check :: IOish m check :: IOish m
=> [FilePath] -- ^ The target files. => [FilePath] -- ^ The target files.
-> GhcModT m (Either String String) -> GhcModT m (Either String String)
check fileNames = overrideGhcUserOptions $ \ghcOpts -> do check fileNames = overrideGhcUserOptions $ \ghcOpts ->
withLogger (setAllWaringFlags . setNoMaxRelevantBindings) $ do withLogger (setAllWaringFlags . setNoMaxRelevantBindings) $ do
_ <- G.setSessionDynFlags =<< addCmdOpts ghcOpts =<< G.getSessionDynFlags _ <- G.setSessionDynFlags =<< addCmdOpts ghcOpts =<< G.getSessionDynFlags
setTargetFiles fileNames setTargetFiles fileNames

View File

@ -118,11 +118,11 @@ getSignature modSum lineNo colNo = do
G.DataFamily -> Data G.DataFamily -> Data
#endif #endif
#if __GLASGOW_HASKELL__ >= 706 #if __GLASGOW_HASKELL__ >= 706
getTyFamVarName = \x -> case x of getTyFamVarName x = case x of
L _ (G.UserTyVar n) -> n L _ (G.UserTyVar n) -> n
L _ (G.KindedTyVar n _) -> n L _ (G.KindedTyVar n _) -> n
#else #else
getTyFamVarName = \x -> case x of -- In GHC 7.4, HsTyVarBndr's have an extra arg getTyFamVarName x = case x of -- In GHC 7.4, HsTyVarBndr's have an extra arg
L _ (G.UserTyVar n _) -> n L _ (G.UserTyVar n _) -> n
L _ (G.KindedTyVar n _ _) -> n L _ (G.KindedTyVar n _ _) -> n
#endif #endif
@ -169,7 +169,7 @@ initialBody' fname args = initialHead fname args ++ " = "
initialFamBody :: FnArgsInfo ty name => DynFlags -> PprStyle -> name -> [name] -> String initialFamBody :: FnArgsInfo ty name => DynFlags -> PprStyle -> name -> [name] -> String
initialFamBody dflag style name args = initialHead (getFnName dflag style name) initialFamBody dflag style name args = initialHead (getFnName dflag style name)
(map (\arg -> FnExplicitName (getFnName dflag style arg)) args) (map (FnExplicitName . getFnName dflag style) args)
++ " = ()" ++ " = ()"
initialHead :: String -> [FnArg] -> String initialHead :: String -> [FnArg] -> String
@ -298,7 +298,7 @@ findVar dflag style tcm tcs lineNo colNo =
then let Just (s,t) = tyInfo then let Just (s,t) = tyInfo
b = case others of -- If inside an App, we need parenthesis b = case others of -- If inside an App, we need parenthesis
[] -> False [] -> False
(L _ (G.HsApp (L _ a1) (L _ a2))):_ -> L _ (G.HsApp (L _ a1) (L _ a2)):_ ->
isSearchedVar i a1 || isSearchedVar i a2 isSearchedVar i a1 || isSearchedVar i a2
_ -> False _ -> False
in return $ Just (s, name, t, b) in return $ Just (s, name, t, b)
@ -339,9 +339,9 @@ auto file lineNo colNo = ghandle handler body
topLevel <- getEverythingInTopLevel minfo topLevel <- getEverythingInTopLevel minfo
let (f,pats) = getPatsForVariable tcs (lineNo,colNo) let (f,pats) = getPatsForVariable tcs (lineNo,colNo)
-- Remove self function to prevent recursion, and id to trim cases -- Remove self function to prevent recursion, and id to trim cases
filterFn = (\(n,_) -> let funName = G.getOccString n filterFn (n,_) = let funName = G.getOccString n
recName = G.getOccString (G.getName f) recName = G.getOccString (G.getName f)
in not $ funName `elem` recName:notWantedFuns) in funName `notElem` recName:notWantedFuns
-- Find without using other functions in top-level -- Find without using other functions in top-level
localBnds = M.unions $ map (\(L _ pat) -> getBindingsForPat pat) pats localBnds = M.unions $ map (\(L _ pat) -> getBindingsForPat pat) pats
lbn = filter filterFn (M.toList localBnds) lbn = filter filterFn (M.toList localBnds)

View File

@ -1,4 +1,4 @@
{-# LANGUAGE CPP, BangPatterns #-} {-# LANGUAGE CPP #-}
module Language.Haskell.GhcMod.Find module Language.Haskell.GhcMod.Find
#ifndef SPEC #ifndef SPEC
@ -150,7 +150,7 @@ dumpSymbol = do
writeSymbolCache :: FilePath writeSymbolCache :: FilePath
-> [(Symbol,[ModuleString])] -> [(Symbol,[ModuleString])]
-> IO () -> IO ()
writeSymbolCache cache sm = do writeSymbolCache cache sm =
void . withFile cache WriteMode $ \hdl -> void . withFile cache WriteMode $ \hdl ->
mapM (hPrint hdl) sm mapM (hPrint hdl) sm

View File

@ -1,7 +1,6 @@
{-# LANGUAGE CPP, GeneralizedNewtypeDeriving, FlexibleInstances #-} {-# LANGUAGE CPP, GeneralizedNewtypeDeriving, FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts, MultiParamTypeClasses, RankNTypes #-} {-# LANGUAGE FlexibleContexts, MultiParamTypeClasses, RankNTypes #-}
{-# LANGUAGE TypeFamilies, UndecidableInstances, RecordWildCards #-} {-# LANGUAGE TypeFamilies, UndecidableInstances, RecordWildCards #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
module Language.Haskell.GhcMod.Monad ( module Language.Haskell.GhcMod.Monad (
@ -167,7 +166,7 @@ instance MonadTrans GhcModT where
lift = GhcModT . lift . lift . lift . lift lift = GhcModT . lift . lift . lift . lift
instance MonadState s m => MonadState s (GhcModT m) where instance MonadState s m => MonadState s (GhcModT m) where
get = GhcModT $ lift $ lift $ lift $ get get = GhcModT $ lift $ lift $ lift get
put = GhcModT . lift . lift . lift . put put = GhcModT . lift . lift . lift . put
state = GhcModT . lift . lift . lift . state state = GhcModT . lift . lift . lift . state
@ -271,9 +270,9 @@ runGhcModT' :: IOish m
-> m (Either GhcModError (a, GhcModState), GhcModLog) -> m (Either GhcModError (a, GhcModState), GhcModLog)
runGhcModT' r s a = do runGhcModT' r s a = do
(res, w') <- (res, w') <-
flip runReaderT r $ runJournalT $ runErrorT $ flip runStateT s flip runReaderT r $ runJournalT $ runErrorT $
$ (unGhcModT $ initGhcMonad (Just libdir) >> a) runStateT (unGhcModT $ initGhcMonad (Just libdir) >> a) s
return $ (res, w') return (res, w')
---------------------------------------------------------------- ----------------------------------------------------------------
withErrorHandler :: IOish m => String -> GhcModT m a -> GhcModT m a withErrorHandler :: IOish m => String -> GhcModT m a -> GhcModT m a