ghc-mod 1.0.8 → 1.10.0
raw patch · 5 files changed
+41/−47 lines, 5 filesdep +Cabaldep −attoparsecdep −attoparsec-enumeratordep −enumerator
Dependencies added: Cabal
Dependencies removed: attoparsec, attoparsec-enumerator, enumerator
Files
- Cabal.hs +20/−23
- CabalDev.hs +17/−19
- Check.hs +1/−1
- elisp/ghc.el +1/−1
- ghc-mod.cabal +2/−3
Cabal.hs view
@@ -1,14 +1,14 @@ {-# LANGUAGE OverloadedStrings #-}+ module Cabal (initializeGHC) where import Control.Applicative import Control.Monad import CoreMonad-import Data.Attoparsec.ByteString.Char8-import Data.Attoparsec.Enumerator-import Data.Enumerator (run, ($$))-import Data.Enumerator.Binary (enumFile) import Data.List+import Distribution.PackageDescription+import Distribution.PackageDescription.Parse (readPackageDescription)+import Distribution.Verbosity (silent) import ErrMsg import GHC import System.Directory@@ -31,31 +31,28 @@ midirs <- parseCabalFile cfile changeToCabalDirectory cdir let idirs = case midirs of- Nothing -> [cdir,owdir]- Just dirs -> dirs ++ [owdir]+ [] -> [cdir,owdir]+ dirs -> dirs ++ [owdir] file = ajustFileName fileName owdir cdir logReader <- initSession opt ghcOptions idirs logging return (file,logReader) ---------------------------------------------------------------- -parseCabalFile :: FilePath -> Ghc (Maybe [String])-parseCabalFile file = liftIO $ do- res <- run (enumFile file $$ iterParser findTarget)- case res of- Right x -> return x- Left e -> error (show e)--findTarget :: Parser (Maybe [String])-findTarget = Just <$> hs_source_dirs- <|> (anyChar >> findTarget)- <|> Nothing <$ endOfInput--hs_source_dirs :: Parser [String]-hs_source_dirs = do- stringCI "hs-source-dirs:"- many (char ' ')- sepBy1 (many . satisfy $ notInClass " ,\n") (many1 . satisfy $ inClass " ,")+parseCabalFile :: FilePath -> Ghc [String]+parseCabalFile file = do+ cabal <- liftIO $ readPackageDescription silent file+ return $ fromLibrary cabal ||| fromExecutable cabal+ where+ [] ||| y = y+ x ||| _ = x+ fromLibrary c = case condLibrary c of+ Nothing -> []+ Just lib -> libHsSourceDir lib+ libHsSourceDir = hsSourceDirs . libBuildInfo . condTreeData+ fromExecutable = execHsSrouceDir . condExecutables+ execHsSrouceDir [] = []+ execHsSrouceDir (x:_) = hsSourceDirs . buildInfo . condTreeData . snd $ x ----------------------------------------------------------------
CabalDev.hs view
@@ -1,10 +1,8 @@-{-# LANGUAGE DoAndIfThenElse #-}- module CabalDev (modifyOptions) where {--If the directory 'cabal-dev/packages-X.X.X.conf' exists, add it to the-options ghc-mod uses to check the source. Otherwise just pass it on.+ If the directory 'cabal-dev/packages-X.X.X.conf' exists, add it to the+ options ghc-mod uses to check the source. Otherwise just pass it on. -} import Control.Applicative ((<$>))@@ -17,33 +15,33 @@ modifyOptions :: Options -> IO Options modifyOptions opts =- fmap (has_cdev opts) findCabalDev- where- has_cdev :: Options -> Maybe String -> Options- has_cdev op Nothing = op- has_cdev op (Just path) = addPath op path+ fmap (has_cdev opts) findCabalDev+ where+ has_cdev :: Options -> Maybe String -> Options+ has_cdev op Nothing = op+ has_cdev op (Just path) = addPath op path findCabalDev :: IO (Maybe String) findCabalDev =- getCurrentDirectory >>= searchIt . splitPath+ getCurrentDirectory >>= searchIt . splitPath addPath :: Options -> String -> Options addPath orig_opts path = do- let orig_ghcopt = ghcOpts orig_opts- orig_opts { ghcOpts = orig_ghcopt ++ ["-package-conf", path] }+ let orig_ghcopt = ghcOpts orig_opts+ orig_opts { ghcOpts = orig_ghcopt ++ ["-package-conf", path] } searchIt :: [FilePath] -> IO (Maybe FilePath) searchIt [] = return Nothing searchIt path = do- a <- doesDirectoryExist (mpath path)- if a then do- findConf (mpath path)- else- searchIt $ init path+ a <- doesDirectoryExist (mpath path)+ if a then do+ findConf (mpath path)+ else+ searchIt $ init path where mpath a = joinPath a </> "cabal-dev/" findConf :: FilePath -> IO (Maybe FilePath) findConf path = do- f <- find (=~ "packages.*\\.conf") <$> getDirectoryContents path- return $ ((path </>) <$> f)+ f <- find (=~ "packages.*\\.conf") <$> getDirectoryContents path+ return $ ((path </>) <$> f)
Check.hs view
@@ -25,4 +25,4 @@ setTargetFile file load LoadAllTargets liftIO readLog- options = ["-Wall","-fno-warn-unused-do-bind"] ++ ghcOpts opt+ options = ["-Wall","-fno-warn-unused-do-bind", "-XHaskell98"] ++ ghcOpts opt
elisp/ghc.el view
@@ -16,7 +16,7 @@ ;;; Code: -(defconst ghc-version "1.0.8")+(defconst ghc-version "1.10.0") ;; (eval-when-compile ;; (require 'haskell-mode))
ghc-mod.cabal view
@@ -1,5 +1,5 @@ Name: ghc-mod-Version: 1.0.8+Version: 1.10.0 Author: Kazu Yamamoto <kazu@iij.ad.jp> Maintainer: Kazu Yamamoto <kazu@iij.ad.jp> License: BSD3@@ -30,8 +30,7 @@ GHC-Options: -Wall Build-Depends: base >= 4.0 && < 5, ghc, ghc-paths, transformers, process, directory, filepath, old-time,- hlint >= 1.7.1, regex-posix,- attoparsec >= 0.10 , enumerator, attoparsec-enumerator+ hlint >= 1.7.1, regex-posix, Cabal Source-Repository head Type: git Location: git://github.com/kazu-yamamoto/ghc-mod.git