Enum BuiltIn

java.lang.Object
java.lang.Enum<BuiltIn>
net.hydromatic.morel.compile.BuiltIn
All Implemented Interfaces:
Serializable, Comparable<BuiltIn>, java.lang.constant.Constable

public enum BuiltIn extends Enum<BuiltIn>
Built-in constants and functions.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static interface 
    Callback used when defining a datatype.
    static class 
    Built-in structure.

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Function "abs", of type "int → int".
    Literal "false", of type "bool".
    Operator "General.op o", of type "(β → γ) * (α → β) → α → γ"
    Function "General.ignore", of type "α → unit".
    Function "Interact.use" of type "string → unit"
    Function "List.all", of type "(α → bool) → α list → bool".
    Function "List.app", of type "(α → unit) → α list → unit".
    Function "List.at", of type "α list * α list → α list".
    Function "List.collate", of type "(α * α → order) → α list * α list → order".
    Function "List.concat", of type "α list list → α list".
    Function "List.drop", of type "α list * int → α list".
    Function "List.exists", of type "(α → bool) → α list → bool".
    Function "List.filter", of type "(α → bool) → α list → α list".
    Function "List.find", of type "(α → bool) → α list → α option".
    Function "List.foldl", of type "(α * β → β) → β → α list → β".
    Function "List.foldr", of type "(α * β → β) → β → α list → β".
    Function "List.getItem", of type "α list → (α * α list) option".
    Function "List.hd", of type "α list → α".
    Function "List.last", of type "α list → α".
    Function "List.length", of type "α list → int".
    Function "List.map", of type "(α → β) → α list → β list".
    Function "List.mapPartial", of type "(α → β option) → α list → β list".
    Constant "List.nil", of type "α list".
    Function "List.nth", of type "α list * int → α".
    Function "List.null", of type "α list → bool".
    Operator "List.op @", of type "α list * α list → α list".
    Function "List.partition", of type "(α → bool) → α list → α list * α list".
    Function "List.rev", of type "α list → α list".
    Function "List.revAppend", of type "α list * α list → α list".
    Function "List.tabulate", of type "int * (int → α) → α list".
    Function "List.take", of type "α list * int → α list".
    Function "List.tl", of type "α list → α list".
    Function "Math.acos", of type "real → real".
    Function "Math.asin", of type "real → real".
    Function "Math.atan", of type "real → real".
    Function "Math.atan2", of type "real *real → real".
    Function "Math.cos", of type "real → real".
    Function "Math.cosh", of type "real → real".
    Constant "Math.e", of type "real", is the base e (2.718281828...) of the natural logarithm.
    Function "Math.exp", of type "real → real".
    Function "Math.ln", of type "real → real".
    Function "Math.log10", of type "real → real".
    Constant "Math.pi", of type "real" is the constant pi (3.141592653...).
    Function "Math.pow", of type "real * real → real".
    Function "Math.sin", of type "real → real".
    Function "Math.sinh", of type "real → real".
    Function "Math.sqrt", of type "real → real".
    Function "Math.tan", of type "real → real".
    Function "Math.tanh", of type "real → real".
    Function "not", of type "bool → bool".
    Infix operator "^", of type "string * string → string".
    Infix operator "::" (list cons), of type "α * α list → α list".
    Infix operator "div", of type "int * int → int".
    Infix operator "/", of type "α * α → α" (where α must be numeric).
    Infix operator "elem", of type "α * α list; → bool".
    Infix operator "=", of type "α * α → bool".
    Infix operator "except", of type "α list * α list → α list".
    Infix operator "≥", of type "α * α → bool" (where α must be comparable).
    Infix operator ">", of type "α * α → bool" (where α must be comparable).
    Infix operator "intersect", of type "α list * α list → α list".
    Infix operator "≤", of type "α * α → bool" (where α must be comparable).
    Infix operator "<", of type "α * α → bool" (where α must be comparable).
    Infix operator "-", of type "α * α → α" (where α must be numeric).
    Infix operator "mod", of type "int * int → int".
    Infix operator "<>", of type "α * α → bool".
    Prefix operator "~", of type "α → α" (where α must be numeric).
    Infix operator "notelem", of type "α * α list; → bool".
    Infix operator "+", of type "α * α → α" (where α must be numeric).
    Infix operator "-", of type "α * α → α" (where α must be numeric).
    Infix operator "union", of type "α list * α list → α list".
    Function "Option.app", of type "(α → unit) → α option → unit".
    Function "Option.compose", of type "(α → β) * (γ → α option) → γ → β option".
    Function "Option.composePartial", of type "(α → β option) * (γ → α option) → γ → β option".
    Function "Option.filter", of type "(α → bool) → α → α option".
    Function "Option.getOpt", of type "α option * α → α".
    Function "Option.isSome", of type "α option → bool".
    Function "Option.join", of type "α option option → α option".
    Function "Option.map", of type "(α → β) → α option → β option".
    Function "Option.mapPartial", of type "(α → β option) → α option → β option".
    Function "Option.valOf", of type "α option → α".
    Function "Real.abs", of type "real → real".
    Function "Real.ceil", of type "real → int".
    Function "Real.checkFloat", of type "real → real".
    Function "Real.compare", of type "real * real → real".
    Function "Real.copySign", of type "real * real → real".
    Function "Real.floor", of type "real → int".
    Function "Real.fromInt", of type "int → real".
    Function "Real.fromManExp r", of type "{exp:int, man:real} → real" returns {man, exp}, where man and exp are the mantissa and exponent of r, respectively.
    Function "Real.fromString s", of type "string → real option", scans a real value from a string.
    Function "Real.isFinite", of type "real → bool".
    Function "Real.isNan", of type "real → bool".
    Function "Real.isNormal", of type "real → bool".
    Function "Real.max", of type "real * real → real".
    Constant "Real.maxFinite", of type "real".
    Function "Real.min", of type "real * real → real".
    Constant "Real.minNormalPos", of type "real".
    Constant "Real.minPos", of type "real".
    Constant "Real.negInf", of type "real".
    Constant "Real.posInf", of type "real".
    Constant "Real.precision", of type "int".
    Constant "Real.radix", of type "int".
    Function "Real.realCeil", of type "real → real".
    Function "Real.realFloor", of type "real → real".
    Function "Real.realMod", of type "real * real → real".
    Function "Real.realRound", of type "real → real".
    Function "Real.realTrunc", of type "real → real".
    Function "Real.rem", of type "real * real → real".
    Function "Real.round", of type "real → int".
    Function "Real.sameSign", of type "real * real → bool".
    Function "Real.sign", of type "real → int".
    Function "Real.signBit", of type "real → bool".
    Function "Real.split", of type "real → {frac:real, whole:real}".
    Function "Real.fromManExp r", of type "{exp:int, man:real} → real" returns {man, exp}, where man and exp are the mantissa and exponent of r, respectively.
    Function "Real.toString", of type "real → string".
    Function "Real.trunc", of type "real → int".
    Function "Real.unordered", of type "real * real → bool".
    Function "Relational.count", aka "count", of type "int list → int".
    Function "Relational.exists", aka "exists", of type "α list → bool".
    Function "Relational.iterate", aka "iterate", of type "α list → (α list → α list → α list) → α list".
    Function "Relational.max", aka "max", of type "α list → α" (where α must be comparable).
    Function "Relational.min", aka "min", of type "α list → α" (where α must be comparable).
    Function "Relational.notExists", aka "notExists", of type "α list → bool".
    Function "Relational.only", aka "only", of type "α list → α".
    Function "Relational.sum", aka "sum", of type "α list → α" (where α must be numeric).
    Function "String.concat", of type "string list → string".
    Function "String.concatWith", of type "string → string list → string".
    Function "String.explode", of type "string → char list".
    Function "String.extract", of type "string * int * int option → string".
    Function "String.implode", of type "char list → string".
    Function "String.isPrefix", of type "string → string → bool".
    Function "String.isSubstring", of type "string → string → bool".
    Function "String.isSuffix", of type "string → string → bool".
    Function "String.map", of type "(char → char) → string → string".
    Constant "String.maxSize", of type "int".
    Function "String.size", of type "string → int".
    Function "String.str", of type "char → string".
    Function "String.sub", of type "string * int → char".
    Function "String.substring", of type "string * int * int → string".
    Function "String.translate", of type "(char → string) → string → string".
    Function "Sys.env", aka "env", of type "unit → string list".
    Value "Sys.file", aka "file", of type "{...}" (partial record).
    Function "Sys.plan", aka "plan", of type "unit → string".
    Function "Sys.set", aka "set", of type "string * α → unit".
    Function "Sys.show", aka "set", of type "string → string option".
    Function "Sys.unset", aka "unset", of type "string → unit".
    Literal "true", of type "bool".
    Function "Vector.all" of type "(α → bool) → α vector → bool".
    Function "Vector.app" of type "(α → unit) → α vector → unit".
    Function "Vector.appi" of type "(int * α → unit) → α vector → unit".
    Function "Vector.collate" of type "(α * α → order) → α vector * α vector → order".
    Function "Vector.concat" of type "α vector list → α vector".
    Function "Vector.exists" of type "(α → bool) → α vector → bool".
    Function "Vector.find" of type "(α → bool) → α vector → α option".
    Function "Vector.findi" of type "(int * α → bool) → α vector → (int * α) option".
    Function "Vector.foldl" of type "(α * β → β) → β → α vector → β".
    Function "Vector.foldli" of type "(int * α * β → β) → β → α vector → β".
    Function "Vector.foldr" of type "(α * β → β) → β → α vector → β".
    Function "Vector.foldri" of type "(int * α * β → β) → β → α vector → β".
    Function "Vector.fromList" of type "α list → α vector".
    Function "Vector.length" of type "α vector → int".
    Function "Vector.map" of type "(α → β) → α vector → β vector".
    Function "Vector.mapi" of type "(int * α → β) → α vector → β vector".
    Constant "Vector.maxLen" of type "int".
    Function "Vector.sub" of type "α vector * int → α".
    Function "Vector.tabulate" of type "int * (int → α) → α vector".
    Function "Vector.update" of type "α vector * int * α → α vector".
    Internal operator "andalso", of type "bool * bool → bool".
    Internal divide operator "/", of type "int * int → int".
    Internal divide operator "/", of type "real * real → real".
    Internal type extent, e.g.
    Internal list constructor, e.g.
    Internal minus operator "-", of type "int * int → int".
    Internal minus operator "-", of type "real * real → real".
    Internal unary negation operator "~", of type "int → int".
    Internal unary negation operator "~", of type "real → real".
    Internal operator "orelse", of type "bool * bool → bool".
    Internal plus operator "+", of type "int * int → int".
    Internal plus operator "+", of type "real * real → real".
    Internal relational sum operator "sum", of type "int * int → int".
    Internal relational sum operator "sum", of type "real * real → real".
    Internal times operator "*", of type "int * int → int".
    Internal times operator "*", of type "real * real → real".
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final String
    An alias, or null.
    static final com.google.common.collect.ImmutableMap<String,BuiltIn>
     
     
    final String
    Unqualified name, e.g.
    private final PrimitiveType
     
    Computes a value for a particular session.
    final String
    Name of the structure (e.g.
    Derives a type, in a particular type system, for this constant or function.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    BuiltIn(@Nullable String structure, String mlName, @Nullable String alias, Function<TypeSystem,Type> typeFunction)
     
    private
    BuiltIn(@Nullable String structure, String mlName, @Nullable String alias, Function<TypeSystem,Type> typeFunction, @Nullable PrimitiveType preferredType, @Nullable Function<Session,Object> sessionValue)
     
    private
    BuiltIn(@Nullable String structure, String mlName, Function<TypeSystem,Type> typeFunction)
     
    private
    BuiltIn(@Nullable String structure, String mlName, PrimitiveType preferredType, Function<TypeSystem,Type> typeFunction)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    dataTypes(TypeSystem typeSystem, List<Binding> bindings)
    Defines built-in datatype and eqtype instances, e.g.
    private static void
    defineDataType(TypeSystem ts, List<Binding> bindings, String name, boolean internal, int varCount, UnaryOperator<BuiltIn.DataTypeHelper> transform)
     
    private static void
    defineEqType(TypeSystem ts, String name, int varCount)
     
    static void
    forEach(TypeSystem typeSystem, BiConsumer<BuiltIn,Type> consumer)
    Calls a consumer once per value.
    static void
    Calls a consumer once per structure.
    void
     
    Returns the reverse comparison operator, R, such that "x this y" if and only if "y R x".
    static BuiltIn
    Returns the enum constant of this type with the specified name.
    static BuiltIn[]
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • TRUE

      public static final BuiltIn TRUE
      Literal "true", of type "bool".
    • FALSE

      public static final BuiltIn FALSE
      Literal "false", of type "bool".
    • NOT

      public static final BuiltIn NOT
      Function "not", of type "bool → bool".
    • ABS

      public static final BuiltIn ABS
      Function "abs", of type "int → int".
    • OP_CARET

      public static final BuiltIn OP_CARET
      Infix operator "^", of type "string * string → string".
    • OP_EXCEPT

      public static final BuiltIn OP_EXCEPT
      Infix operator "except", of type "α list * α list → α list".
    • OP_INTERSECT

      public static final BuiltIn OP_INTERSECT
      Infix operator "intersect", of type "α list * α list → α list".
    • OP_UNION

      public static final BuiltIn OP_UNION
      Infix operator "union", of type "α list * α list → α list".
    • OP_CONS

      public static final BuiltIn OP_CONS
      Infix operator "::" (list cons), of type "α * α list → α list".
    • OP_DIV

      public static final BuiltIn OP_DIV
      Infix operator "div", of type "int * int → int".
    • OP_DIVIDE

      public static final BuiltIn OP_DIVIDE
      Infix operator "/", of type "α * α → α" (where α must be numeric).
    • OP_EQ

      public static final BuiltIn OP_EQ
      Infix operator "=", of type "α * α → bool".
    • OP_GE

      public static final BuiltIn OP_GE
      Infix operator "≥", of type "α * α → bool" (where α must be comparable).
    • OP_GT

      public static final BuiltIn OP_GT
      Infix operator ">", of type "α * α → bool" (where α must be comparable).
    • OP_LE

      public static final BuiltIn OP_LE
      Infix operator "≤", of type "α * α → bool" (where α must be comparable).
    • OP_LT

      public static final BuiltIn OP_LT
      Infix operator "<", of type "α * α → bool" (where α must be comparable).
    • OP_NE

      public static final BuiltIn OP_NE
      Infix operator "<>", of type "α * α → bool".
    • OP_ELEM

      public static final BuiltIn OP_ELEM
      Infix operator "elem", of type "α * α list; → bool".
    • OP_NOT_ELEM

      public static final BuiltIn OP_NOT_ELEM
      Infix operator "notelem", of type "α * α list; → bool".
    • OP_MINUS

      public static final BuiltIn OP_MINUS
      Infix operator "-", of type "α * α → α" (where α must be numeric).
    • OP_MOD

      public static final BuiltIn OP_MOD
      Infix operator "mod", of type "int * int → int".
    • OP_PLUS

      public static final BuiltIn OP_PLUS
      Infix operator "+", of type "α * α → α" (where α must be numeric).
    • OP_NEGATE

      public static final BuiltIn OP_NEGATE
      Prefix operator "~", of type "α → α" (where α must be numeric).
    • OP_TIMES

      public static final BuiltIn OP_TIMES
      Infix operator "-", of type "α * α → α" (where α must be numeric).
    • IGNORE

      public static final BuiltIn IGNORE
      Function "General.ignore", of type "α → unit".
    • GENERAL_OP_O

      public static final BuiltIn GENERAL_OP_O
      Operator "General.op o", of type "(β → γ) * (α → β) → α → γ"

      "f o g" is the function composition of "f" and "g". Thus, "(f o g) a" is equivalent to "f (g a)".

    • INTERACT_USE

      public static final BuiltIn INTERACT_USE
      Function "Interact.use" of type "string → unit"

      "use f" loads source text from the file named `f`.

    • STRING_MAX_SIZE

      public static final BuiltIn STRING_MAX_SIZE
      Constant "String.maxSize", of type "int".

      "The longest allowed size of a string".

    • STRING_SIZE

      public static final BuiltIn STRING_SIZE
      Function "String.size", of type "string → int".

      "size s" returns |s|, the number of characters in string s.

    • STRING_SUB

      public static final BuiltIn STRING_SUB
      Function "String.sub", of type "string * int → char".

      "sub (s, i)" returns the ith character of s, counting from zero. This raises Subscript if i < 0 or |s| ≤ i.

    • STRING_EXTRACT

      public static final BuiltIn STRING_EXTRACT
      Function "String.extract", of type "string * int * int option → string".

      "extract (s, i, NONE)" and "extract (s, i, SOME j)" return substrings of s. The first returns the substring of s from the ith character to the end of the string, i.e., the string s[i..|s|-1]. This raises Subscript if i < 0 or |s| < i.

      The second form returns the substring of size j starting at index i, i.e., the string s[i..i+j-1]. It raises Subscript if i < 0 or j < 0 or |s| < i + j. Note that, if defined, extract returns the empty string when i = |s|.

    • STRING_SUBSTRING

      public static final BuiltIn STRING_SUBSTRING
      Function "String.substring", of type "string * int * int → string".

      "substring (s, i, j)" returns the substring s[i..i+j-1], i.e., the substring of size j starting at index i. This is equivalent to extract(s, i, SOME j).

    • STRING_CONCAT

      public static final BuiltIn STRING_CONCAT
      Function "String.concat", of type "string list → string".

      "concat l" is the concatenation of all the strings in l. This raises Size if the sum of all the sizes is greater than maxSize.

    • STRING_CONCAT_WITH

      public static final BuiltIn STRING_CONCAT_WITH
      Function "String.concatWith", of type "string → string list → string".

      "concatWith s l" returns the concatenation of the strings in the list l using the string s as a separator. This raises Size if the size of the resulting string would be greater than maxSize.

    • STRING_STR

      public static final BuiltIn STRING_STR
      Function "String.str", of type "char → string".

      "str c" is the string of size one containing the character c.

    • STRING_IMPLODE

      public static final BuiltIn STRING_IMPLODE
      Function "String.implode", of type "char list → string".

      "implode l" generates the string containing the characters in the list l. This is equivalent to concat (List.map str l). This raises Size if the resulting string would have size greater than maxSize.

    • STRING_EXPLODE

      public static final BuiltIn STRING_EXPLODE
      Function "String.explode", of type "string → char list".

      "explode s" is the list of characters in the string s.

    • STRING_MAP

      public static final BuiltIn STRING_MAP
      Function "String.map", of type "(char → char) → string → string".

      "map f s" applies f to each element of s from left to right, returning the resulting string. It is equivalent to implode(List.map f (explode s)).

    • STRING_TRANSLATE

      public static final BuiltIn STRING_TRANSLATE
      Function "String.translate", of type "(char → string) → string → string".

      "translate f s" returns the string generated from s by mapping each character in s by f. It is equivalent to {code concat(List.map f (explode s))}.

    • STRING_IS_PREFIX

      public static final BuiltIn STRING_IS_PREFIX
      Function "String.isPrefix", of type "string → string → bool".

      "isPrefix s1 s2" returns true if the string s1 is a prefix of the string s2. Note that the empty string is a prefix of any string, and that a string is a prefix of itself.

    • STRING_IS_SUBSTRING

      public static final BuiltIn STRING_IS_SUBSTRING
      Function "String.isSubstring", of type "string → string → bool".

      "isSubstring s1 s2" returns true if the string s1 is a substring of the string s2. Note that the empty string is a substring of any string, and that a string is a substring of itself.

    • STRING_IS_SUFFIX

      public static final BuiltIn STRING_IS_SUFFIX
      Function "String.isSuffix", of type "string → string → bool".

      "isSuffix s1 s2" returns true if the string s1 is a suffix of the string s2. Note that the empty string is a suffix of any string, and that a string is a suffix of itself.

    • LIST_NIL

      public static final BuiltIn LIST_NIL
      Constant "List.nil", of type "α list".

      "nil" is the empty list.

    • LIST_NULL

      public static final BuiltIn LIST_NULL
      Function "List.null", of type "α list → bool".

      "null l" returns true if the list l is empty.

    • LIST_LENGTH

      public static final BuiltIn LIST_LENGTH
      Function "List.length", of type "α list → int".

      "length l" returns the number of elements in the list l.

    • LIST_AT

      public static final BuiltIn LIST_AT
      Function "List.at", of type "α list * α list → α list".

      "l1 @ l2" returns the list that is the concatenation of l1 and l2.

    • LIST_OP_AT

      public static final BuiltIn LIST_OP_AT
      Operator "List.op @", of type "α list * α list → α list".

      "l1 @ l2" returns the list that is the concatenation of l1 and l2.

    • LIST_HD

      public static final BuiltIn LIST_HD
      Function "List.hd", of type "α list → α".

      "hd l" returns the first element of l. It raises Empty if l is nil.

    • LIST_TL

      public static final BuiltIn LIST_TL
      Function "List.tl", of type "α list → α list".

      "tl l" returns all but the first element of l. It raises empty if l is nil.

    • LIST_LAST

      public static final BuiltIn LIST_LAST
      Function "List.last", of type "α list → α".

      "last l" returns the last element of l. It raises empty if l is nil.

    • LIST_GET_ITEM

      public static final BuiltIn LIST_GET_ITEM
      Function "List.getItem", of type "α list → (α * α list) option".

      "getItem l" returns NONE if the list is empty, and SOME(hd l,tl l) otherwise. This function is particularly useful for creating value readers from lists of characters. For example, Int.scan StringCvt.DEC getItem has the type (int, char list) StringCvt.reader and can be used to scan decimal integers from lists of characters.

    • LIST_NTH

      public static final BuiltIn LIST_NTH
      Function "List.nth", of type "α list * int → α".

      "nth (l, i)" returns the ith element of the list l, counting from 0. It raises Subscript if i < 0 or i >= length l. We have nth(l,0) = hd l, ignoring exceptions.

    • LIST_TAKE

      public static final BuiltIn LIST_TAKE
      Function "List.take", of type "α list * int → α list".

      "take (l, i)" returns the first i elements of the list l. It raises Subscript if i < 0 or i > length l. We have take(l, length l) = l.

    • LIST_DROP

      public static final BuiltIn LIST_DROP
      Function "List.drop", of type "α list * int → α list".

      "drop (l, i)" returns what is left after dropping the first i elements of the list l.

      It raises Subscript if i < 0 or i > length l.

      It holds that take(l, i) @ drop(l, i) = l when 0 ≤ i ≤ length l.

      We also have drop(l, length l) = [].

    • LIST_REV

      public static final BuiltIn LIST_REV
      Function "List.rev", of type "α list → α list".

      "rev l" returns a list consisting of l's elements in reverse order.

    • LIST_CONCAT

      public static final BuiltIn LIST_CONCAT
      Function "List.concat", of type "α list list → α list".

      "concat l" returns the list that is the concatenation of all the lists in l in order. concat[l1,l2,...ln] = l1 @ l2 @ ... @ ln

    • LIST_REV_APPEND

      public static final BuiltIn LIST_REV_APPEND
      Function "List.revAppend", of type "α list * α list → α list".

      "revAppend (l1, l2)" returns (rev l1) @ l2.

    • LIST_APP

      public static final BuiltIn LIST_APP
      Function "List.app", of type "(α → unit) → α list → unit".

      "app f l" applies f to the elements of l, from left to right.

    • LIST_MAP

      public static final BuiltIn LIST_MAP
      Function "List.map", of type "(α → β) → α list → β list".

      "map f l" applies f to each element of l from left to right, returning the list of results.

    • LIST_MAP_PARTIAL

      public static final BuiltIn LIST_MAP_PARTIAL
      Function "List.mapPartial", of type "(α → β option) → α list → β list".

      "mapPartial f l" applies f to each element of l from left to right, returning a list of results, with SOME stripped, where f was defined. f is not defined for an element of l if f applied to the element returns NONE. The above expression is equivalent to: ((map valOf) o (filter isSome) o (map f)) l

    • LIST_FIND

      public static final BuiltIn LIST_FIND
      Function "List.find", of type "(α → bool) → α list → α option".

      "find f l" applies f to each element x of the list l, from left to right, until f x evaluates to true. It returns SOME(x) if such an x exists; otherwise it returns NONE.

    • LIST_FILTER

      public static final BuiltIn LIST_FILTER
      Function "List.filter", of type "(α → bool) → α list → α list".

      "filter f l" applies f to each element x of l, from left to right, and returns the list of those x for which f x evaluated to true, in the same order as they occurred in the argument list.

    • LIST_PARTITION

      public static final BuiltIn LIST_PARTITION
      Function "List.partition", of type "(α → bool) → α list → α list * α list".

      "partition f l" applies f to each element x of l, from left to right, and returns a pair (pos, neg) where pos is the list of those x for which f x evaluated to true, and neg is the list of those for which f x evaluated to false. The elements of pos and neg retain the same relative order they possessed in l.

    • LIST_FOLDL

      public static final BuiltIn LIST_FOLDL
      Function "List.foldl", of type "(α * β → β) → β → α list → β".

      "foldl f init [x1, x2, ..., xn]" returns f(xn,...,f(x2, f(x1, init))...) or init if the list is empty.

    • LIST_FOLDR

      public static final BuiltIn LIST_FOLDR
      Function "List.foldr", of type "(α * β → β) → β → α list → β".

      "foldr f init [x1, x2, ..., xn]" returns f(x1, f(x2, ..., f(xn, init)...)) or init if the list is empty.

    • LIST_EXISTS

      public static final BuiltIn LIST_EXISTS
      Function "List.exists", of type "(α → bool) → α list → bool".

      "exists f l" applies f to each element x of the list l, from left to right, until f x evaluates to true; it returns true if such an x exists and false otherwise.

    • LIST_ALL

      public static final BuiltIn LIST_ALL
      Function "List.all", of type "(α → bool) → α list → bool".

      "all f l" applies f to each element x of the list l, from left to right, until f x evaluates to false; it returns false if such an x exists and true otherwise. It is equivalent to not(exists (not o f) l)).

    • LIST_TABULATE

      public static final BuiltIn LIST_TABULATE
      Function "List.tabulate", of type "int * (int → α) → α list".

      "tabulate (n, f)" returns a list of length n equal to [f(0), f(1), ..., f(n-1)], created from left to right. It raises Size if n < 0.

    • LIST_COLLATE

      public static final BuiltIn LIST_COLLATE
      Function "List.collate", of type "(α * α → order) → α list * α list → order".

      "collate f (l1, l2)" performs lexicographic comparison of the two lists using the given ordering f on the list elements.

    • MATH_ACOS

      public static final BuiltIn MATH_ACOS
      Function "Math.acos", of type "real → real".

      "acos x" returns the arc cosine of x. acos is the inverse of cos. Its result is guaranteed to be in the closed interval [0,pi]. If the magnitude of x exceeds 1.0, returns NaN.

    • MATH_ASIN

      public static final BuiltIn MATH_ASIN
      Function "Math.asin", of type "real → real".

      "asin x" returns the arc sine of x. asin is the inverse of sin. Its result is guaranteed to be in the closed interval [-pi / 2, pi / 2]. If the magnitude of x exceeds 1.0, returns NaN.

    • MATH_ATAN

      public static final BuiltIn MATH_ATAN
      Function "Math.atan", of type "real → real".

      "atan x" returns the arc tangent of x. atan is the inverse of tan. For finite arguments, the result is guaranteed to be in the open interval (-pi / 2, pi / 2). If x is +infinity, it returns pi / 2; if x is -infinity, it returns -pi / 2.

    • MATH_ATAN2

      public static final BuiltIn MATH_ATAN2
      Function "Math.atan2", of type "real *real → real".

      "atan2 (x, y)" returns the arc tangent of (y / x) in the closed interval [-pi, pi], corresponding to angles within +-180 degrees. The quadrant of the resulting angle is determined using the signs of both x and y, and is the same as the quadrant of the point (x, y). When x = 0, this corresponds to an angle of 90 degrees, and the result is (real (sign y)) * pi / 2.0. It holds that

       sign (cos (atan2 (y, x))) = sign (x)

      and

      sign (sin (atan2 (y, x))) = sign (y)

      except for inaccuracies incurred by the finite precision of real and the approximation algorithms used to compute the mathematical functions. Rules for exceptional cases are specified in the following table.

      
          y                 x         atan2(y, x)
          ================= ========= ==========
          +-0               0 < x     +-0
          +-0               +0        +-0
          +-0               x < 0     +-pi
          +-0               -0        +-pi
          y, 0 < y          +-0       pi/2
          y, y < 0          +-0       -pi/2
          +-y, finite y > 0 +infinity +-0
          +-y, finite y > 0 -infinity +-pi
          +-infinity        finite x  +-pi/2
          +-infinity        +infinity +-pi/4
          +-infinity        -infinity +-3pi/4
       
    • MATH_COS

      public static final BuiltIn MATH_COS
      Function "Math.cos", of type "real → real".

      "cos x" returns the cosine of x, measured in radians. If x is an infinity, returns NaN.

    • MATH_COSH

      public static final BuiltIn MATH_COSH
      Function "Math.cosh", of type "real → real".

      "cosh x" returns the hyperbolic cosine of x, that is, (e(x) + e(-x)) / 2. It has the properties cosh +-0 = 1, cosh +-infinity = +-infinity.

    • MATH_E

      public static final BuiltIn MATH_E
      Constant "Math.e", of type "real", is the base e (2.718281828...) of the natural logarithm.
    • MATH_EXP

      public static final BuiltIn MATH_EXP
      Function "Math.exp", of type "real → real".

      "exp x" returns e(x), i.e., e raised to the x(th) power. If x is +infinity, it returns +infinity; if x is -infinity, it returns 0.

    • MATH_LN

      public static final BuiltIn MATH_LN
      Function "Math.ln", of type "real → real".

      "ln x" returns the natural logarithm (base e) of x. If x < 0, returns NaN; if x = 0, returns -infinity; if x is infinity, returns infinity.

    • MATH_LOG10

      public static final BuiltIn MATH_LOG10
      Function "Math.log10", of type "real → real".

      "log10 x" returns the decimal logarithm (base 10) of x. If x < 0, returns NaN; if x = 0, returns -infinity; if x is infinity, returns infinity.

    • MATH_PI

      public static final BuiltIn MATH_PI
      Constant "Math.pi", of type "real" is the constant pi (3.141592653...).
    • MATH_POW

      public static final BuiltIn MATH_POW
      Function "Math.pow", of type "real * real → real".

      "pow x" returns x(y), i.e., x raised to the y(th) power. For finite x and y, this is well-defined when x > 0, or when x < 0 and y is integral. Rules for exceptional cases are specified below.

      
          x                 y                             pow(x,y)
          ================= ============================= ==========
          x, including NaN  0                             1
          |x| > 1           +infinity                     +infinity
          |x| < 1           +infinity                     +0
          |x| > 1           -infinity                     +0
          |x| < 1           -infinity                     +infinity
          +infinity         y > 0                         +infinity
          +infinity         y < 0                         +0
          -infinity         y > 0, odd integer            -infinity
          -infinity         y > 0, not odd integer        +infinity
          -infinity         y < 0, odd integer            -0
          -infinity         y < 0, not odd integer        +0
          x                 NaN                           NaN
          NaN               y <> 0                        NaN
          +-1               +-infinity                    NaN
          finite x < 0      finite non-integer y          NaN
          +-0               y < 0, odd integer            +-infinity
          +-0               finite y < 0, not odd integer +infinity
          +-0               y > 0, odd integer            +-0
          +-0               y > 0, not odd integer        +0
       
    • MATH_SIN

      public static final BuiltIn MATH_SIN
      Function "Math.sin", of type "real → real".

      "sin x" returns the sine of x, measured in radians. If x is an infinity, returns NaN.

    • MATH_SINH

      public static final BuiltIn MATH_SINH
      Function "Math.sinh", of type "real → real".

      "sinh x" returns the hyperbolic sine of x, that is, (e(x) - e(-x)) / 2. It has the property sinh +-0 = +-0, sinh +-infinity = +-infinity.

    • MATH_SQRT

      public static final BuiltIn MATH_SQRT
      Function "Math.sqrt", of type "real → real".

      "sqrt x" returns the square root of x. sqrt (~0.0) = ~0.0. If x < 0, it returns NaN.

    • MATH_TAN

      public static final BuiltIn MATH_TAN
      Function "Math.tan", of type "real → real".

      "tan x" returns the tangent of x, measured in radians. If x is an infinity, these returns NaN. Produces infinities at various finite values, roughly corresponding to the singularities of the tangent function.

    • MATH_TANH

      public static final BuiltIn MATH_TANH
      Function "Math.tanh", of type "real → real".

      "tanh x" returns the hyperbolic tangent of x, that is, (sinh x) / (cosh x). It has the properties tanh +-0 = +-0, tanh +-infinity = +-1.

    • OPTION_GET_OPT

      public static final BuiltIn OPTION_GET_OPT
      Function "Option.getOpt", of type "α option * α → α".

      getOpt(opt, a) returns v if opt is SOME(v); otherwise it returns a.

    • OPTION_IS_SOME

      public static final BuiltIn OPTION_IS_SOME
      Function "Option.isSome", of type "α option → bool".

      isSome opt returns true if opt is SOME(v); otherwise it returns false.

    • OPTION_VAL_OF

      public static final BuiltIn OPTION_VAL_OF
      Function "Option.valOf", of type "α option → α".

      valOf opt returns v if opt is SOME(v); otherwise it raises Option.

    • OPTION_FILTER

      public static final BuiltIn OPTION_FILTER
      Function "Option.filter", of type "(α → bool) → α → α option".

      filter f a returns SOME(a) if f(a) is true and NONE otherwise.

    • OPTION_JOIN

      public static final BuiltIn OPTION_JOIN
      Function "Option.join", of type "α option option → α option".

      join opt maps NONE to NONE and SOME(v) to v.

      Because join is a keyword in Morel, you must quote the function name using backticks. For example:

      
       Option.`join` (SOME (SOME 1));
       > val it = SOME 1 : int option
       
    • OPTION_APP

      public static final BuiltIn OPTION_APP
      Function "Option.app", of type "(α → unit) → α option → unit".

      app f opt applies the function f to the value v if opt is SOME(v), and otherwise does nothing.

    • OPTION_MAP

      public static final BuiltIn OPTION_MAP
      Function "Option.map", of type "(α → β) → α option → β option".

      map f opt maps NONE to NONE and SOME(v) to SOME(f v).

    • OPTION_MAP_PARTIAL

      public static final BuiltIn OPTION_MAP_PARTIAL
      Function "Option.mapPartial", of type "(α → β option) → α option → β option".

      mapPartial f opt maps NONE to NONE and SOME(v) to f (v).

    • OPTION_COMPOSE

      public static final BuiltIn OPTION_COMPOSE
      Function "Option.compose", of type "(α → β) * (γ → α option) → γ → β option".

      compose (f, g) a returns NONE if g(a) is NONE; otherwise, if g(a) is SOME(v), it returns SOME(f v).

      Thus, the compose function composes f with the partial function g to produce another partial function. The expression compose (f, g) is equivalent to (map f) o g.

    • OPTION_COMPOSE_PARTIAL

      public static final BuiltIn OPTION_COMPOSE_PARTIAL
      Function "Option.composePartial", of type "(α → β option) * (γ → α option) → γ → β option".

      composePartial (f, g) a returns NONE if g(a) is NONE; otherwise, if g(a) is SOME(v), it returns f(v).

      Thus, the composePartial function composes the two partial functions f and g to produce another partial function. The expression composePartial (f, g) is equivalent to (mapPartial f) o g.

    • REAL_ABS

      public static final BuiltIn REAL_ABS
      Function "Real.abs", of type "real → real".

      Returns the absolute value of r.

    • REAL_CEIL

      public static final BuiltIn REAL_CEIL
      Function "Real.ceil", of type "real → int".

      Returns largest int not larger than r.

    • REAL_CHECK_FLOAT

      public static final BuiltIn REAL_CHECK_FLOAT
      Function "Real.checkFloat", of type "real → real".

      "checkFloat x" raises Overflow if x is an infinity, and raises Div if x is NaN. Otherwise, it returns its argument.

    • REAL_COMPARE

      public static final BuiltIn REAL_COMPARE
      Function "Real.compare", of type "real * real → real".

      Returns x with the sign of y, even if y is NaN.

    • REAL_COPY_SIGN

      public static final BuiltIn REAL_COPY_SIGN
      Function "Real.copySign", of type "real * real → real".

      Returns x with the sign of y, even if y is NaN.

    • REAL_FLOOR

      public static final BuiltIn REAL_FLOOR
      Function "Real.floor", of type "real → int".

      Returns smallest int not less than r.

    • REAL_FROM_INT

      public static final BuiltIn REAL_FROM_INT
      Function "Real.fromInt", of type "int → real". Converts the integer i to a real value. If the absolute value of i is larger than maxFinite, then the appropriate infinity is returned. If i cannot be exactly represented as a real value, then the current rounding mode is used to determine the resulting value. The top-level function real is an alias for Real.fromInt.
    • REAL_FROM_MAN_EXP

      public static final BuiltIn REAL_FROM_MAN_EXP
      Function "Real.fromManExp r", of type "{exp:int, man:real} → real" returns {man, exp}, where man and exp are the mantissa and exponent of r, respectively.
    • REAL_FROM_STRING

      public static final BuiltIn REAL_FROM_STRING
      Function "Real.fromString s", of type "string → real option", scans a real value from a string. Returns SOME(r) if a real value can be scanned from a prefix of s, ignoring any initial whitespace; otherwise, it returns NONE. This function is equivalent to StringCvt.scanString scan.
    • REAL_IS_FINITE

      public static final BuiltIn REAL_IS_FINITE
      Function "Real.isFinite", of type "real → bool".

      "isFinite x" returns true if x is neither NaN nor an infinity.

    • REAL_IS_NAN

      public static final BuiltIn REAL_IS_NAN
      Function "Real.isNan", of type "real → bool".

      "isNan x" returns true if x is NaN.

    • REAL_IS_NORMAL

      public static final BuiltIn REAL_IS_NORMAL
      Function "Real.isNormal", of type "real → bool".

      "isNormal x" returns true if x is normal, i.e., neither zero, subnormal, infinite nor NaN.

    • REAL_NEG_INF

      public static final BuiltIn REAL_NEG_INF
      Constant "Real.negInf", of type "real".

      The negative infinity value.

    • REAL_POS_INF

      public static final BuiltIn REAL_POS_INF
      Constant "Real.posInf", of type "real".

      The positive infinity value.

    • REAL_RADIX

      public static final BuiltIn REAL_RADIX
      Constant "Real.radix", of type "int".

      The base of the representation, e.g., 2 or 10 for IEEE floating point.

    • REAL_PRECISION

      public static final BuiltIn REAL_PRECISION
      Constant "Real.precision", of type "int".

      The number of digits, each between 0 and radix - 1, in the mantissa. Note that the precision includes the implicit (or hidden) bit used in the IEEE representation (e.g., the value of Real64.precision is 53).

    • REAL_MAX

      public static final BuiltIn REAL_MAX
      Function "Real.max", of type "real * real → real".

      Returns the returns the larger of the arguments. If exactly one argument is NaN, returns the other argument. If both arguments are NaN, returns NaN.

    • REAL_MAX_FINITE

      public static final BuiltIn REAL_MAX_FINITE
      Constant "Real.maxFinite", of type "real".

      The maximum finite number.

    • REAL_MIN

      public static final BuiltIn REAL_MIN
      Function "Real.min", of type "real * real → real".

      Returns the returns the larger of the arguments. If exactly one argument is NaN, returns the other argument. If both arguments are NaN, returns NaN.

    • REAL_MIN_POS

      public static final BuiltIn REAL_MIN_POS
      Constant "Real.minPos", of type "real".

      The minimum non-zero positive number.

    • REAL_MIN_NORMAL_POS

      public static final BuiltIn REAL_MIN_NORMAL_POS
      Constant "Real.minNormalPos", of type "real".

      The minimum non-zero normalized number.

    • REAL_REAL_MOD

      public static final BuiltIn REAL_REAL_MOD
      Function "Real.realMod", of type "real * real → real".

      Returns the fractional part of r. "realMod" is equivalent to "#frac o split".

    • REAL_REAL_CEIL

      public static final BuiltIn REAL_REAL_CEIL
      Function "Real.realCeil", of type "real → real".

      Returns the smallest integer-valued real not less than r.

    • REAL_REAL_FLOOR

      public static final BuiltIn REAL_REAL_FLOOR
      Function "Real.realFloor", of type "real → real".

      Returns the largest integer-valued real not larger than r.

    • REAL_REAL_ROUND

      public static final BuiltIn REAL_REAL_ROUND
      Function "Real.realRound", of type "real → real".

      Returns the integer-valued real nearest to r. In the case of a tie, it rounds to the nearest even integer.

    • REAL_REAL_TRUNC

      public static final BuiltIn REAL_REAL_TRUNC
      Function "Real.realTrunc", of type "real → real".

      Returns the r rounded towards zero.

    • REAL_REM

      public static final BuiltIn REAL_REM
      Function "Real.rem", of type "real * real → real".

      Returns the remainder x - n * y, where n = trunc (x / y). The result has the same sign as x and has absolute value less than the absolute value of y. If x is an infinity or y is 0, returns NaN. If y is an infinity, returns x.

    • REAL_ROUND

      public static final BuiltIn REAL_ROUND
      Function "Real.round", of type "real → int".

      Returns the integer nearest to r. In the case of a tie, it rounds to the nearest even integer.

    • REAL_SAME_SIGN

      public static final BuiltIn REAL_SAME_SIGN
      Function "Real.sameSign", of type "real * real → bool".

      Returns true if and only if signBit r1 equals signBit r2.

    • REAL_SIGN

      public static final BuiltIn REAL_SIGN
      Function "Real.sign", of type "real → int".

      Returns ~1 if r is negative, 0 if r is zero, or 1 if r is positive. An infinity returns its sign; a zero returns 0 regardless of its sign. It raises Domain on NaN.

    • REAL_SIGN_BIT

      public static final BuiltIn REAL_SIGN_BIT
      Function "Real.signBit", of type "real → bool".

      Returns true if and only if the sign of r (infinities, zeros, and NaN, included) is negative.

    • REAL_SPLIT

      public static final BuiltIn REAL_SPLIT
      Function "Real.split", of type "real → {frac:real, whole:real}".

      Returns {frac, whole}, where frac and whole are the fractional and integral parts of r, respectively. Specifically, whole is integral, |frac| < 1.0, whole and frac have the same sign as r, and r = whole + frac.

      This function is comparable to modf in the C library. If r is +-infinity, whole is +-infinity and frac is +-0. If r is NaN, both whole and frac are NaN.

    • REAL_TO_MAN_EXP

      public static final BuiltIn REAL_TO_MAN_EXP
      Function "Real.fromManExp r", of type "{exp:int, man:real} → real" returns {man, exp}, where man and exp are the mantissa and exponent of r, respectively.
    • REAL_TO_STRING

      public static final BuiltIn REAL_TO_STRING
      Function "Real.toString", of type "real → string".

      "toString r" converts reals into strings. The value returned by toString t is equivalent to:

      
       (fmt (StringCvt.GEN NONE) r)
       
    • REAL_TRUNC

      public static final BuiltIn REAL_TRUNC
      Function "Real.trunc", of type "real → int".

      Returns r rounded towards zero.

    • REAL_UNORDERED

      public static final BuiltIn REAL_UNORDERED
      Function "Real.unordered", of type "real * real → bool".

      "unordered (x, y) returns true if x and y are unordered, i.e., at least one of x and y is NaN.

    • RELATIONAL_COUNT

      public static final BuiltIn RELATIONAL_COUNT
      Function "Relational.count", aka "count", of type "int list → int".

      Often used with group:

           from e in emps
           group deptno = (#deptno e)
             compute sumId = sum of (#id e)
         
    • RELATIONAL_EXISTS

      public static final BuiltIn RELATIONAL_EXISTS
      Function "Relational.exists", aka "exists", of type "α list → bool".

      For example,

      
       from d in depts
       where exists (
         from e in emps
         where e.deptno = d.deptno
         andalso e.job = 'CLERK')
       
    • RELATIONAL_NOT_EXISTS

      public static final BuiltIn RELATIONAL_NOT_EXISTS
      Function "Relational.notExists", aka "notExists", of type "α list → bool".

      For example,

      
       from d in depts
       where notExists (
         from e in emps
         where e.deptno = d.deptno
         andalso e.job = 'CLERK')
       

      notExists list is equivalent to not (exists list), but the former may be more convenient, because it requires fewer parentheses.

    • RELATIONAL_ONLY

      public static final BuiltIn RELATIONAL_ONLY
      Function "Relational.only", aka "only", of type "α list → α".

      "only list" returns the only element of list. It raises Empty if list is nil, Size if list has more than one element.

      "only" allows you to write the equivalent of a scalar sub-query:

      
       from e in emps
       yield {e.ename, dname = only (from d in depts
                                     where d.deptno = e.deptno
                                     yield d.dname)}
       
    • RELATIONAL_ITERATE

      public static final BuiltIn RELATIONAL_ITERATE
      Function "Relational.iterate", aka "iterate", of type "α list → (α list → α list → α list) → α list".

      "iterate initialList listUpdate" computes a fixed point, starting with a list and iterating by passing it to a function.

    • RELATIONAL_SUM

      public static final BuiltIn RELATIONAL_SUM
      Function "Relational.sum", aka "sum", of type "α list → α" (where α must be numeric).

      Often used with group:

           from e in emps
           group deptno = (#deptno e)
             compute sumId = sum of (#id e)
         
    • RELATIONAL_MAX

      public static final BuiltIn RELATIONAL_MAX
      Function "Relational.max", aka "max", of type "α list → α" (where α must be comparable).
    • RELATIONAL_MIN

      public static final BuiltIn RELATIONAL_MIN
      Function "Relational.min", aka "min", of type "α list → α" (where α must be comparable).
    • SYS_ENV

      public static final BuiltIn SYS_ENV
      Function "Sys.env", aka "env", of type "unit → string list".
    • SYS_FILE

      public static final BuiltIn SYS_FILE
      Value "Sys.file", aka "file", of type "{...}" (partial record).

      Its value is not global; each session has a private value. This allows the type to be different for each session, and reduces concern thread-safety concerns.

    • SYS_PLAN

      public static final BuiltIn SYS_PLAN
      Function "Sys.plan", aka "plan", of type "unit → string".
    • SYS_SET

      public static final BuiltIn SYS_SET
      Function "Sys.set", aka "set", of type "string * α → unit".
    • SYS_SHOW

      public static final BuiltIn SYS_SHOW
      Function "Sys.show", aka "set", of type "string → string option".
    • SYS_UNSET

      public static final BuiltIn SYS_UNSET
      Function "Sys.unset", aka "unset", of type "string → unit".
    • VECTOR_MAX_LEN

      public static final BuiltIn VECTOR_MAX_LEN
      Constant "Vector.maxLen" of type "int".

      The maximum length of vectors supported by this implementation. Attempts to create larger vectors will result in the Size exception being raised.

    • VECTOR_FROM_LIST

      public static final BuiltIn VECTOR_FROM_LIST
      Function "Vector.fromList" of type "α list → α vector".

      fromList l creates a new vector from l, whose length is length l and with the ith element of l used as the ith element of the vector. If the length of the list is greater than maxLen, then the Size exception is raised.

    • VECTOR_TABULATE

      public static final BuiltIn VECTOR_TABULATE
      Function "Vector.tabulate" of type "int * (int → α) → α vector".

      tabulate (n, f) creates a vector of n elements, where the elements are defined in order of increasing index by applying f to the element's index. This is equivalent to the expression:

      fromList (List.tabulate (n, f))

      If n < 0 or maxLen < n, then the Size exception is raised.

    • VECTOR_LENGTH

      public static final BuiltIn VECTOR_LENGTH
      Function "Vector.length" of type "α vector → int".

      length vec returns |vec|, the length of the vector vec.

    • VECTOR_SUB

      public static final BuiltIn VECTOR_SUB
      Function "Vector.sub" of type "α vector * int → α".

      sub (vec, i) returns the ith element of the vector vec. If i < 0 or |vec| <= i, then the Subscript exception is raised.

    • VECTOR_UPDATE

      public static final BuiltIn VECTOR_UPDATE
      Function "Vector.update" of type "α vector * int * α → α vector".

      update (vec, i, x) returns a new vector, identical to vec, except the ith element of vec is set to x. If i < 0 or |vec| <= i, then the Subscript exception is raised.

    • VECTOR_CONCAT

      public static final BuiltIn VECTOR_CONCAT
      Function "Vector.concat" of type "α vector list → α vector".

      concat l returns the vector that is the concatenation of the vectors in the list l. If the total length of these vectors exceeds maxLen, then the Size exception is raised.

    • VECTOR_APPI

      public static final BuiltIn VECTOR_APPI
      Function "Vector.appi" of type "(int * α → unit) → α vector → unit".

      appi f vec applies the function f to the elements of a vector in left to right order (i.e., in order of increasing indices). The appi function is more general than app, and supplies both the element and the element's index to the function f. Equivalent to:

      List.app f (foldri (fn (i,a,l) => (i,a)::l) [] vec)
    • VECTOR_APP

      public static final BuiltIn VECTOR_APP
      Function "Vector.app" of type "(α → unit) → α vector → unit".

      app f vec applies the function f to the elements of a vector in left to right order (i.e., in order of increasing indices). Equivalent to:

      List.app f (foldr (fn (a,l) => a::l) [] vec)
    • VECTOR_MAPI

      public static final BuiltIn VECTOR_MAPI
      Function "Vector.mapi" of type "(int * α → β) → α vector → β vector".

      mapi f vec produces a new vector by mapping the function f from left to right over the argument vector. The form mapi is more general, and supplies f with the vector index of an element along with the element. Equivalent to:

      fromList (List.map f (foldri (fn (i,a,l) => (i,a)::l) [] vec))
    • VECTOR_MAP

      public static final BuiltIn VECTOR_MAP
      Function "Vector.map" of type "(α → β) → α vector → β vector".

      map f vec produces a new vector by mapping the function f from left to right over the argument vector. Equivalent to:

      fromList (List.map f (foldr (fn (a,l) => a::l) [] vec))
    • VECTOR_FOLDLI

      public static final BuiltIn VECTOR_FOLDLI
      Function "Vector.foldli" of type "(int * α * β → β) → β → α vector → β".

      foldli f init vec folds the function f over all the elements of a vector, using the value init as the initial value. Applies the function f from left to right (increasing indices). The functions foldli and foldri are more general, and supply both the element and the element's index to the function f.

    • VECTOR_FOLDRI

      public static final BuiltIn VECTOR_FOLDRI
      Function "Vector.foldri" of type "(int * α * β → β) → β → α vector → β".

      foldri f init vec folds the function f over all the elements of a vector, using the value init as the initial value. Applies the function f from right to left (decreasing indices). The functions foldli and foldri are more general, and supply both the element and the element's index to the function f.

    • VECTOR_FOLDL

      public static final BuiltIn VECTOR_FOLDL
      Function "Vector.foldl" of type "(α * β → β) → β → α vector → β".

      foldl f init vec folds the function f over all the elements of a vector, using the value init as the initial value. Applies the function f from left to right (increasing indices). Equivalent to

      foldli (fn (_, a, x) => f(a, x)) init vec
    • VECTOR_FOLDR

      public static final BuiltIn VECTOR_FOLDR
      Function "Vector.foldr" of type "(α * β → β) → β → α vector → β".

      foldr f init vec folds the function f over all the elements of a vector, using the value init as the initial value. Applies the function f from right to left (decreasing indices). Equivalent to

      foldri (fn (_, a, x) => f(a, x)) init vec
    • VECTOR_FINDI

      public static final BuiltIn VECTOR_FINDI
      Function "Vector.findi" of type "(int * α → bool) → α vector → (int * α) option".

      findi f vec applies f to each element of the vector vec, from left to right (i.e., increasing indices), until a true value is returned. If this occurs, the function returns the element; otherwise, it return NONE. The function findi is more general than find, and also supplies f with the vector index of the element and, upon finding an entry satisfying the predicate, returns that index with the element.

    • VECTOR_FIND

      public static final BuiltIn VECTOR_FIND
      Function "Vector.find" of type "(α → bool) → α vector → α option".

      find f vec applies f to each element of the vector vec, from left to right (i.e., increasing indices), until a true value is returned. If this occurs, the function returns the element; otherwise, it returns NONE.

    • VECTOR_EXISTS

      public static final BuiltIn VECTOR_EXISTS
      Function "Vector.exists" of type "(α → bool) → α vector → bool".

      exists f vec applies f to each element x of the vector vec, from left to right (i.e., increasing indices), until f(x) evaluates to true; it returns true if such an x exists and false otherwise.

    • VECTOR_ALL

      public static final BuiltIn VECTOR_ALL
      Function "Vector.all" of type "(α → bool) → α vector → bool".

      all f vec applies f to each element x of the vector vec, from left to right (i.e., increasing indices), until f(x) evaluates to false; it returns false if such an x exists and true otherwise. It is equivalent to not (exists (not o f) vec)).

    • VECTOR_COLLATE

      public static final BuiltIn VECTOR_COLLATE
      Function "Vector.collate" of type "(α * α → order) → α vector * α vector → order".

      collate f (v1, v2) performs lexicographic comparison of the two vectors using the given ordering f on elements.

    • Z_ANDALSO

      public static final BuiltIn Z_ANDALSO
      Internal operator "andalso", of type "bool * bool → bool".
    • Z_ORELSE

      public static final BuiltIn Z_ORELSE
      Internal operator "orelse", of type "bool * bool → bool".
    • Z_NEGATE_INT

      public static final BuiltIn Z_NEGATE_INT
      Internal unary negation operator "~", of type "int → int".
    • Z_NEGATE_REAL

      public static final BuiltIn Z_NEGATE_REAL
      Internal unary negation operator "~", of type "real → real".
    • Z_DIVIDE_INT

      public static final BuiltIn Z_DIVIDE_INT
      Internal divide operator "/", of type "int * int → int".
    • Z_DIVIDE_REAL

      public static final BuiltIn Z_DIVIDE_REAL
      Internal divide operator "/", of type "real * real → real".
    • Z_MINUS_INT

      public static final BuiltIn Z_MINUS_INT
      Internal minus operator "-", of type "int * int → int".
    • Z_MINUS_REAL

      public static final BuiltIn Z_MINUS_REAL
      Internal minus operator "-", of type "real * real → real".
    • Z_PLUS_INT

      public static final BuiltIn Z_PLUS_INT
      Internal plus operator "+", of type "int * int → int".
    • Z_PLUS_REAL

      public static final BuiltIn Z_PLUS_REAL
      Internal plus operator "+", of type "real * real → real".
    • Z_TIMES_INT

      public static final BuiltIn Z_TIMES_INT
      Internal times operator "*", of type "int * int → int".
    • Z_TIMES_REAL

      public static final BuiltIn Z_TIMES_REAL
      Internal times operator "*", of type "real * real → real".
    • Z_SUM_INT

      public static final BuiltIn Z_SUM_INT
      Internal relational sum operator "sum", of type "int * int → int".
    • Z_SUM_REAL

      public static final BuiltIn Z_SUM_REAL
      Internal relational sum operator "sum", of type "real * real → real".
    • Z_EXTENT

      public static final BuiltIn Z_EXTENT
      Internal type extent, e.g. "extent: bool list" returns "[false, true]", "extent: (int * bool) list" returns "[(0, false), (0, true), (1, false), (1, true), ...]".

      These returns are hypothetical; except for bool and some algebraic types, the extent is practically infinite. It will need to be removed during planning.

      Its type is "unit → * α list". It would not be possible to derive the type if "extent" were used in code.

    • Z_LIST

      public static final BuiltIn Z_LIST
      Internal list constructor, e.g. "list (1 + 2, 3)" implements "[1 + 2, 3]". It cannot be assigned a type, because the tuple is variadic.
  • Field Details

    • structure

      public final String structure
      Name of the structure (e.g. "List", "String"), or null.
    • mlName

      public final String mlName
      Unqualified name, e.g. "map" (for "List.map") or "true".
    • alias

      public final String alias
      An alias, or null. For example, "List.map" has an alias "map".
    • typeFunction

      public final Function<TypeSystem,Type> typeFunction
      Derives a type, in a particular type system, for this constant or function.
    • preferredType

      private final PrimitiveType preferredType
    • sessionValue

      public final Function<Session,Object> sessionValue
      Computes a value for a particular session.
    • BY_ML_NAME

      public static final com.google.common.collect.ImmutableMap<String,BuiltIn> BY_ML_NAME
    • BY_STRUCTURE

      public static final SortedMap<String,BuiltIn.Structure> BY_STRUCTURE
  • Constructor Details

  • Method Details

    • values

      public static BuiltIn[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static BuiltIn valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • forEach

      public static void forEach(TypeSystem typeSystem, BiConsumer<BuiltIn,Type> consumer)
      Calls a consumer once per value.
    • forEachStructure

      public static void forEachStructure(TypeSystem typeSystem, BiConsumer<BuiltIn.Structure,Type> consumer)
      Calls a consumer once per structure.
    • dataTypes

      public static void dataTypes(TypeSystem typeSystem, List<Binding> bindings)
      Defines built-in datatype and eqtype instances, e.g. option, vector.
    • defineEqType

      private static void defineEqType(TypeSystem ts, String name, int varCount)
    • defineDataType

      private static void defineDataType(TypeSystem ts, List<Binding> bindings, String name, boolean internal, int varCount, UnaryOperator<BuiltIn.DataTypeHelper> transform)
    • reverse

      public BuiltIn reverse()
      Returns the reverse comparison operator, R, such that "x this y" if and only if "y R x".
    • prefer

      public void prefer(Consumer<PrimitiveType> consumer)