cmd_compile :: String -> IP.IdrisParser (Either String Command)
cmd_compile name = do
    let defaultCodegen = Via IBCFormat "c"

    let codegenOption :: IP.IdrisParser Codegen
        codegenOption = do
            let bytecodeCodegen = discard (IP.symbol "bytecode") *> return Bytecode
                viaCodegen = do x <- IP.identifier
                                return (Via IBCFormat (map toLower x))
            bytecodeCodegen <|> viaCodegen

    let hasOneArg = do
          i <- get
          f <- IP.identifier
          P.eof
          return $ Right (Compile defaultCodegen f)

    let hasTwoArgs = do
          i <- get
          codegen <- codegenOption
          f <- IP.identifier
          P.eof
          return $ Right (Compile codegen f)

    let failure = return $ Left $ "Usage is :" ++ name ++ " [<codegen>] <filename>"
    P.try hasTwoArgs <|> P.try hasOneArg <|> failure
cmd_compile :: String -> IP.IdrisParser (Either String Command)
cmd_compile name = do
    let defaultCodegen = Via IBCFormat "c"

    let codegenOption :: IP.IdrisParser Codegen
        codegenOption = do
            let bytecodeCodegen = discard (IP.symbol "bytecode") *> return Bytecode
                viaCodegen = do x <- IP.identifier
                                return (Via IBCFormat (map toLower x))
            bytecodeCodegen <|> viaCodegen

    let hasOneArg = do
          i <- get
          f <- IP.identifier
          P.eof
          return $ Right (Compile defaultCodegen f)

    let hasTwoArgs = do
          i <- get
          codegen <- codegenOption
          f <- IP.identifier
          P.eof
          return $ Right (Compile codegen f)

    let failure = return $ Left $ "Usage is :" ++ name ++ " [<codegen>] <filename>"
    P.try hasTwoArgs <|> P.try hasOneArg <|> failure
cmd_compile name = do
    let defaultCodegen = Via IBCFormat "c"

    let codegenOption :: IP.IdrisParser Codegen
        codegenOption = do
            let bytecodeCodegen = discard (IP.symbol "bytecode") *> return Bytecode
                viaCodegen = do x <- IP.identifier
                                return (Via IBCFormat (map toLower x))
            bytecodeCodegen <|> viaCodegen

    let hasOneArg = do
          i <- get
          f <- IP.identifier
          P.eof
          return $ Right (Compile defaultCodegen f)

    let hasTwoArgs = do
          i <- get
          codegen <- codegenOption
          f <- IP.identifier
          P.eof
          return $ Right (Compile codegen f)

    let failure = return $ Left $ "Usage is :" ++ name ++ " [<codegen>] <filename>"
    P.try hasTwoArgs <|> P.try hasOneArg <|> failure