zephyr 0.1.1.0 → 0.1.4
raw patch · 4 files changed
+45/−19 lines, 4 filesdep +ansi-wl-pprint
Dependencies added: ansi-wl-pprint
Files
- README.md +1/−0
- app/Command/DCE.hs +15/−11
- app/Main.hs +22/−4
- zephyr.cabal +7/−4
README.md view
@@ -1,5 +1,6 @@ # zephyr [](http://github.com/coot)+[](https://travis-ci.org/coot/zephyr) Experimental tree shaking tool for [PureScript](https://github.com/purescript/purescript).
app/Command/DCE.hs view
@@ -1,7 +1,6 @@ -- | Dead code elimination command based on `Language.PureScript.CoreFn.DCE`. module Command.DCE- ( command- , runDCECommand+ ( runDCECommand , dceOptions , entryPointOpt ) where@@ -23,6 +22,7 @@ import qualified Data.ByteString.UTF8 as BU8 import Data.Bool (bool) import Data.Either (Either, lefts, rights)+import Data.Foldable (traverse_) import Data.List (intercalate, null) import qualified Data.Map as M import Data.Maybe (isNothing, listToMaybe)@@ -152,7 +152,7 @@ dceOptions :: Opts.Parser DCEOptions dceOptions = DCEOptions- <$> Opts.some entryPointOpt+ <$> Opts.many entryPointOpt <*> inputDirectoryOpt <*> outputDirectoryOpt <*> verboseOutputOpt@@ -213,7 +213,9 @@ (T.intercalate "\n\t" errs') formatDCEAppError _ _ (NoInputs path) = sformat- (stext%": No inputs found under "%string%" directory.\n Please run `purs compile --dump-corefn ..` or `pulp build -- --dump-corefn`")+ (stext%": No inputs found under "%string%" directory.\n"+ %" Please run `purs compile --codegen corefn ..` or"+ %"`pulp build -- --codegen corefn`") (colorText errorColor "Error") (colorString codeColor path) formatDCEAppError _ _ (InputNotDirectory path)@@ -248,7 +250,7 @@ $ runWriterT $ dceEval (snd `map` rights inpts) >>= flip dce entryPoints relPath <- liftIO getCurrentDirectory- liftIO $ traverse (hPutStrLn stderr . uncurry (displayDCEWarning relPath)) (zip (zip [1..] (repeat (length warns))) warns)+ liftIO $ traverse_ (hPutStrLn stderr . uncurry (displayDCEWarning relPath)) (zip (zip [1..] (repeat (length warns))) warns) let filePathMap = M.fromList $ map (\m -> (CoreFn.moduleName m, Right $ CoreFn.modulePath m)) mods foreigns <- P.inferForeignModules filePathMap let makeActions = P.buildMakeActions dceOutputDir filePathMap foreigns dceUsePrefix@@ -265,13 +267,15 @@ then sformat (string%":\n "%string) f (A.formatError p err) else T.pack f -runDCECommand :: DCEOptions -> IO ()+runDCECommand+ :: DCEOptions+ -> IO () runDCECommand opts = do res <- runExceptT $ dceCommand opts relPath <- getCurrentDirectory case res of- Left e -> (hPutStrLn stderr . T.unpack . formatDCEAppError opts relPath $ e) *> exitFailure- Right _ -> exitSuccess--command :: Opts.Parser (IO ())-command = runDCECommand <$> (Opts.helper <*> dceOptions)+ Left e ->+ (hPutStrLn stderr . T.unpack . formatDCEAppError opts relPath $ e)+ *> exitFailure+ Right{} ->+ exitSuccess
app/Main.hs view
@@ -1,14 +1,32 @@ module Main where import Command.DCE-import Options.Applicative ((<**>))+import Data.Monoid ((<>))+import Data.Version (showVersion) import qualified Options.Applicative as Opts+import qualified Paths_zephyr as Paths+import System.Environment (getArgs) import qualified System.IO as IO + main :: IO () main = do IO.hSetEncoding IO.stdout IO.utf8 IO.hSetEncoding IO.stderr IO.utf8- let info = Opts.info (dceOptions <**> Opts.helper) (Opts.progDesc "tree shaking breeze for PureScript")- opts <- Opts.execParser info- runDCECommand opts+ let pinfo = Opts.info (versionOpt <*> Opts.helper <*> dceOptions) (Opts.progDesc "tree shaking breeze for PureScript")+ getArgs+ >>= Opts.handleParseResult . execParserPure pinfo+ >>= runDCECommand+ where+ execParserPure :: Opts.ParserInfo a -> [String] -> Opts.ParserResult a+ execParserPure pinfo [] = Opts.Failure $+ Opts.parserFailure Opts.defaultPrefs pinfo Opts.ShowHelpText mempty+ execParserPure pinfo args = Opts.execParserPure Opts.defaultPrefs pinfo args++versionOpt :: Opts.Parser (a -> a)+versionOpt = Opts.abortOption (Opts.InfoMsg versionString) $+ Opts.long "version"+ <> Opts.help "Show the version number"+ <> Opts.hidden+ where+ versionString = showVersion Paths.version
zephyr.cabal view
@@ -1,6 +1,7 @@ name: zephyr-version: 0.1.1.0-synopsis: Zephyr tree shaking for PureScript Language+version: 0.1.4+synopsis: + Zephyr tree shaking for PureScript Language description: Tree shaking tool and partial evaluator for PureScript CoreFn AST.@@ -37,8 +38,8 @@ TupleSections ViewPatterns ghc-options:- -Wall- -fmax-pmcheck-iterations=4000000+ -Wall+ -fmax-pmcheck-iterations=4000000 exposed-modules: Language.PureScript.DCE , Language.PureScript.DCE.Constants@@ -77,6 +78,7 @@ other-modules: Command.DCE Command.DCEOptions+ Paths_zephyr default-extensions: DataKinds FlexibleContexts@@ -92,6 +94,7 @@ build-depends: aeson >=1.0 && <1.3 , ansi-terminal >=0.7.1 && <0.8+ , ansi-wl-pprint , base , base-compat >=0.6.0 , bytestring