catlog_wasm/
notation.rs

1//! Traits concerning quoting and elaboration.
2
3/** An elaborator.
4
5Elaboration is the process of transforming notation (as declared in
6notebook-types) into syntax and values. This can possibly fail. Eventually, this
7struct may have some role to play in accumulating errors, but for now it is a
8singleton.
9 */
10pub struct Elaborator;
11
12/** A type that can elaborated into another.
13
14Says that objects of type `T` can be elaborated into objects of type `S`.
15 */
16pub trait CanElaborate<T, S> {
17    /// Transform notation into syntax.
18    fn elab(&self, x: &T) -> Result<S, String>;
19}
20
21/** A quoter.
22
23Quotation is the process of transformation syntax or values into notation.
24Unlike elaboration, quotation is infallible.
25 */
26pub struct Quoter;
27
28/** A typed that quoted into another.
29
30Says that objects of type `T` can be quoted as objects of type `S`.
31 */
32pub trait CanQuote<T, S> {
33    /// Transform syntax or value into notation.
34    fn quote(&self, x: &T) -> S;
35}