git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Remove multiple references to --no-prelude
6e473edPhil Freeman
psc-make/Main.hs+7−10
@@ -66,9 +66,9 @@ instance P.MonadMake Make where
66 liftError = either throwError return
66 liftError = either throwError return
67 progress = makeIO . U.putStrLn
67 progress = makeIO . U.putStrLn
68
68
69−compile :: FilePath -> P.Options -> [FilePath] -> IO ()
69+compile :: FilePath -> [FilePath] -> FilePath -> P.Options -> IO ()
70−compile outputDir opts input = do
70+compile prelude input outputDir opts = do
71− modules <- readInput input
71+ modules <- readInput allInputFiles
72 case modules of
72 case modules of
73 Left err -> do
73 Left err -> do
74 U.print err
74 U.print err
@@ -81,6 +81,9 @@ compile outputDir opts input = do
81 exitFailure
81 exitFailure
82 Right _ -> do
82 Right _ -> do
83 exitSuccess
83 exitSuccess
84+ where
85+ allInputFiles | P.optionsNoPrelude opts = input
86+ | otherwise = prelude : input
84
87
85mkdirp :: FilePath -> IO ()
88mkdirp :: FilePath -> IO ()
86mkdirp = createDirectoryIfMissing True . takeDirectory
89mkdirp = createDirectoryIfMissing True . takeDirectory
@@ -120,14 +123,8 @@ verboseErrors = value $ flag $ (optInfo [ "v", "verbose-errors" ])
120options :: Term P.Options
123options :: Term P.Options
121options = P.Options <$> noPrelude <*> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> pure Nothing <*> noOpts <*> pure Nothing <*> pure [] <*> pure [] <*> verboseErrors
124options = P.Options <$> noPrelude <*> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> pure Nothing <*> noOpts <*> pure Nothing <*> pure [] <*> pure [] <*> verboseErrors
122
125
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−
129term :: FilePath -> Term (IO ())
126term :: FilePath -> Term (IO ())
130−term prelude = compile <$> outputDirectory <*> options <*> inputFilesAndPrelude prelude
127+term prelude = compile prelude <$> inputFiles <*> outputDirectory <*> options
131
128
132termInfo :: TermInfo
129termInfo :: TermInfo
133termInfo = defTI
130termInfo = defTI
psc/Main.hs+9−11
@@ -44,9 +44,9 @@ readInput (Just input) = fmap collect $ forM input $ \inputFile -> do
44 collect :: [(FilePath, Either ParseError [P.Module])] -> Either ParseError [(FilePath, P.Module)]
44 collect :: [(FilePath, Either ParseError [P.Module])] -> Either ParseError [(FilePath, P.Module)]
45 collect = fmap concat . sequence . map (\(fp, e) -> fmap (map ((,) fp)) e)
45 collect = fmap concat . sequence . map (\(fp, e) -> fmap (map ((,) fp)) e)
46
46
47−compile :: P.Options -> Maybe [FilePath] -> Maybe FilePath -> Maybe FilePath -> IO ()
47+compile :: FilePath -> P.Options -> Bool -> [FilePath] -> Maybe FilePath -> Maybe FilePath -> IO ()
48−compile opts input output externs = do
48+compile prelude opts stdin input output externs = do
49− modules <- readInput input
49+ modules <- readInput stdInOrInputFiles
50 case modules of
50 case modules of
51 Left err -> do
51 Left err -> do
52 U.hPutStr stderr $ show err
52 U.hPutStr stderr $ show err
@@ -64,6 +64,11 @@ compile opts input output externs = do
64 Just path -> mkdirp path >> U.writeFile path exts
64 Just path -> mkdirp path >> U.writeFile path exts
65 Nothing -> return ()
65 Nothing -> return ()
66 exitSuccess
66 exitSuccess
67+ where
68+ stdInOrInputFiles :: Maybe [FilePath]
69+ stdInOrInputFiles | stdin = Nothing
70+ | P.optionsNoPrelude opts = Just input
71+ | otherwise = Just $ prelude : input
67
72
68mkdirp :: FilePath -> IO ()
73mkdirp :: FilePath -> IO ()
69mkdirp = createDirectoryIfMissing True . takeDirectory
74mkdirp = createDirectoryIfMissing True . takeDirectory
@@ -127,15 +132,8 @@ verboseErrors = value $ flag $ (optInfo [ "v", "verbose-errors" ])
127options :: Term P.Options
132options :: Term P.Options
128options = P.Options <$> noPrelude <*> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> runMain <*> noOpts <*> (Just <$> browserNamespace) <*> dceModules <*> codeGenModules <*> verboseErrors
133options = P.Options <$> noPrelude <*> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> runMain <*> noOpts <*> (Just <$> browserNamespace) <*> dceModules <*> codeGenModules <*> verboseErrors
129
134
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−
137term :: FilePath -> Term (IO ())
135term :: FilePath -> Term (IO ())
138−term prelude = compile <$> options <*> stdInOrInputFiles prelude <*> outputFile <*> externsFile
136+term prelude = compile prelude <$> options <*> useStdIn <*> inputFiles <*> outputFile <*> externsFile
139
137
140termInfo :: TermInfo
138termInfo :: TermInfo
141termInfo = defTI
139termInfo = defTI