Skip to main content

DhallExpr

Enum DhallExpr 

Source
pub enum DhallExpr {
Show 36 variants BoolLit(bool), NaturalLit(u64), IntegerLit(i64), DoubleLit(f64), TextLit(String), TextInterp(String, Box<DhallExpr>, String), ListLit(Vec<DhallExpr>), EmptyList(DhallType), Some(Box<DhallExpr>), None(DhallType), RecordLit(Box<DhallRecord>), RecordType(Vec<(String, DhallType)>), UnionLit { union_type: DhallType, ctor: String, value: Option<Box<DhallExpr>>, }, Lambda(Box<DhallFunction>), Forall(String, DhallType, Box<DhallExpr>), Let(Vec<DhallDecl>, Box<DhallExpr>), If(Box<DhallExpr>, Box<DhallExpr>, Box<DhallExpr>), Merge(Box<DhallExpr>, Box<DhallExpr>, Option<DhallType>), ToMap(Box<DhallExpr>, Option<DhallType>), Assert(Box<DhallExpr>, Box<DhallExpr>), Equivalent(Box<DhallExpr>, Box<DhallExpr>), With(Box<DhallExpr>, Vec<(String, DhallExpr)>), Select(Box<DhallExpr>, String), Project(Box<DhallExpr>, Vec<String>), Application(Box<DhallExpr>, Box<DhallExpr>), Var(String), Import(DhallImport), Annot(Box<DhallExpr>, DhallType), BoolOp(String, Box<DhallExpr>, Box<DhallExpr>), NaturalOp(String, Box<DhallExpr>, Box<DhallExpr>), TextAppend(Box<DhallExpr>, Box<DhallExpr>), ListAppend(Box<DhallExpr>, Box<DhallExpr>), RecordTypeMerge(Box<DhallExpr>, Box<DhallExpr>), RecordMerge(Box<DhallExpr>, Box<DhallExpr>), Universe(DhallType), BuiltinType(DhallType),
}
Expand description

Dhall expression AST.

Variants§

§

BoolLit(bool)

Boolean literal: True / False

§

NaturalLit(u64)

Natural number literal: 0, 42

§

IntegerLit(i64)

Integer literal: +1, -5

§

DoubleLit(f64)

Double literal: 3.14

§

TextLit(String)

Text literal: "hello, world"

§

TextInterp(String, Box<DhallExpr>, String)

Text interpolation: "prefix ${expr} suffix"

§

ListLit(Vec<DhallExpr>)

List literal: [ v1, v2, v3 ]

§

EmptyList(DhallType)

Typed empty list: [] : List Natural

§

Some(Box<DhallExpr>)

Some value (Optional constructor)

§

None(DhallType)

None T (empty Optional)

§

RecordLit(Box<DhallRecord>)

Record value: { field1 = v1, field2 = v2 }

§

RecordType(Vec<(String, DhallType)>)

Record type: { field1 : T1, field2 : T2 }

§

UnionLit

Union value: < Ctor : T | ... >.Ctor value

Fields

§union_type: DhallType

Union type

§ctor: String

Chosen constructor

§value: Option<Box<DhallExpr>>

Constructor argument (None for unit constructors)

§

Lambda(Box<DhallFunction>)

Lambda: \(x : T) -> body

§

Forall(String, DhallType, Box<DhallExpr>)

Dependent forall: forall (x : T) -> body

§

Let(Vec<DhallDecl>, Box<DhallExpr>)

Let binding: let x : T = e in body

§

If(Box<DhallExpr>, Box<DhallExpr>, Box<DhallExpr>)

If-then-else: if cond then t else f

§

Merge(Box<DhallExpr>, Box<DhallExpr>, Option<DhallType>)

merge handler union : T — union elimination

§

ToMap(Box<DhallExpr>, Option<DhallType>)

toMap record : List { mapKey : Text, mapValue : T }

§

Assert(Box<DhallExpr>, Box<DhallExpr>)

Equivalence assertion: assert : a === b

§

Equivalent(Box<DhallExpr>, Box<DhallExpr>)

Equivalence type: a === b

§

With(Box<DhallExpr>, Vec<(String, DhallExpr)>)

Record update: record // { field = value }

§

Select(Box<DhallExpr>, String)

Field selection: record.field

§

Project(Box<DhallExpr>, Vec<String>)

Projection: record.{ field1, field2 }

§

Application(Box<DhallExpr>, Box<DhallExpr>)

Function application: f x

§

Var(String)

Variable: x, Natural/show, List/map

§

Import(DhallImport)

Import expression

§

Annot(Box<DhallExpr>, DhallType)

Type ascription: x : T

§

BoolOp(String, Box<DhallExpr>, Box<DhallExpr>)

Boolean operators: &&, ||

§

NaturalOp(String, Box<DhallExpr>, Box<DhallExpr>)

Natural/Integer arithmetic: +, *

§

TextAppend(Box<DhallExpr>, Box<DhallExpr>)

Text append: x ++ y

§

ListAppend(Box<DhallExpr>, Box<DhallExpr>)

List append: xs # ys

§

RecordTypeMerge(Box<DhallExpr>, Box<DhallExpr>)

Record merge (types): T1 /\ T2

§

RecordMerge(Box<DhallExpr>, Box<DhallExpr>)

Record value merge: r1 // r2

§

Universe(DhallType)

Type, Kind, Sort

§

BuiltinType(DhallType)

Bool, Natural, Integer, Double, Text as type expressions

Implementations§

Source§

impl DhallExpr

Source

pub fn emit(&self, indent: usize) -> String

Emit this expression as a Dhall source string.

Trait Implementations§

Source§

impl Clone for DhallExpr

Source§

fn clone(&self) -> DhallExpr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DhallExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for DhallExpr

Source§

fn eq(&self, other: &DhallExpr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DhallExpr

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.