git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #324 from garyb/no-prelude-fix
c9ef0e2Phil Freeman
psc-make/Main.hs+1−1
@@ -116,7 +116,7 @@ browserNamespace = value $ opt "PS" $ (optInfo [ "browser-namespace" ])
116 { optDoc = "Specify the namespace that PureScript modules will be exported to when running in the browser." }
116 { optDoc = "Specify the namespace that PureScript modules will be exported to when running in the browser." }
117
117
118options :: Term P.Options
118options :: Term P.Options
119−options = P.Options <$> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> pure Nothing <*> noOpts <*> browserNamespace <*> pure [] <*> pure []
119+options = P.Options <$> noPrelude <*> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> pure Nothing <*> noOpts <*> browserNamespace <*> pure [] <*> pure []
120
120
121inputFilesAndPrelude :: FilePath -> Term [FilePath]
121inputFilesAndPrelude :: FilePath -> Term [FilePath]
122inputFilesAndPrelude prelude = combine <$> (not <$> noPrelude) <*> inputFiles
122inputFilesAndPrelude prelude = combine <$> (not <$> noPrelude) <*> inputFiles
psc/Main.hs+1−1
@@ -123,7 +123,7 @@ codeGenModules = value $ optAll [] $ (optInfo [ "codegen" ])
123 { optDoc = "A list of modules for which Javascript and externs should be generated. This argument can be used multiple times." }
123 { optDoc = "A list of modules for which Javascript and externs should be generated. This argument can be used multiple times." }
124
124
125options :: Term P.Options
125options :: Term P.Options
126−options = P.Options <$> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> runMain <*> noOpts <*> browserNamespace <*> dceModules <*> codeGenModules
126+options = P.Options <$> noPrelude <*> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> runMain <*> noOpts <*> browserNamespace <*> dceModules <*> codeGenModules
127
127
128stdInOrInputFiles :: FilePath -> Term (Maybe [FilePath])
128stdInOrInputFiles :: FilePath -> Term (Maybe [FilePath])
129stdInOrInputFiles prelude = combine <$> useStdIn <*> (not <$> noPrelude) <*> inputFiles
129stdInOrInputFiles prelude = combine <$> useStdIn <*> (not <$> noPrelude) <*> inputFiles
psci/Main.hs+1−1
@@ -194,7 +194,7 @@ completion = completeWord Nothing " \t\n\r" findCompletions
194-- | Compilation options.
194-- | Compilation options.
195--
195--
196options :: P.Options
196options :: P.Options
197−options = P.Options True False True (Just "Main") True "PS" [] []
197+options = P.Options False True False True (Just "Main") True "PS" [] []
198
198
199-- |
199-- |
200-- Makes a volatile module to execute the current expression.
200-- Makes a volatile module to execute the current expression.
src/Language/PureScript.hs+2−2
@@ -69,7 +69,7 @@ compile = compile' initEnvironment
69
69
70compile' :: Environment -> Options -> [Module] -> Either String (String, String, Environment)
70compile' :: Environment -> Options -> [Module] -> Either String (String, String, Environment)
71compile' env opts ms = do
71compile' env opts ms = do
72− (sorted, _) <- sortModules (map importPrelude ms)
72+ (sorted, _) <- sortModules $ if optionsNoPrelude opts then ms else (map importPrelude ms)
73 desugared <- desugar sorted
73 desugared <- desugar sorted
74 (elaborated, env') <- runCheck' env $ forM desugared $ typeCheckModule mainModuleIdent
74 (elaborated, env') <- runCheck' env $ forM desugared $ typeCheckModule mainModuleIdent
75 regrouped <- createBindingGroupsModule . collapseBindingGroupsModule $ elaborated
75 regrouped <- createBindingGroupsModule . collapseBindingGroupsModule $ elaborated
@@ -164,7 +164,7 @@ make :: (Functor m, Monad m, MonadMake m) => Options -> [(FilePath, Module)] ->
164make opts ms = do
164make opts ms = do
165 let filePathMap = M.fromList (map (\(fp, Module mn _ _) -> (mn, fp)) ms)
165 let filePathMap = M.fromList (map (\(fp, Module mn _ _) -> (mn, fp)) ms)
166
166
167− (sorted, graph) <- liftError $ sortModules (map (importPrelude . snd) ms)
167+ (sorted, graph) <- liftError $ sortModules $ if optionsNoPrelude opts then map snd ms else (map (importPrelude . snd) ms)
168
168
169 toRebuild <- foldM (\s (Module moduleName' _ _) -> do
169 toRebuild <- foldM (\s (Module moduleName' _ _) -> do
170 let filePath = toFileName moduleName'
170 let filePath = toFileName moduleName'
src/Language/PureScript/Options.hs+6−2
@@ -19,10 +19,14 @@ module Language.PureScript.Options where
19-- The data type of compiler options
19-- The data type of compiler options
20--
20--
21data Options = Options {
21data Options = Options {
22+ -- |
23+ -- Disable inclusion of the built in Prelude
24+ --
25+ optionsNoPrelude :: Bool
22 -- |
26 -- |
23 -- Disable tail-call elimination
27 -- Disable tail-call elimination
24 --
28 --
25− optionsNoTco :: Bool
29+ , optionsNoTco :: Bool
26 -- |
30 -- |
27 -- Perform type checks at runtime
31 -- Perform type checks at runtime
28 --
32 --
@@ -59,4 +63,4 @@ data Options = Options {
59-- Default compiler options
63-- Default compiler options
60--
64--
61defaultOptions :: Options
65defaultOptions :: Options
62−defaultOptions = Options False False False Nothing False "PS" [] []
66+defaultOptions = Options False False False False Nothing False "PS" [] []