Enum BuiltIn

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<BuiltIn>

    public enum BuiltIn
    extends java.lang.Enum<BuiltIn>
    Built-in constants and functions.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ABS
      Function "abs", of type "int → int".
      FALSE
      Literal "false", of type "bool".
      IGNORE
      Function "ignore", of type "α → unit".
      LIST_ALL
      Function "List.all", of type "(α → bool) → α list → bool".
      LIST_APP
      Function "List.app", of type "(α → unit) → α list → unit".
      LIST_AT
      Function "List.at", of type "α list * α list → α list".
      LIST_COLLATE
      Function "List.collate", of type "(α * α → order) → α list * α list → order".
      LIST_CONCAT
      Function "List.concat", of type "α list list → α list".
      LIST_DROP
      Function "List.drop", of type "α list * int → α list".
      LIST_EXISTS
      Function "List.exists", of type "(α → bool) → α list → bool".
      LIST_FILTER
      Function "List.filter", of type "(α → bool) → α list → α list".
      LIST_FIND
      Function "List.find", of type "(α → bool) → α list → α option".
      LIST_FOLDL
      Function "List.foldl", of type "(α * β → β) → β → α list → β".
      LIST_FOLDR
      Function "List.foldr", of type "(α * β → β) → β → α list → β".
      LIST_GET_ITEM
      Function "List.getItem", of type "α list → (α * α list) option".
      LIST_HD
      Function "List.hd", of type "α list → α".
      LIST_LAST
      Function "List.last", of type "α list → α".
      LIST_LENGTH
      Function "List.length", of type "α list → int".
      LIST_MAP
      Function "List.map", of type "(α → β) → α list → β list".
      LIST_MAP_PARTIAL
      Function "List.mapPartial", of type "(α → β option) → α list → β list".
      LIST_NIL
      Constant "List.nil", of type "α list".
      LIST_NTH
      Function "List.nth", of type "α list * int → α".
      LIST_NULL
      Function "List.null", of type "α list → bool".
      LIST_PARTITION
      Function "List.partition", of type "(α → bool) → α list → α list * α list".
      LIST_REV
      Function "List.rev", of type "α list → α list".
      LIST_REV_APPEND
      Function "List.revAppend", of type "α list * α list → α list".
      LIST_TABULATE
      Function "List.tabulate", of type "int * (int → α) → α list".
      LIST_TAKE
      Function "List.take", of type "α list * int → α list".
      LIST_TL
      Function "List.tl", of type "α list → α list".
      NOT
      Function "not", of type "bool → bool".
      RELATIONAL_COUNT
      Function "Relational.count", aka "count", of type "int list → int".
      RELATIONAL_SUM
      Function "Relational.sum", aka "sum", of type "int list → int".
      STRING_CONCAT
      Function "String.concat", of type "string list → string".
      STRING_CONCAT_WITH
      Function "String.concatWith", of type "string → string list → string".
      STRING_EXPLODE
      Function "String.explode", of type "string → char list".
      STRING_EXTRACT
      Function "String.extract", of type "string * int * int option → string".
      STRING_IMPLODE
      Function "String.implode", of type "char list → string".
      STRING_IS_PREFIX
      Function "String.isPrefix", of type "string → string → bool".
      STRING_IS_SUBSTRING
      Function "String.isSubstring", of type "string → string → bool".
      STRING_IS_SUFFIX
      Function "String.isSuffix", of type "string → string → bool".
      STRING_MAP
      Function "String.map", of type "(char → char) → string → string".
      STRING_MAX_SIZE
      Constant "String.maxSize", of type "int".
      STRING_SIZE
      Function "String.size", of type "string → int".
      STRING_STR
      Function "String.str", of type "char → string".
      STRING_SUB
      Function "String.sub", of type "string * int → char".
      STRING_SUBSTRING
      Function "String.substring", of type "string * int * int → string".
      STRING_TRANSLATE
      Function "String.translate", of type "(char → string) → string → string".
      SYS_ENV
      Function "Sys.env", aka "env", of type "unit → string list".
      TRUE
      Literal "true", of type "bool".
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.String alias
      An alias, or null.
      static com.google.common.collect.ImmutableMap<java.lang.String,​BuiltIn> BY_ML_NAME  
      java.lang.String mlName
      The name as it appears in ML's symbol table.
      java.util.function.Function<TypeSystem,​Type> typeFunction
      Derives a type, in a particular type system, for this constant or function.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private BuiltIn​(java.lang.String mlName, java.lang.String alias, java.util.function.Function<TypeSystem,​Type> typeFunction)  
      private BuiltIn​(java.lang.String mlName, java.util.function.Function<TypeSystem,​Type> typeFunction)  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void forEachType​(TypeSystem typeSystem, java.util.function.BiConsumer<java.lang.String,​Type> consumer)
      Calls a consumer once per value.
      static BuiltIn valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static BuiltIn[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

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

      • 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".
      • IGNORE

        public static final BuiltIn IGNORE
        Function "ignore", of type "α → unit".
      • 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 i(th) 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".

        TODO: The current implementation ignores the "int option" last argument.

        "extract (s, i, NONE)" and "extract (s, i, SOME j)" return substrings of s. The first returns the substring of s from the i(th) 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_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 i(th) 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.

      • 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 e) as deptno
               compute sum of (#id e) as sumId
           
      • RELATIONAL_SUM

        public static final BuiltIn RELATIONAL_SUM
        Function "Relational.sum", aka "sum", of type "int list → int".

        Often used with group:

             from e in emps
             group (#deptno e) as deptno
               compute sum of (#id e) as sumId
           
      • SYS_ENV

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

      • mlName

        public final java.lang.String mlName
        The name as it appears in ML's symbol table.
      • alias

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

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

        public static final com.google.common.collect.ImmutableMap<java.lang.String,​BuiltIn> BY_ML_NAME
    • Constructor Detail

      • BuiltIn

        private BuiltIn​(java.lang.String mlName,
                        java.util.function.Function<TypeSystem,​Type> typeFunction)
      • BuiltIn

        private BuiltIn​(java.lang.String mlName,
                        java.lang.String alias,
                        java.util.function.Function<TypeSystem,​Type> typeFunction)
    • Method Detail

      • values

        public static BuiltIn[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (BuiltIn c : BuiltIn.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static BuiltIn valueOf​(java.lang.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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • forEachType

        public static void forEachType​(TypeSystem typeSystem,
                                       java.util.function.BiConsumer<java.lang.String,​Type> consumer)
        Calls a consumer once per value.