Commit 3eb4ad80 authored by Björn Peemöller 's avatar Björn Peemöller
Browse files

Merge branch 'master' of /home/bjp/public_html/repos/curry-frontend

parents bd710062 7cac53e1
......@@ -15,6 +15,7 @@
-}
module CurryBuilder (buildCurry, smake) where
import qualified Control.Exception as C (SomeException (..), catch)
import Control.Monad (liftM)
import Data.Maybe (catMaybes, mapMaybe)
import System.Time (ClockTime)
......@@ -121,7 +122,8 @@ smake dests deps actOutdated actUpToDate = do
outOfDate tgtimes dptimes = or [ tg < dp | tg <- tgtimes, dp <- dptimes]
abortOnError :: IO a -> IO a
abortOnError act = catch act (\ err -> abortWith [show err])
abortOnError act = C.catch act handler
where handler (C.SomeException e) = abortWith [show e]
errMissingFile :: FilePath -> String
errMissingFile f = "Missing file \"" ++ f ++ "\""
\ No newline at end of file
......@@ -32,7 +32,7 @@ import Curry.Base.Ident
import Curry.Base.MessageMonad
import Curry.Files.Filenames
import Curry.Files.PathUtils
import Curry.Syntax (Module (..), ImportDecl (..), parseHeader)
import Curry.Syntax (Module (..), ImportDecl (..), parseHeader, patchModuleId)
import Base.Messages (internalError)
import Base.SCC (scc)
......@@ -86,7 +86,7 @@ targetDeps opts paths sEnv fn = do
-- |Retrieve the dependencies of a given source file
sourceDeps :: Options -> [FilePath] -> SourceEnv -> FilePath -> IO SourceEnv
sourceDeps opts paths sEnv fn = do
hdr <- (ok . parseHeader fn) `liftM` readModule fn
hdr <- patchModuleId fn `liftM` (ok . parseHeader fn) `liftM` readModule fn
moduleDeps opts paths sEnv fn hdr
-- |Retrieve the dependencies of a given module
......@@ -120,7 +120,8 @@ moduleIdentDeps opts paths sEnv m = case Map.lookup m sEnv of
where
libraryPaths = optImportPaths opts
checkModuleHeader fn = do
hdr@(Module m' _ _ _) <- (ok . parseHeader fn) `liftM` readModule fn
hdr@(Module m' _ _ _) <- patchModuleId fn `liftM` (ok . parseHeader fn)
`liftM` readModule fn
unless (m == m') $ error $ errWrongModule m m'
moduleDeps opts paths sEnv fn hdr
......@@ -149,7 +150,6 @@ flattenDeps = fdeps . sortDeps
errWrongModule :: ModuleIdent -> ModuleIdent -> String
errWrongModule m m' =
"Expected module for " ++ show m ++ " but found " ++ show m'
++ show (moduleQualifiers m, moduleQualifiers m')
errCyclicImport :: [ModuleIdent] -> String
errCyclicImport [] = internalError "CurryDeps.errCyclicImport: empty list"
......
......@@ -114,7 +114,7 @@ loadModule opts fn = do
checkModuleHeader :: Options -> FilePath -> CS.Module -> (CS.Module, [String])
checkModuleHeader opts fn = checkModuleId fn
. importPrelude opts
. patchModuleId fn
. CS.patchModuleId fn
-- |Check whether the 'ModuleIdent' and the 'FilePath' fit together
checkModuleId :: FilePath -> CS.Module -> (CS.Module, [String])
......@@ -147,17 +147,6 @@ importPrelude opts m@(CS.Module mid es is ds)
Nothing -- no selection of types, functions, etc.
imported = [imp | (CS.ImportDecl _ imp _ _ _) <- is]
-- A module which doesn't contain a \texttt{module ... where} declaration
-- obtains its filename as module identifier (unlike the definition in
-- Haskell and original MCC where a module obtains \texttt{main}).
patchModuleId :: FilePath -> CS.Module -> CS.Module
patchModuleId fn m@(CS.Module mid es is ds)
| mid == mainMIdent
= CS.Module (mkMIdent [takeBaseName fn]) es is ds
| otherwise
= m
-- ---------------------------------------------------------------------------
-- Checking a module
-- ---------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment