Changing GHCMod as a library.
This commit is contained in:
parent
1977b8858a
commit
bac4bbbcf3
7
Lang.hs
7
Lang.hs
@ -1,7 +0,0 @@
|
|||||||
module Lang where
|
|
||||||
|
|
||||||
import qualified Gap
|
|
||||||
import Types
|
|
||||||
|
|
||||||
listLanguages :: Options -> IO String
|
|
||||||
listLanguages opt = return $ convert opt Gap.supportedExtensions
|
|
27
Language/Haskell/GhcMod.hs
Normal file
27
Language/Haskell/GhcMod.hs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
module Language.Haskell.GhcMod (
|
||||||
|
browseModule
|
||||||
|
, checkSyntax
|
||||||
|
, module Language.Haskell.GhcMod.Cradle
|
||||||
|
, debugInfo
|
||||||
|
, debug
|
||||||
|
, infoExpr
|
||||||
|
, typeExpr
|
||||||
|
, listLanguages
|
||||||
|
, lintSyntax
|
||||||
|
, listModules
|
||||||
|
, module Language.Haskell.GhcMod.Types
|
||||||
|
, listFlags
|
||||||
|
, getGHCVersion
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Language.Haskell.GhcMod.Browse
|
||||||
|
import Language.Haskell.GhcMod.Check
|
||||||
|
import Language.Haskell.GhcMod.Cradle
|
||||||
|
import Language.Haskell.GhcMod.Debug
|
||||||
|
import Language.Haskell.GhcMod.Flag
|
||||||
|
import Language.Haskell.GhcMod.Info
|
||||||
|
import Language.Haskell.GhcMod.Lang
|
||||||
|
import Language.Haskell.GhcMod.Lint
|
||||||
|
import Language.Haskell.GhcMod.List
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
|
import Language.Haskell.GhcMod.CabalApi
|
@ -1,18 +1,18 @@
|
|||||||
module Browse (browseModule) where
|
module Language.Haskell.GhcMod.Browse (browseModule) where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import DataCon (dataConRepType)
|
import DataCon (dataConRepType)
|
||||||
import Doc
|
|
||||||
import GHC
|
import GHC
|
||||||
import GHCApi
|
import Language.Haskell.GhcMod.Doc
|
||||||
|
import Language.Haskell.GhcMod.GHCApi
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
import Name
|
import Name
|
||||||
import Outputable
|
import Outputable
|
||||||
import TyCon
|
import TyCon
|
||||||
import Type
|
import Type
|
||||||
import Types
|
|
||||||
import Var
|
import Var
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
@ -1,6 +1,6 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module CabalApi (
|
module Language.Haskell.GhcMod.CabalApi (
|
||||||
fromCabalFile
|
fromCabalFile
|
||||||
, cabalParseFile
|
, cabalParseFile
|
||||||
, cabalBuildInfo
|
, cabalBuildInfo
|
||||||
@ -22,8 +22,8 @@ import Distribution.Simple.Program.Types (programName, programFindVersion)
|
|||||||
import Distribution.Text (display)
|
import Distribution.Text (display)
|
||||||
import Distribution.Verbosity (silent)
|
import Distribution.Verbosity (silent)
|
||||||
import Distribution.Version (versionBranch)
|
import Distribution.Version (versionBranch)
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import Types
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
@ -1,14 +1,14 @@
|
|||||||
module Check (checkSyntax) where
|
module Language.Haskell.GhcMod.Check (checkSyntax) where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import CoreMonad
|
import CoreMonad
|
||||||
import ErrMsg
|
|
||||||
import Exception
|
import Exception
|
||||||
import GHC
|
import GHC
|
||||||
import GHCApi
|
import Language.Haskell.GhcMod.ErrMsg
|
||||||
|
import Language.Haskell.GhcMod.GHCApi
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
import Prelude
|
import Prelude
|
||||||
import Types
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
module Cradle (findCradle) where
|
module Language.Haskell.GhcMod.Cradle (findCradle) where
|
||||||
|
|
||||||
import Control.Applicative ((<$>))
|
import Control.Applicative ((<$>))
|
||||||
import Control.Exception (throwIO)
|
import Control.Exception (throwIO)
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.List (isSuffixOf)
|
import Data.List (isSuffixOf)
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import System.FilePath ((</>),takeDirectory)
|
import System.FilePath ((</>),takeDirectory)
|
||||||
import Types
|
|
||||||
|
|
||||||
-- An error would be thrown
|
-- An error would be thrown
|
||||||
findCradle :: Maybe FilePath -> String -> IO Cradle
|
findCradle :: Maybe FilePath -> String -> IO Cradle
|
@ -1,15 +1,15 @@
|
|||||||
module Debug (debugInfo, debug) where
|
module Language.Haskell.GhcMod.Debug (debugInfo, debug) where
|
||||||
|
|
||||||
import CabalApi
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Exception.IOChoice
|
import Control.Exception.IOChoice
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.List (intercalate)
|
import Data.List (intercalate)
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import GHC
|
import GHC
|
||||||
import GHCApi
|
import Language.Haskell.GhcMod.CabalApi
|
||||||
|
import Language.Haskell.GhcMod.GHCApi
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
import Prelude
|
import Prelude
|
||||||
import Types
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
module Doc where
|
module Language.Haskell.GhcMod.Doc where
|
||||||
|
|
||||||
import DynFlags (DynFlags)
|
import DynFlags (DynFlags)
|
||||||
import Gap (withStyle)
|
import Language.Haskell.GhcMod.Gap (withStyle)
|
||||||
import Outputable
|
import Outputable
|
||||||
import Pretty
|
import Pretty
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
{-# LANGUAGE BangPatterns #-}
|
{-# LANGUAGE BangPatterns #-}
|
||||||
|
|
||||||
module ErrMsg (
|
module Language.Haskell.GhcMod.ErrMsg (
|
||||||
LogReader
|
LogReader
|
||||||
, setLogger
|
, setLogger
|
||||||
, handleErrMsg
|
, handleErrMsg
|
||||||
@ -10,12 +10,12 @@ import Bag
|
|||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Data.IORef
|
import Data.IORef
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Doc
|
|
||||||
import DynFlags
|
import DynFlags
|
||||||
import ErrUtils
|
import ErrUtils
|
||||||
import GHC
|
import GHC
|
||||||
import qualified Gap
|
|
||||||
import HscTypes
|
import HscTypes
|
||||||
|
import Language.Haskell.GhcMod.Doc
|
||||||
|
import qualified Language.Haskell.GhcMod.Gap as Gap
|
||||||
import Outputable
|
import Outputable
|
||||||
import System.FilePath (normalise)
|
import System.FilePath (normalise)
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Flag where
|
module Language.Haskell.GhcMod.Flag where
|
||||||
|
|
||||||
import Types
|
import qualified Language.Haskell.GhcMod.Gap as Gap
|
||||||
import qualified Gap
|
import Language.Haskell.GhcMod.Types
|
||||||
|
|
||||||
listFlags :: Options -> IO String
|
listFlags :: Options -> IO String
|
||||||
listFlags opt = return $ convert opt [ "-f" ++ prefix ++ option
|
listFlags opt = return $ convert opt [ "-f" ++ prefix ++ option
|
@ -1,6 +1,6 @@
|
|||||||
{-# LANGUAGE ScopedTypeVariables #-}
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
|
||||||
module GHCApi (
|
module Language.Haskell.GhcMod.GHCApi (
|
||||||
withGHC
|
withGHC
|
||||||
, withGHCDummyFile
|
, withGHCDummyFile
|
||||||
, initializeFlags
|
, initializeFlags
|
||||||
@ -12,21 +12,21 @@ module GHCApi (
|
|||||||
, canCheckFast
|
, canCheckFast
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import CabalApi
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import CoreMonad
|
import CoreMonad
|
||||||
import Data.Maybe (isJust)
|
import Data.Maybe (isJust)
|
||||||
import DynFlags
|
import DynFlags
|
||||||
import ErrMsg
|
|
||||||
import Exception
|
import Exception
|
||||||
import GHC
|
import GHC
|
||||||
import GHCChoice
|
|
||||||
import GHC.Paths (libdir)
|
import GHC.Paths (libdir)
|
||||||
|
import Language.Haskell.GhcMod.CabalApi
|
||||||
|
import Language.Haskell.GhcMod.ErrMsg
|
||||||
|
import Language.Haskell.GhcMod.GHCChoice
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import System.IO
|
import System.IO
|
||||||
import Types
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
{-# LANGUAGE ScopedTypeVariables #-}
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
|
||||||
module GHCChoice where
|
module Language.Haskell.GhcMod.GHCChoice where
|
||||||
|
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import CoreMonad
|
import CoreMonad
|
@ -1,7 +1,7 @@
|
|||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Gap (
|
module Language.Haskell.GhcMod.Gap (
|
||||||
Gap.ClsInst
|
Language.Haskell.GhcMod.Gap.ClsInst
|
||||||
, mkTarget
|
, mkTarget
|
||||||
, withStyle
|
, withStyle
|
||||||
, setLogAction
|
, setLogAction
|
||||||
@ -26,7 +26,7 @@ import DynFlags
|
|||||||
import ErrUtils
|
import ErrUtils
|
||||||
import FastString
|
import FastString
|
||||||
import GHC
|
import GHC
|
||||||
import GHCChoice
|
import Language.Haskell.GhcMod.GHCChoice
|
||||||
import Outputable
|
import Outputable
|
||||||
import StringBuffer
|
import StringBuffer
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
{-# LANGUAGE TupleSections, FlexibleInstances, TypeSynonymInstances #-}
|
{-# LANGUAGE TupleSections, FlexibleInstances, TypeSynonymInstances #-}
|
||||||
{-# LANGUAGE Rank2Types #-}
|
{-# LANGUAGE Rank2Types #-}
|
||||||
|
|
||||||
module Info (infoExpr, typeExpr) where
|
module Language.Haskell.GhcMod.Info (infoExpr, typeExpr) where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Monad (void, when)
|
import Control.Monad (void, when)
|
||||||
@ -13,19 +13,19 @@ import Data.Maybe
|
|||||||
import Data.Ord as O
|
import Data.Ord as O
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
import Desugar
|
import Desugar
|
||||||
import Doc
|
|
||||||
import GHC
|
import GHC
|
||||||
import GHC.SYB.Utils
|
import GHC.SYB.Utils
|
||||||
import GHCApi
|
|
||||||
import GHCChoice
|
|
||||||
import qualified Gap
|
|
||||||
import HscTypes
|
import HscTypes
|
||||||
|
import Language.Haskell.GhcMod.Doc
|
||||||
|
import Language.Haskell.GhcMod.GHCApi
|
||||||
|
import Language.Haskell.GhcMod.GHCChoice
|
||||||
|
import qualified Language.Haskell.GhcMod.Gap as Gap
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
import NameSet
|
import NameSet
|
||||||
import Outputable
|
import Outputable
|
||||||
import PprTyThing
|
import PprTyThing
|
||||||
import TcHsSyn (hsPatType)
|
import TcHsSyn (hsPatType)
|
||||||
import TcRnTypes
|
import TcRnTypes
|
||||||
import Types
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ instance HasType (LPat Id) where
|
|||||||
getType _ (L spn pat) = return $ Just (spn, hsPatType pat)
|
getType _ (L spn pat) = return $ Just (spn, hsPatType pat)
|
||||||
|
|
||||||
typeExpr :: Options -> Cradle -> ModuleString -> Int -> Int -> FilePath -> IO String
|
typeExpr :: Options -> Cradle -> ModuleString -> Int -> Int -> FilePath -> IO String
|
||||||
typeExpr opt cradle modstr lineNo colNo file = Info.typeOf opt cradle file modstr lineNo colNo
|
typeExpr opt cradle modstr lineNo colNo file = Language.Haskell.GhcMod.Info.typeOf opt cradle file modstr lineNo colNo
|
||||||
|
|
||||||
typeOf :: Options -> Cradle -> FilePath -> ModuleString -> Int -> Int -> IO String
|
typeOf :: Options -> Cradle -> FilePath -> ModuleString -> Int -> Int -> IO String
|
||||||
typeOf opt cradle fileName modstr lineNo colNo =
|
typeOf opt cradle fileName modstr lineNo colNo =
|
7
Language/Haskell/GhcMod/Lang.hs
Normal file
7
Language/Haskell/GhcMod/Lang.hs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module Language.Haskell.GhcMod.Lang where
|
||||||
|
|
||||||
|
import qualified Language.Haskell.GhcMod.Gap as Gap
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
|
|
||||||
|
listLanguages :: Options -> IO String
|
||||||
|
listLanguages opt = return $ convert opt Gap.supportedExtensions
|
@ -1,9 +1,9 @@
|
|||||||
module Lint where
|
module Language.Haskell.GhcMod.Lint where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Data.List
|
import Data.List
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
import Language.Haskell.HLint
|
import Language.Haskell.HLint
|
||||||
import Types
|
|
||||||
|
|
||||||
lintSyntax :: Options -> String -> IO String
|
lintSyntax :: Options -> String -> IO String
|
||||||
lintSyntax opt file = pack <$> lint opt file
|
lintSyntax opt file = pack <$> lint opt file
|
@ -1,11 +1,11 @@
|
|||||||
module List (listModules) where
|
module Language.Haskell.GhcMod.List (listModules) where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Data.List
|
import Data.List
|
||||||
import GHC
|
import GHC
|
||||||
import GHCApi
|
import Language.Haskell.GhcMod.GHCApi
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
import Packages
|
import Packages
|
||||||
import Types
|
|
||||||
import UniqFM
|
import UniqFM
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
@ -1,6 +1,6 @@
|
|||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
|
|
||||||
module Types where
|
module Language.Haskell.GhcMod.Types where
|
||||||
|
|
||||||
data OutputStyle = LispStyle | PlainStyle
|
data OutputStyle = LispStyle | PlainStyle
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
Name: ghc-mod
|
Name: ghc-mod
|
||||||
Version: 1.12.5
|
Version: 2.0.0
|
||||||
Author: Kazu Yamamoto <kazu@iij.ad.jp>
|
Author: Kazu Yamamoto <kazu@iij.ad.jp>
|
||||||
Maintainer: Kazu Yamamoto <kazu@iij.ad.jp>
|
Maintainer: Kazu Yamamoto <kazu@iij.ad.jp>
|
||||||
License: BSD3
|
License: BSD3
|
||||||
@ -37,27 +37,27 @@ Extra-Source-Files: ChangeLog
|
|||||||
test/data/check-test-subdir/test/*.hs
|
test/data/check-test-subdir/test/*.hs
|
||||||
test/data/check-test-subdir/test/Bar/*.hs
|
test/data/check-test-subdir/test/Bar/*.hs
|
||||||
test/data/check-test-subdir/src/Check/Test/*.hs
|
test/data/check-test-subdir/src/Check/Test/*.hs
|
||||||
Executable ghc-mod
|
|
||||||
|
Library
|
||||||
Default-Language: Haskell2010
|
Default-Language: Haskell2010
|
||||||
Main-Is: GHCMod.hs
|
|
||||||
Other-Modules: Browse
|
|
||||||
CabalApi
|
|
||||||
Check
|
|
||||||
Cradle
|
|
||||||
Doc
|
|
||||||
Debug
|
|
||||||
ErrMsg
|
|
||||||
Flag
|
|
||||||
GHCApi
|
|
||||||
GHCChoice
|
|
||||||
Gap
|
|
||||||
Info
|
|
||||||
Lang
|
|
||||||
Lint
|
|
||||||
List
|
|
||||||
Paths_ghc_mod
|
|
||||||
Types
|
|
||||||
GHC-Options: -Wall
|
GHC-Options: -Wall
|
||||||
|
Exposed-Modules: Language.Haskell.GhcMod
|
||||||
|
Other-Modules: Language.Haskell.GhcMod.Browse
|
||||||
|
Language.Haskell.GhcMod.CabalApi
|
||||||
|
Language.Haskell.GhcMod.Check
|
||||||
|
Language.Haskell.GhcMod.Cradle
|
||||||
|
Language.Haskell.GhcMod.Doc
|
||||||
|
Language.Haskell.GhcMod.Debug
|
||||||
|
Language.Haskell.GhcMod.ErrMsg
|
||||||
|
Language.Haskell.GhcMod.Flag
|
||||||
|
Language.Haskell.GhcMod.GHCApi
|
||||||
|
Language.Haskell.GhcMod.GHCChoice
|
||||||
|
Language.Haskell.GhcMod.Gap
|
||||||
|
Language.Haskell.GhcMod.Info
|
||||||
|
Language.Haskell.GhcMod.Lang
|
||||||
|
Language.Haskell.GhcMod.Lint
|
||||||
|
Language.Haskell.GhcMod.List
|
||||||
|
Language.Haskell.GhcMod.Types
|
||||||
Build-Depends: base >= 4.0 && < 5
|
Build-Depends: base >= 4.0 && < 5
|
||||||
, Cabal >= 1.10
|
, Cabal >= 1.10
|
||||||
, containers
|
, containers
|
||||||
@ -75,6 +75,18 @@ Executable ghc-mod
|
|||||||
, time
|
, time
|
||||||
, transformers
|
, transformers
|
||||||
|
|
||||||
|
Executable ghc-mod
|
||||||
|
Default-Language: Haskell2010
|
||||||
|
Main-Is: GHCMod.hs
|
||||||
|
Other-Modules: Paths_ghc_mod
|
||||||
|
GHC-Options: -Wall
|
||||||
|
HS-Source-Dirs: src
|
||||||
|
Build-Depends: base >= 4.0 && < 5
|
||||||
|
, directory
|
||||||
|
, filepath
|
||||||
|
, ghc
|
||||||
|
, ghc-mod
|
||||||
|
|
||||||
Test-Suite spec
|
Test-Suite spec
|
||||||
Default-Language: Haskell2010
|
Default-Language: Haskell2010
|
||||||
Main-Is: Spec.hs
|
Main-Is: Spec.hs
|
||||||
|
@ -2,27 +2,17 @@
|
|||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Browse
|
|
||||||
import CabalApi
|
|
||||||
import Check
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Cradle
|
|
||||||
import Data.Typeable
|
import Data.Typeable
|
||||||
import Data.Version
|
import Data.Version
|
||||||
import Debug
|
import Language.Haskell.GhcMod
|
||||||
import Flag
|
|
||||||
import Info
|
|
||||||
import Lang
|
|
||||||
import Lint
|
|
||||||
import List
|
|
||||||
import Paths_ghc_mod
|
import Paths_ghc_mod
|
||||||
import Prelude
|
import Prelude
|
||||||
import System.Console.GetOpt
|
import System.Console.GetOpt
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import System.Environment (getArgs)
|
import System.Environment (getArgs)
|
||||||
import System.IO (hPutStr, hPutStrLn, stdout, stderr, hSetEncoding, utf8)
|
import System.IO (hPutStr, hPutStrLn, stdout, stderr, hSetEncoding, utf8)
|
||||||
import Types
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user