git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Remove multiple references to --no-prelude
commit6e473edab847820fb1d3b671906429fbe67e8f4b authorPhil Freeman <paf31@cantab.net> dateSun 24 Aug 2014, 17:36 (12 years ago) parent2e0559b
2 files changed+16−21
psc-make/Main.hs+7−10 psc/Main.hs+9−11
psc-make/Main.hs+7−10
@@ -66,9 +66,9 @@ instance P.MonadMake Make where
6666 liftError = either throwError return
6767 progress = makeIO . U.putStrLn
6868
69−compile :: FilePath -> P.Options -> [FilePath] -> IO ()
70−compile outputDir opts input = do
71− modules <- readInput input
69+compile :: FilePath -> [FilePath] -> FilePath -> P.Options -> IO ()
70+compile prelude input outputDir opts = do
71+ modules <- readInput allInputFiles
7272 case modules of
7373 Left err -> do
7474 U.print err
@@ -81,6 +81,9 @@ compile outputDir opts input = do
8181 exitFailure
8282 Right _ -> do
8383 exitSuccess
84+ where
85+ allInputFiles | P.optionsNoPrelude opts = input
86+ | otherwise = prelude : input
8487
8588mkdirp :: FilePath -> IO ()
8689mkdirp = createDirectoryIfMissing True . takeDirectory
@@ -120,14 +123,8 @@ verboseErrors = value $ flag $ (optInfo [ "v", "verbose-errors" ])
120123options :: Term P.Options
121124options = P.Options <$> noPrelude <*> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> pure Nothing <*> noOpts <*> pure Nothing <*> pure [] <*> pure [] <*> verboseErrors
122125
123−inputFilesAndPrelude :: FilePath -> Term [FilePath]
124−inputFilesAndPrelude prelude = combine <$> (not <$> noPrelude) <*> inputFiles
125− where
126− combine True input = prelude : input
127− combine False input = input
128−
129126term :: FilePath -> Term (IO ())
130−term prelude = compile <$> outputDirectory <*> options <*> inputFilesAndPrelude prelude
127+term prelude = compile prelude <$> inputFiles <*> outputDirectory <*> options
131128
132129termInfo :: TermInfo
133130termInfo = defTI
psc/Main.hs+9−11
@@ -44,9 +44,9 @@ readInput (Just input) = fmap collect $ forM input $ \inputFile -> do
4444 collect :: [(FilePath, Either ParseError [P.Module])] -> Either ParseError [(FilePath, P.Module)]
4545 collect = fmap concat . sequence . map (\(fp, e) -> fmap (map ((,) fp)) e)
4646
47−compile :: P.Options -> Maybe [FilePath] -> Maybe FilePath -> Maybe FilePath -> IO ()
48−compile opts input output externs = do
49− modules <- readInput input
47+compile :: FilePath -> P.Options -> Bool -> [FilePath] -> Maybe FilePath -> Maybe FilePath -> IO ()
48+compile prelude opts stdin input output externs = do
49+ modules <- readInput stdInOrInputFiles
5050 case modules of
5151 Left err -> do
5252 U.hPutStr stderr $ show err
@@ -64,6 +64,11 @@ compile opts input output externs = do
6464 Just path -> mkdirp path >> U.writeFile path exts
6565 Nothing -> return ()
6666 exitSuccess
67+ where
68+ stdInOrInputFiles :: Maybe [FilePath]
69+ stdInOrInputFiles | stdin = Nothing
70+ | P.optionsNoPrelude opts = Just input
71+ | otherwise = Just $ prelude : input
6772
6873mkdirp :: FilePath -> IO ()
6974mkdirp = createDirectoryIfMissing True . takeDirectory
@@ -127,15 +132,8 @@ verboseErrors = value $ flag $ (optInfo [ "v", "verbose-errors" ])
127132options :: Term P.Options
128133options = P.Options <$> noPrelude <*> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> runMain <*> noOpts <*> (Just <$> browserNamespace) <*> dceModules <*> codeGenModules <*> verboseErrors
129134
130−stdInOrInputFiles :: FilePath -> Term (Maybe [FilePath])
131−stdInOrInputFiles prelude = combine <$> useStdIn <*> (not <$> noPrelude) <*> inputFiles
132− where
133− combine False True input = Just (prelude : input)
134− combine False False input = Just input
135− combine True _ _ = Nothing
136−
137135term :: FilePath -> Term (IO ())
138−term prelude = compile <$> options <*> stdInOrInputFiles prelude <*> outputFile <*> externsFile
136+term prelude = compile prelude <$> options <*> useStdIn <*> inputFiles <*> outputFile <*> externsFile
139137
140138termInfo :: TermInfo
141139termInfo = defTI