~jojo/Carth

6071f9511dc62f784cc808db4f3c26a2a02ed780 — JoJo 1 year, 3 months ago 843a985
Formatting
2 files changed, 13 insertions(+), 18 deletions(-)

M app/GetConfig.hs
M app/Main.hs
M app/GetConfig.hs => app/GetConfig.hs +12 -16
@@ 22,18 22,16 @@ getConfig = do
    let subCompile a = a == "c" || a == "compile"
    let subRun a = a == "r" || a == "run"
    case as of
        a : as'
            | subCompile a -> compileCfg as'
            | subRun a -> runCfg as'
        a : as' | subCompile a -> compileCfg as'
                | subRun a -> runCfg as'
        a : _ | a == "-h" || a == "--help" -> do
            putStrLn usageSubs
            exitFailure
        "help" : [] -> do
            putStrLn usageSubs
            exitFailure
        "help" : a : _
            | subCompile a -> usageCompile
            | subRun a -> usageRun
        "help" : a : _ | subCompile a -> usageCompile
                       | subRun a -> usageRun
        "version" : _ -> printVersion >> exitSuccess
        a : _ -> do
            putStrLn ("Error: `" ++ a ++ "` is not a valid subcommand\n")


@@ 120,16 118,14 @@ usageRun = do

compileOpts :: [OptDescr (CompileConfig -> CompileConfig)]
compileOpts =
    [ Option
        []
        ["cc"]
        (ReqArg (\cc' c -> c { cCompiler = cc' }) "PROGRAM")
        "C compiler to use for linking"
    , Option
        ['o']
        ["outfile"]
        (ReqArg (\f c -> c { cOutfile = f }) "FILE")
        "Output filepath"
    [ Option []
             ["cc"]
             (ReqArg (\cc' c -> c { cCompiler = cc' }) "PROGRAM")
             "C compiler to use for linking"
    , Option ['o']
             ["outfile"]
             (ReqArg (\f c -> c { cOutfile = f }) "FILE")
             "Output filepath"
    , Option [] ["debug"] (NoArg (\c -> c { cDebug = True })) "Enable debugging"
    , Option ['v'] ["verbose"] (NoArg (\c -> c { cVerbose = True })) "Verbose output"
    ]

M app/Main.hs => app/Main.hs +1 -2
@@ 67,8 67,7 @@ parse f = Parse.parse f >>= \case
    Left e -> putStrLn (formatParseErr e) >> abort f
    Right p -> pure p
  where
    formatParseErr e =
        let ss = lines e in (unlines ((head ss ++ " Error:") : tail ss))
    formatParseErr e = let ss = lines e in (unlines ((head ss ++ " Error:") : tail ss))

typecheck' :: FilePath -> Parsed.Program -> IO Checked.Program
typecheck' f p = case typecheck p of