git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #324 from garyb/no-prelude-fix

Disable prelude auto-import with --no-prelude

commitc9ef0e2cae462b747618f7370b0523af54cf984a authorPhil Freeman <paf31@cantab.net> dateTue 25 Mar 2014, 17:31 (13 years ago) parent4f76abfaa8a269
5 files changed+11−7
psc-make/Main.hs+1−1 psc/Main.hs+1−1 psci/Main.hs+1−1 src/Language/PureScript.hs+2−2 src/Language/PureScript/Options.hs+6−2
psc-make/Main.hs+1−1
@@ -116,7 +116,7 @@ browserNamespace = value $ opt "PS" $ (optInfo [ "browser-namespace" ])
116116 { optDoc = "Specify the namespace that PureScript modules will be exported to when running in the browser." }
117117
118118options :: 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 []
120120
121121inputFilesAndPrelude :: FilePath -> Term [FilePath]
122122inputFilesAndPrelude prelude = combine <$> (not <$> noPrelude) <*> inputFiles
psc/Main.hs+1−1
@@ -123,7 +123,7 @@ codeGenModules = value $ optAll [] $ (optInfo [ "codegen" ])
123123 { optDoc = "A list of modules for which Javascript and externs should be generated. This argument can be used multiple times." }
124124
125125options :: 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
127127
128128stdInOrInputFiles :: FilePath -> Term (Maybe [FilePath])
129129stdInOrInputFiles prelude = combine <$> useStdIn <*> (not <$> noPrelude) <*> inputFiles
psci/Main.hs+1−1
@@ -194,7 +194,7 @@ completion = completeWord Nothing " \t\n\r" findCompletions
194194-- | Compilation options.
195195--
196196options :: 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" [] []
198198
199199-- |
200200-- Makes a volatile module to execute the current expression.
src/Language/PureScript.hs+2−2
@@ -69,7 +69,7 @@ compile = compile' initEnvironment
6969
7070compile' :: Environment -> Options -> [Module] -> Either String (String, String, Environment)
7171compile' env opts ms = do
72− (sorted, _) <- sortModules (map importPrelude ms)
72+ (sorted, _) <- sortModules $ if optionsNoPrelude opts then ms else (map importPrelude ms)
7373 desugared <- desugar sorted
7474 (elaborated, env') <- runCheck' env $ forM desugared $ typeCheckModule mainModuleIdent
7575 regrouped <- createBindingGroupsModule . collapseBindingGroupsModule $ elaborated
@@ -164,7 +164,7 @@ make :: (Functor m, Monad m, MonadMake m) => Options -> [(FilePath, Module)] ->
164164make opts ms = do
165165 let filePathMap = M.fromList (map (\(fp, Module mn _ _) -> (mn, fp)) ms)
166166
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)
168168
169169 toRebuild <- foldM (\s (Module moduleName' _ _) -> do
170170 let filePath = toFileName moduleName'
src/Language/PureScript/Options.hs+6−2
@@ -19,10 +19,14 @@ module Language.PureScript.Options where
1919-- The data type of compiler options
2020--
2121data Options = Options {
22+ -- |
23+ -- Disable inclusion of the built in Prelude
24+ --
25+ optionsNoPrelude :: Bool
2226 -- |
2327 -- Disable tail-call elimination
2428 --
25− optionsNoTco :: Bool
29+ , optionsNoTco :: Bool
2630 -- |
2731 -- Perform type checks at runtime
2832 --
@@ -59,4 +63,4 @@ data Options = Options {
5963-- Default compiler options
6064--
6165defaultOptions :: Options
62−defaultOptions = Options False False False Nothing False "PS" [] []
66+defaultOptions = Options False False False False Nothing False "PS" [] []