public static final class Expr.Util
extends java.lang.Object
Note that many of these operations represent "down-casts", and return null in cases
where the expression doesn't have the requested constructor.
| Modifier and Type | Method and Description |
|---|---|
static Expr |
applyAsLambda(Expr expr,
Expr arg)
If the expression is a lambda, apply it to the given argument.
|
static java.lang.Boolean |
asBoolLiteral(Expr expr)
If the expression is a
Bool literal, return its value. |
static java.lang.String |
asBuiltIn(Expr expr)
If the expression is a Dhall built-in, return its name.
|
static java.lang.Double |
asDoubleLiteral(Expr expr)
If the expression is a
Double literal, return its value. |
static java.util.Map.Entry<Expr,java.lang.String> |
asFieldAccess(Expr expr)
If the expression is a field access, return the base and field name.
|
static java.math.BigInteger |
asIntegerLiteral(Expr expr)
If the expression is an
Integer literal, return its value. |
static java.util.List<Expr> |
asListLiteral(Expr expr)
If the expression is a
List literal, return its contents. |
static java.math.BigInteger |
asNaturalLiteral(Expr expr)
If the expression is a
Natural literal, return its value. |
static java.util.List<java.util.Map.Entry<java.lang.String,Expr>> |
asRecordLiteral(Expr expr)
If the expression is a record literal, return its fields.
|
static java.util.List<java.util.Map.Entry<java.lang.String,Expr>> |
asRecordType(Expr expr)
If the expression is a record type, return its fields.
|
static java.lang.String |
asSimpleTextLiteral(Expr expr)
If the expression is a
Text literal with no interpolations, return its value. |
static java.util.List<java.util.Map.Entry<java.lang.String,Expr>> |
asUnionType(Expr expr)
If the expression is a union type, return its fields.
|
static byte[] |
decodeHashBytes(java.lang.String input) |
static Expr |
desugarComplete(Expr lhs,
Expr rhs)
Desugar the complete operator (
::). |
static Expr |
desugarWith(Expr base,
java.lang.String[] path,
Expr value)
Desugar
with. |
static java.lang.String |
encodeHashBytes(byte[] hash)
Encode an array of bytes as a hex string.
|
static void |
encodeToStream(Expr expr,
java.io.OutputStream stream)
Write an encoded expression to a stream.
|
static java.lang.String |
escapeText(java.lang.String input,
boolean quoted) |
static java.util.Map.Entry<Expr,Expr> |
getFirstDiff(Expr first,
Expr second)
Return the first difference between the structure of two expressions as a pair.
|
static Expr |
getListArg(Expr expr)
If the expression is an application of
List, return the element type. |
static Expr |
getNoneArg(Expr expr)
If the expression is an application of
None, return the element type. |
static Expr |
getOptionalArg(Expr expr)
If the expression is an application of
Optional, return the element type. |
static Expr |
getSomeArg(Expr expr)
If the expression is an application of
Some, return the element type. |
static Expr |
typeCheck(Expr expr)
Type-check the given expression and return the inferred type.
|
public static final Expr typeCheck(Expr expr)
public static final java.util.Map.Entry<Expr,Expr> getFirstDiff(Expr first, Expr second)
public static final void encodeToStream(Expr expr, java.io.OutputStream stream)
public static java.lang.String encodeHashBytes(byte[] hash)
public static final byte[] decodeHashBytes(java.lang.String input)
public static Expr getListArg(Expr expr)
List, return the element type.public static Expr getOptionalArg(Expr expr)
Optional, return the element type.public static Expr getSomeArg(Expr expr)
Some, return the element type.public static Expr getNoneArg(Expr expr)
None, return the element type.public static final java.lang.Boolean asBoolLiteral(Expr expr)
Bool literal, return its value.public static final java.math.BigInteger asNaturalLiteral(Expr expr)
Natural literal, return its value.public static final java.math.BigInteger asIntegerLiteral(Expr expr)
Integer literal, return its value.public static final java.lang.Double asDoubleLiteral(Expr expr)
Double literal, return its value.public static final java.lang.String asSimpleTextLiteral(Expr expr)
Text literal with no interpolations, return its value.public static final java.lang.String asBuiltIn(Expr expr)
public static final java.util.List<Expr> asListLiteral(Expr expr)
List literal, return its contents.public static final java.util.List<java.util.Map.Entry<java.lang.String,Expr>> asRecordLiteral(Expr expr)
public static final java.util.List<java.util.Map.Entry<java.lang.String,Expr>> asRecordType(Expr expr)
public static final java.util.List<java.util.Map.Entry<java.lang.String,Expr>> asUnionType(Expr expr)
public static final java.util.Map.Entry<Expr,java.lang.String> asFieldAccess(Expr expr)
public static final java.lang.String escapeText(java.lang.String input,
boolean quoted)
public static final Expr desugarComplete(Expr lhs, Expr rhs)
::).public static final Expr desugarWith(Expr base, java.lang.String[] path, Expr value)
with.