Skip to main content

DhallBackend

Struct DhallBackend 

Source
pub struct DhallBackend {
    pub emit_annotations: bool,
}
Expand description

The Dhall code generation backend.

Converts OxiLean IR constructs into Dhall configuration language output.

Fields§

§emit_annotations: bool

Whether to emit types with full annotation (default true)

Implementations§

Source§

impl DhallBackend

Source

pub fn new() -> Self

Create a new DhallBackend with default settings.

Source

pub fn emit_expr(&self, expr: &DhallExpr, indent: usize) -> String

Emit a DhallExpr to string.

Source

pub fn emit_file(&self, file: &DhallFile) -> String

Emit a complete DhallFile to string.

Source

pub fn emit_record(&self, record: &DhallRecord, indent: usize) -> String

Emit a DhallRecord to string.

Source

pub fn emit_function(&self, func: &DhallFunction, indent: usize) -> String

Emit a DhallFunction to string.

Source

pub fn make_schema(&self, fields: Vec<(&str, DhallType)>) -> DhallExpr

Build a Dhall record schema (record type) from a field map.

Source

pub fn make_list_map( &self, input_type: DhallType, output_type: DhallType, func: DhallExpr, list: DhallExpr, ) -> DhallExpr

Build a List/map application.

Source

pub fn make_natural_fold( &self, n: DhallExpr, result_type: DhallType, succ: DhallExpr, zero: DhallExpr, ) -> DhallExpr

Build a Natural/fold-style loop body.

Source

pub fn make_service_config( &self, enable: bool, name: &str, port: u64, extra_fields: Vec<(String, DhallExpr)>, ) -> DhallExpr

Build a configuration record for a service-like schema.

Source

pub fn make_enum(&self, variants: Vec<&str>) -> DhallType

Build a union type for an enumeration.

Source

pub fn make_optional_merge( &self, optional_value: DhallExpr, some_handler: DhallExpr, none_value: DhallExpr, result_type: DhallType, ) -> DhallExpr

Build an Optional handling pattern with merge.

Source

pub fn make_package( &self, _module_name: &str, exports: Vec<(&str, DhallExpr)>, ) -> DhallFile

Generate a Dhall prelude-style package.dhall skeleton.

Trait Implementations§

Source§

impl Default for DhallBackend

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.