From d8757e898c9f6d70c774ed34df408c2f5ea5d887 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Thu, 3 Oct 2019 18:11:28 -0400 Subject: [PATCH] factor opts out of main --- semantic-ast/src/CLI.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/semantic-ast/src/CLI.hs b/semantic-ast/src/CLI.hs index 332708054..6ce5971c5 100644 --- a/semantic-ast/src/CLI.hs +++ b/semantic-ast/src/CLI.hs @@ -13,6 +13,14 @@ import System.IO (FilePath) import Options.Applicative hiding (style) import Data.Semigroup ((<>)) +main :: IO () +main = generateAST =<< execParser opts + +opts :: ParserInfo SemanticAST +opts = info (parseAST <**> helper) + ( fullDesc + <> progDesc "Read a file, output an AST" + <> header "semantic-ast - generates ASTs" ) data SemanticAST = SemanticAST { sourceFilePath :: Prelude.String , format :: Prelude.String @@ -28,14 +36,6 @@ parseAST = SemanticAST ( long "format" <> help "Specify format --json --sexpression --show" ) -main :: IO () -main = generateAST =<< execParser opts - where - opts = info (parseAST <**> helper) - ( fullDesc - <> progDesc "Read a file, output an AST" - <> header "semantic-ast - generates ASTs" ) - generateAST :: SemanticAST -> IO () generateAST (SemanticAST file _) = do bytestring <- Data.ByteString.readFile file