pub fn run(options: Options) -> Result<(), Box<dyn Error>> {
    let mut writer = StandardStream::stdout(ColorChoice::Always);
    let mut editor = {
        let config = Config::builder()
            .history_ignore_space(true)
            .history_ignore_dups(true)
            .build();

        Editor::<()>::with_config(config)
    };

    if editor.load_history(&options.history_file).is_err() {
        // No previous REPL history!
    }

    let mut files = Files::new();
    let context = Context::default();
    let mut metas = meta::Env::new();

    loop {
        match editor.readline(&options.prompt) {
            Ok(line) => {
                let file_id = files.add("repl", line);
                let file = &files[file_id];
                editor.add_history_entry(file.contents());

                match read_eval(&context, &mut metas, file) {
                    Ok((term, ty)) => {
                        let output = pretty::ann(
                            context.term_to_doc(&term),
                            context.value_to_doc(&metas, &ty),
                        );

                        let width = pretty_width(&mut editor);
                        writeln!(writer, "{}", output.pretty(width))?;
                    },
                    Err(diagnostic) => {
                        let config = language_reporting::DefaultConfig;
                        language_reporting::emit(&mut writer.lock(), &files, &diagnostic, &config)?;
                    },
                }
            },
            Err(ReadlineError::Interrupted) => println!("Interrupted!"),
            Err(ReadlineError::Eof) => break,
            Err(error) => return Err(error.into()),
        }
    }

    editor.save_history(&options.history_file)?;

    println!("Bye bye");

    Ok(())
}
/// Run the REPL with the given options.
Run the REPL with the given options.
Run the REPL with the given options .
pub fn run(options: Options) -> Result<(), Box<dyn Error>> {
    let mut writer = StandardStream::stdout(ColorChoice::Always);
    let mut editor = {
        let config = Config::builder()
            .history_ignore_space(true)
            .history_ignore_dups(true)
            .build();
        Editor::<()>::with_config(config)
    };
    if editor.load_history(&options.history_file).is_err() {
        // No previous REPL history!
    }
    let mut files = Files::new();
    let context = Context::default();
    let mut metas = meta::Env::new();
    loop {
        match editor.readline(&options.prompt) {
            Ok(line) => {
                let file_id = files.add("repl", line);
                let file = &files[file_id];
                editor.add_history_entry(file.contents());
                match read_eval(&context, &mut metas, file) {
                    Ok((term, ty)) => {
                        let output = pretty::ann(
                            context.term_to_doc(&term),
                            context.value_to_doc(&metas, &ty),
                        );
                        let width = pretty_width(&mut editor);
                        writeln!(writer, "{}", output.pretty(width))?;
                    },
                    Err(diagnostic) => {
                        let config = language_reporting::DefaultConfig;
                        language_reporting::emit(&mut writer.lock(), &files, &diagnostic, &config)?;
                    },
                }
            },
            Err(ReadlineError::Interrupted) => println!("Interrupted!"),
            Err(ReadlineError::Eof) => break,
            Err(error) => return Err(error.into()),
        }
    }
    editor.save_history(&options.history_file)?;
    println!("Bye bye");
    Ok(())
}
pub fn run ( options : Options ) -> Result < ( ) , Box < dyn Error > > { let mut writer = StandardStream :: stdout ( ColorChoice :: Always ) ; let mut editor = { let config = Config :: builder ( ) . history_ignore_space ( true ) . history_ignore_dups ( true ) . build ( ) ; Editor :: < ( ) > :: with_config ( config ) } ; if editor . load_history ( & options . history_file ) . is_err ( ) { // No previous REPL history! } let mut files = Files :: new ( ) ; let context = Context :: default ( ) ; let mut metas = meta :: Env :: new ( ) ; loop { match editor . readline ( & options . prompt ) { Ok ( line ) => { let file_id = files . add ( " " , line ) ; let file = & files [ file_id ] ; editor . add_history_entry ( file . contents ( ) ) ; match read_eval ( & context , & mut metas , file ) { Ok ( ( term , ty ) ) => { let output = pretty :: ann ( context . term_to_doc ( & term ) , context . value_to_doc ( & metas , & ty ) , ) ; let width = pretty_width ( & mut editor ) ; writeln ! ( writer " " output pretty ( width ) ) ? ; } , Err ( diagnostic ) => { let config = language_reporting :: DefaultConfig ; language_reporting :: emit ( & mut writer . lock ( ) , & files , & diagnostic , & config ) ? ; } , } } , Err ( ReadlineError :: Interrupted ) => println ! ( " " ) , Err ( ReadlineError :: Eof ) => break , Err ( error ) => return Err ( error . into ( ) ) , } } editor . save_history ( & options . history_file ) ? ; println ! ( " " ) ; Ok ( ( ) ) }
Run the REPL with the given options.
Run the REPL with the given options .
options
Options
options
Options