Merge remote-tracking branch 'kazu/master'
This commit is contained in:
commit
9b38818f66
@ -34,7 +34,7 @@ import Name (getOccString)
|
|||||||
import System.Directory (doesDirectoryExist, getAppUserDataDirectory, doesFileExist, getModificationTime)
|
import System.Directory (doesDirectoryExist, getAppUserDataDirectory, doesFileExist, getModificationTime)
|
||||||
import System.FilePath ((</>), takeDirectory)
|
import System.FilePath ((</>), takeDirectory)
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Environment (getExecutablePath)
|
import System.Environment
|
||||||
|
|
||||||
#ifndef MIN_VERSION_containers
|
#ifndef MIN_VERSION_containers
|
||||||
#define MIN_VERSION_containers(x,y,z) 1
|
#define MIN_VERSION_containers(x,y,z) 1
|
||||||
@ -90,11 +90,18 @@ loadSymbolDb = SymbolDb <$> readSymbolDb
|
|||||||
ghcModExecutable :: IO FilePath
|
ghcModExecutable :: IO FilePath
|
||||||
#ifndef SPEC
|
#ifndef SPEC
|
||||||
ghcModExecutable = do
|
ghcModExecutable = do
|
||||||
dir <- takeDirectory <$> getExecutablePath
|
dir <- getExecutablePath'
|
||||||
return $ dir </> "ghc-mod"
|
return $ dir </> "ghc-mod"
|
||||||
#else
|
#else
|
||||||
ghcModExecutable = return "dist/build/ghc-mod/ghc-mod"
|
ghcModExecutable = return "dist/build/ghc-mod/ghc-mod"
|
||||||
#endif
|
#endif
|
||||||
|
where
|
||||||
|
getExecutablePath' :: IO FilePath
|
||||||
|
# if __GLASGOW_HASKELL__ >= 706
|
||||||
|
getExecutablePath' = takeDirectory <$> getExecutablePath
|
||||||
|
# else
|
||||||
|
getExecutablePath' = return ""
|
||||||
|
# endif
|
||||||
|
|
||||||
readSymbolDb :: IO (Map Symbol [ModuleString])
|
readSymbolDb :: IO (Map Symbol [ModuleString])
|
||||||
readSymbolDb = handle (\(SomeException _) -> return M.empty) $ do
|
readSymbolDb = handle (\(SomeException _) -> return M.empty) $ do
|
||||||
|
@ -127,10 +127,22 @@ instance Error GhcModError where
|
|||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
||||||
|
-- | A constraint alias (-XConstraintKinds) to make functions dealing with
|
||||||
|
-- 'GhcModT' somewhat cleaner.
|
||||||
|
--
|
||||||
|
-- Basicially an @IOish m => m@ is a 'Monad' supporting arbitrary 'IO' and
|
||||||
|
-- exception handling. Usually this will simply be 'IO' but we parametrise it in
|
||||||
|
-- the exported API so users have the option to use a custom underlying monad.
|
||||||
type IOish m = (Functor m, MonadIO m, MonadBaseControl IO m)
|
type IOish m = (Functor m, MonadIO m, MonadBaseControl IO m)
|
||||||
|
|
||||||
type GhcMod a = GhcModT (ErrorT GhcModError IO) a
|
type GhcMod a = GhcModT (ErrorT GhcModError IO) a
|
||||||
|
|
||||||
|
-- | The GhcMod monad transformer data type. This is basically a wrapper around
|
||||||
|
-- RWST with custom instances for 'GhcMonad' and it's constraints.
|
||||||
|
--
|
||||||
|
-- The inner monad should have instances for 'MonadIO' and 'MonadBaseControl'
|
||||||
|
-- 'IO'. Most @mtl@ monads already have 'MonadBaseControl' 'IO' instances, see
|
||||||
|
-- the @monad-control@ package.
|
||||||
newtype GhcModT m a = GhcModT {
|
newtype GhcModT m a = GhcModT {
|
||||||
unGhcModT :: RWST GhcModEnv GhcModWriter GhcModState m a
|
unGhcModT :: RWST GhcModEnv GhcModWriter GhcModState m a
|
||||||
} deriving (Functor
|
} deriving (Functor
|
||||||
|
Loading…
Reference in New Issue
Block a user