public abstract class Expr
extends java.lang.Object
Note that there are two tools for manipulating expressions: internal visitors, which are a fold over the structure, and external visitors, which correspond to pattern matching.
| Modifier and Type | Class and Description |
|---|---|
static class |
Expr.Constants
Definitions of Dhall built-ins and other frequently-used expressions.
|
static class |
Expr.ImportMode
Modifier specifying how an import should be parsed into a Dhall expression.
|
static class |
Expr.LetBinding<A>
Represents the first part of a
let-expression. |
static class |
Expr.Parsed
Represents a Dhall expression that's been parsed and has associated source information.
|
static class |
Expr.Util
Convenience methods for working with expressions.
|
| Modifier and Type | Method and Description |
|---|---|
abstract <A> A |
accept(ExternalVisitor<A> visitor)
Run the given external visitor on this expression.
|
<A> A |
accept(Visitor<A> visitor)
Run the given internal visitor on this expression.
|
Expr |
alphaNormalize()
Alpha-normalize this expression.
|
Expr |
decrement(java.lang.String name)
Increment a variable name in this expression.
|
boolean |
equals(java.lang.Object obj)
Check whether this expression is equivalent to another value.
|
boolean |
equivalent(Expr other)
Check whether this expression is equivalent to another.
|
byte[] |
getEncodedBytes()
Encode this expression as a CBOR byte array.
|
byte[] |
getHashBytes()
Encode this expression as a CBOR byte array and return the SHA-256 hash of the result.
|
java.lang.String |
hash()
Encode this expression as a CBOR byte array and return the SHA-256 hash of the result as a
string.
|
int |
hashCode()
Hashes the CBOR encoding of this expression.
|
Expr |
increment(java.lang.String name)
Increment a variable name in this expression.
|
boolean |
isResolved()
Check whether all imports in this expression have been resolved.
|
static Expr |
makeAnnotated(Expr base,
Expr type) |
static Expr |
makeApplication(Expr base,
Expr arg) |
static Expr |
makeApplication(Expr base,
Expr[] args) |
static Expr |
makeApplication(Expr base,
java.util.List<Expr> args) |
static Expr |
makeAssert(Expr base) |
static Expr |
makeBuiltIn(java.lang.String name) |
static Expr |
makeClasspathImport(java.nio.file.Path path,
Expr.ImportMode mode,
byte[] hash) |
static Expr |
makeDoubleLiteral(double value) |
static Expr |
makeEmptyListLiteral(Expr tpe) |
static Expr |
makeEnvImport(java.lang.String value,
Expr.ImportMode mode,
byte[] hash) |
static Expr |
makeFieldAccess(Expr base,
java.lang.String fieldName) |
static Expr |
makeIdentifier(java.lang.String name) |
static Expr |
makeIdentifier(java.lang.String name,
long index) |
static Expr |
makeIf(Expr cond,
Expr thenValue,
Expr elseValue) |
static Expr |
makeIntegerLiteral(java.math.BigInteger value) |
static Expr |
makeLambda(java.lang.String param,
Expr input,
Expr result) |
static Expr |
makeLet(java.util.List<Expr.LetBinding<Expr>> bindings,
Expr body) |
static Expr |
makeLet(java.lang.String name,
Expr value,
Expr body) |
static Expr |
makeLet(java.lang.String name,
Expr type,
Expr value,
Expr body) |
static Expr |
makeLocalImport(java.nio.file.Path path,
Expr.ImportMode mode,
byte[] hash) |
static Expr |
makeMerge(Expr left,
Expr right) |
static Expr |
makeMerge(Expr left,
Expr right,
Expr type) |
static Expr |
makeMissingImport(Expr.ImportMode mode,
byte[] hash) |
static Expr |
makeNaturalLiteral(java.math.BigInteger value) |
static Expr |
makeNonEmptyListLiteral(java.util.Collection<Expr> values) |
static Expr |
makeNonEmptyListLiteral(Expr[] values) |
static Expr |
makeNote(Expr base,
Source source) |
static Expr |
makeOperatorApplication(Operator operator,
Expr lhs,
Expr rhs) |
static Expr |
makePi(Expr input,
Expr result) |
static Expr |
makePi(java.lang.String param,
Expr input,
Expr result) |
static Expr |
makeProjection(Expr base,
java.lang.String[] fieldNames) |
static Expr |
makeProjectionByType(Expr base,
Expr tpe) |
static Expr |
makeRecordLiteral(java.util.Collection<java.util.Map.Entry<java.lang.String,Expr>> fields) |
static Expr |
makeRecordLiteral(java.util.Map.Entry<java.lang.String,Expr>[] fields) |
static Expr |
makeRecordLiteral(java.lang.String key,
Expr value) |
static Expr |
makeRecordType(java.util.Collection<java.util.Map.Entry<java.lang.String,Expr>> fields) |
static Expr |
makeRecordType(java.util.Map.Entry<java.lang.String,Expr>[] fields) |
static Expr |
makeRemoteImport(java.net.URI url,
Expr using,
Expr.ImportMode mode,
byte[] hash) |
static Expr |
makeTextLiteral(java.lang.String value) |
static Expr |
makeTextLiteral(java.lang.String[] parts,
java.util.Collection<Expr> interpolated) |
static Expr |
makeTextLiteral(java.lang.String[] parts,
Expr[] interpolated) |
static Expr |
makeToMap(Expr base) |
static Expr |
makeToMap(Expr base,
Expr type) |
static Expr |
makeUnionType(java.util.Collection<java.util.Map.Entry<java.lang.String,Expr>> fields) |
static Expr |
makeUnionType(java.util.Map.Entry<java.lang.String,Expr>[] fields) |
static Expr |
makeWith(Expr base,
java.lang.String[] path,
Expr value) |
Expr |
normalize()
Beta-normalize this expression.
|
boolean |
sameStructure(Expr other)
Check whether this expression has the same structure as another.
|
Expr |
substitute(java.lang.String name,
Expr replacement)
Substitute the given expression for the given variable name in this expression.
|
java.lang.String |
toString() |
public abstract <A> A accept(ExternalVisitor<A> visitor)
public final Expr normalize()
This operation "evaluates" the expression.
public final Expr alphaNormalize()
This operation replaces all variable names with De-Bruijn-indexed underscores.
public final Expr increment(java.lang.String name)
public final Expr decrement(java.lang.String name)
public final Expr substitute(java.lang.String name, Expr replacement)
public final byte[] getEncodedBytes()
Note that this method does not normalize the expression.
public final byte[] getHashBytes()
Note that this method does not normalize the expression.
public final java.lang.String hash()
Note that this method does not normalize the expression.
public final boolean isResolved()
public final boolean sameStructure(Expr other)
This method is a stricter than equivalent in that it doesn't normalize its
arguments.
public final boolean equivalent(Expr other)
Note that this method normalizes both expressions before comparing.
public final boolean equals(java.lang.Object obj)
Note that this method normalizes both expressions before comparing. Also note that in future
releases this method may compare the hashes of the encoded bytes, but currently it is identical
to equivalent (but with an Object argument because Java).
equals in class java.lang.Objectpublic final int hashCode()
hashCode in class java.lang.Objectpublic final java.lang.String toString()
toString in class java.lang.Objectpublic static final Expr makeDoubleLiteral(double value)
public static final Expr makeNaturalLiteral(java.math.BigInteger value)
public static final Expr makeIntegerLiteral(java.math.BigInteger value)
public static final Expr makeTextLiteral(java.lang.String[] parts, Expr[] interpolated)
public static final Expr makeTextLiteral(java.lang.String[] parts, java.util.Collection<Expr> interpolated)
public static final Expr makeTextLiteral(java.lang.String value)
public static final Expr makeOperatorApplication(Operator operator, Expr lhs, Expr rhs)
public static final Expr makeBuiltIn(java.lang.String name)
public static final Expr makeIdentifier(java.lang.String name, long index)
public static final Expr makeIdentifier(java.lang.String name)
public static final Expr makeRecordLiteral(java.util.Map.Entry<java.lang.String,Expr>[] fields)
public static final Expr makeRecordLiteral(java.util.Collection<java.util.Map.Entry<java.lang.String,Expr>> fields)
public static final Expr makeRecordType(java.util.Map.Entry<java.lang.String,Expr>[] fields)
public static final Expr makeRecordType(java.util.Collection<java.util.Map.Entry<java.lang.String,Expr>> fields)
public static final Expr makeUnionType(java.util.Map.Entry<java.lang.String,Expr>[] fields)
public static final Expr makeUnionType(java.util.Collection<java.util.Map.Entry<java.lang.String,Expr>> fields)
public static final Expr makeNonEmptyListLiteral(java.util.Collection<Expr> values)
public static final Expr makeLet(java.util.List<Expr.LetBinding<Expr>> bindings, Expr body)
public static final Expr makeLocalImport(java.nio.file.Path path, Expr.ImportMode mode, byte[] hash)
public static final Expr makeClasspathImport(java.nio.file.Path path, Expr.ImportMode mode, byte[] hash)
public static final Expr makeRemoteImport(java.net.URI url, Expr using, Expr.ImportMode mode, byte[] hash)
public static final Expr makeEnvImport(java.lang.String value, Expr.ImportMode mode, byte[] hash)
public static final Expr makeMissingImport(Expr.ImportMode mode, byte[] hash)
public final <A> A accept(Visitor<A> visitor)