git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Auto include the Prelude, add --no-prelude flag.
commitda0530b63563e8791c776f0f7c3cf6d2d679133f authorPhil Freeman <paf31@cantab.net> dateFri 10 Jan 2014, 15:36 (13 years ago) parent53cc34f
2 files changed+22−9
purescript.cabal+2−1 src/Main.hs+20−8
purescript.cabal+2−1
@@ -1,5 +1,5 @@
11name: purescript
2−version: 0.2.10.2
2+version: 0.2.11
33cabal-version: >=1.8
44build-type: Simple
55license: MIT
@@ -12,6 +12,7 @@ description: A small compile-to-JS language with extensible records and type-saf
1212category: Language
1313author: Phil Freeman <paf31@cantab.net>
1414data-dir: ""
15+data-files: libraries/prelude/prelude.purs
1516
1617library
1718 build-depends: base >=4 && <5, cmdtheline -any, containers -any,
src/Main.hs+20−8
@@ -21,6 +21,11 @@ import Control.Monad (forM)
2121import System.Exit (exitSuccess, exitFailure)
2222import qualified System.IO.UTF8 as U
2323import Text.Parsec (ParseError)
24+import qualified Paths_purescript as Paths
25+import Data.Version (showVersion)
26+
27+preludeFilename :: IO FilePath
28+preludeFilename = Paths.getDataFileName "libraries/prelude/prelude.purs"
2429
2530readInput :: Maybe [FilePath] -> IO (Either ParseError [P.Module])
2631readInput Nothing = getContents >>= return . P.runIndentParser P.parseModules
@@ -73,24 +78,31 @@ performRuntimeTypeChecks :: Term Bool
7378performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
7479 { optDoc = "Generate runtime type checks" }
7580
81+noPrelude :: Term Bool
82+noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
83+ { optDoc = "Omit the Prelude" }
84+
7685options :: Term P.Options
7786options = P.Options <$> tco <*> performRuntimeTypeChecks
7887
79−stdInOrInputFiles :: Term (Maybe [FilePath])
80−stdInOrInputFiles = combine <$> useStdIn <*> inputFiles
88+stdInOrInputFiles :: FilePath -> Term (Maybe [FilePath])
89+stdInOrInputFiles prelude = combine <$> useStdIn <*> (not <$> noPrelude) <*> inputFiles
8190 where
82− combine False input = Just input
83− combine True _ = Nothing
91+ combine False True input = Just (prelude : input)
92+ combine False False input = Just input
93+ combine True _ _ = Nothing
8494
85−term :: Term (IO ())
86−term = compile <$> options <*> stdInOrInputFiles <*> outputFile <*> externsFile
95+term :: FilePath -> Term (IO ())
96+term prelude = compile <$> options <*> stdInOrInputFiles prelude <*> outputFile <*> externsFile
8797
8898termInfo :: TermInfo
8999termInfo = defTI
90100 { termName = "psc"
91− , version = "1.0"
101+ , version = showVersion $ Paths.version
92102 , termDoc = "Compiles PureScript to Javascript"
93103 }
94104
95105main :: IO ()
96−main = run (term, termInfo)
106+main = do
107+ prelude <- preludeFilename
108+ run (term prelude, termInfo)