1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! Evaluation and evaluators.

mod lazy;
mod name;
pub mod util;
mod value;

use std::fmt::Display;

use failure::Error;

use ast::PrintStyle;
pub use eval::lazy::LazyEvaluation;
pub use eval::name::CallByName;
pub use eval::value::CallByValue;

// TODO: Should there be proptest/quickcheck tests for progress/preservation properties?

/// An evaluator, which determines the evaluation strategy.
pub trait Evaluator: Display {
    /// Determines whether the primary expression is currently in a normal form, i.e. one that
    /// cannot be further reduced.
    fn normal_form(&self) -> bool;

    /// Sets the print style.
    fn set_print_style(&mut self, print_style: PrintStyle);

    /// Performs a single reduction step.
    fn step(&mut self) -> Result<(), Error>;
}