git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Auto include the Prelude, add --no-prelude flag.
da0530bPhil Freeman
purescript.cabal+2−1
@@ -1,5 +1,5 @@
1name: purescript
1name: purescript
2−version: 0.2.10.2
2+version: 0.2.11
3cabal-version: >=1.8
3cabal-version: >=1.8
4build-type: Simple
4build-type: Simple
5license: MIT
5license: MIT
@@ -12,6 +12,7 @@ description: A small compile-to-JS language with extensible records and type-saf
12category: Language
12category: Language
13author: Phil Freeman <paf31@cantab.net>
13author: Phil Freeman <paf31@cantab.net>
14data-dir: ""
14data-dir: ""
15+data-files: libraries/prelude/prelude.purs
15
16
16library
17library
17 build-depends: base >=4 && <5, cmdtheline -any, containers -any,
18 build-depends: base >=4 && <5, cmdtheline -any, containers -any,
src/Main.hs+20−8
@@ -21,6 +21,11 @@ import Control.Monad (forM)
21import System.Exit (exitSuccess, exitFailure)
21import System.Exit (exitSuccess, exitFailure)
22import qualified System.IO.UTF8 as U
22import qualified System.IO.UTF8 as U
23import Text.Parsec (ParseError)
23import 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"
24
29
25readInput :: Maybe [FilePath] -> IO (Either ParseError [P.Module])
30readInput :: Maybe [FilePath] -> IO (Either ParseError [P.Module])
26readInput Nothing = getContents >>= return . P.runIndentParser P.parseModules
31readInput Nothing = getContents >>= return . P.runIndentParser P.parseModules
@@ -73,24 +78,31 @@ performRuntimeTypeChecks :: Term Bool
73performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
78performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
74 { optDoc = "Generate runtime type checks" }
79 { optDoc = "Generate runtime type checks" }
75
80
81+noPrelude :: Term Bool
82+noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
83+ { optDoc = "Omit the Prelude" }
84+
76options :: Term P.Options
85options :: Term P.Options
77options = P.Options <$> tco <*> performRuntimeTypeChecks
86options = P.Options <$> tco <*> performRuntimeTypeChecks
78
87
79−stdInOrInputFiles :: Term (Maybe [FilePath])
88+stdInOrInputFiles :: FilePath -> Term (Maybe [FilePath])
80−stdInOrInputFiles = combine <$> useStdIn <*> inputFiles
89+stdInOrInputFiles prelude = combine <$> useStdIn <*> (not <$> noPrelude) <*> inputFiles
81 where
90 where
82− combine False input = Just input
91+ combine False True input = Just (prelude : input)
92+ combine False False input = Just input
83− combine True _ = Nothing
93+ combine True _ _ = Nothing
84
94
85−term :: Term (IO ())
95+term :: FilePath -> Term (IO ())
86−term = compile <$> options <*> stdInOrInputFiles <*> outputFile <*> externsFile
96+term prelude = compile <$> options <*> stdInOrInputFiles prelude <*> outputFile <*> externsFile
87
97
88termInfo :: TermInfo
98termInfo :: TermInfo
89termInfo = defTI
99termInfo = defTI
90 { termName = "psc"
100 { termName = "psc"
91− , version = "1.0"
101+ , version = showVersion $ Paths.version
92 , termDoc = "Compiles PureScript to Javascript"
102 , termDoc = "Compiles PureScript to Javascript"
93 }
103 }
94
104
95main :: IO ()
105main :: IO ()
106+main = do
107+ prelude <- preludeFilename
96−main = run (term, termInfo)
108+ run (term prelude, termInfo)