mirror of
https://github.com/enso-org/enso.git
synced 2024-11-22 22:10:15 +03:00
Add PRIVATE so function hidden from Component Browser and other tidying... (#6207)
Review the set of public functions. Mark many as PRIVATE so not in CB. Some other small tidying.
This commit is contained in:
parent
fef70ed911
commit
a05cee2571
@ -49,7 +49,8 @@ type Any
|
||||
pretty : Text
|
||||
pretty self = @Builtin_Method "Any.pretty"
|
||||
|
||||
## Generic conversion of an arbitrary Enso value to a corresponding short
|
||||
## PRIVATE
|
||||
Generic conversion of an arbitrary Enso value to a corresponding short
|
||||
human-readable representation.
|
||||
|
||||
> Example
|
||||
|
@ -77,19 +77,20 @@ type Array
|
||||
new_4 : Any -> Any -> Any -> Any -> Array
|
||||
new_4 item_1 item_2 item_3 item_4 = @Builtin_Method "Array.new_4"
|
||||
|
||||
## Copies from the source array, beginning at the specified position, to the
|
||||
## PRIVATE
|
||||
Copies from the source array, beginning at the specified position, to the
|
||||
specified position in the destination array.
|
||||
|
||||
Arguments:
|
||||
- src: The source array.
|
||||
- source_index: The start position in the src array.
|
||||
- dest: The desination array.
|
||||
- dest: The destination array.
|
||||
- dest_index: The start position in the that array.
|
||||
|
||||
A subsequence of array elements are copied from the src array to the
|
||||
dest array. The number of components copied is equal to count. The
|
||||
components at positions source_index through source_index + count - 1
|
||||
in the strc array are copied into positions dest_index through
|
||||
in the src array are copied into positions dest_index through
|
||||
dest_index + count - 1, respectively, of the destination array.
|
||||
|
||||
If the src and dest arguments refer to the same array, then the copy
|
||||
@ -150,7 +151,6 @@ type Array
|
||||
self.sort_builtin comparator
|
||||
|
||||
## Identity.
|
||||
|
||||
This method is implemented purely for completeness with the runtime's
|
||||
primitive array protocol.
|
||||
to_array : Array
|
||||
|
@ -3,7 +3,8 @@ import project.Data.Array.Array
|
||||
import project.Data.Numbers.Integer
|
||||
import project.Errors.Illegal_Argument.Illegal_Argument
|
||||
|
||||
## A helper type used for creating an array from a length and a callback
|
||||
## PRIVATE
|
||||
A helper type used for creating an array from a length and a callback
|
||||
providing its elements.
|
||||
|
||||
It can be used to create an array from some non-standard underlying storage
|
||||
@ -13,8 +14,8 @@ import project.Errors.Illegal_Argument.Illegal_Argument
|
||||
vector backed by such custom storage.
|
||||
@Builtin_Type
|
||||
type Array_Proxy
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a new `Array_Proxy` from a length and a callback.
|
||||
|
||||
Arguments:
|
||||
@ -38,8 +39,8 @@ type Array_Proxy
|
||||
new_builtin : Integer -> (Integer -> Any) -> Array
|
||||
new_builtin length at = @Builtin_Method "Array_Proxy.new_builtin"
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a new `Array_Proxy` from an object providing `length` and `at`
|
||||
methods.
|
||||
from_proxy_object : Any -> Array
|
||||
|
@ -1,4 +1,5 @@
|
||||
import project.Any.Any
|
||||
import project.Data.Boolean.Boolean
|
||||
import project.Data.Text.Case_Sensitivity.Case_Sensitivity
|
||||
import project.Data.Text.Extensions
|
||||
import project.Data.Text.Regex
|
||||
@ -157,6 +158,7 @@ type Filter_Condition
|
||||
## Converts a `Filter_Condition` condition into a predicate taking an
|
||||
element and returning a value indicating whether the element should be
|
||||
accepted by the filter.
|
||||
to_predicate : (Any -> Boolean)
|
||||
to_predicate self = case self of
|
||||
Less value -> <value
|
||||
Equal_Or_Less value -> <=value
|
||||
|
@ -55,10 +55,10 @@ type Json
|
||||
|
||||
Check the `message` field for detailed information on the specific failure.
|
||||
type Invalid_JSON
|
||||
## PRIVATE
|
||||
Error message
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Converts the error to a display representation.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
@ -69,8 +69,7 @@ type Invalid_JSON
|
||||
A failure indicating the inability to marshall a `Json` object into the
|
||||
specified format.
|
||||
type Marshalling_Error
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
|
||||
The `json` object could not be converted into `format`, due to a type
|
||||
mismatch.
|
||||
@ -82,8 +81,7 @@ type Marshalling_Error
|
||||
This can occur e.g. when trying to reinterpret a number as a `Text`, etc.
|
||||
Type_Mismatch json format
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
The `json` object could not be converted into `format`, due to a field
|
||||
missing in the `json` structure.
|
||||
|
||||
@ -96,8 +94,7 @@ type Marshalling_Error
|
||||
when the JSON does not contain all the fields required by the atom.
|
||||
Missing_Field json field format
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Convert the marshalling error into a human-readable format.
|
||||
to_display_text : Text
|
||||
to_display_text self = case self of
|
||||
@ -108,8 +105,10 @@ type Marshalling_Error
|
||||
Marshalling_Error.Missing_Field _ field _ ->
|
||||
"Missing field in Json: the field `" + field.to_text "` was missing in the json."
|
||||
|
||||
## PRIVATE
|
||||
type JS_Object
|
||||
## Creates a JS_Object from a list of key-value pairs.
|
||||
## PRIVATE
|
||||
Creates a JS_Object from a list of key-value pairs.
|
||||
Keys must be `Text` values.
|
||||
Values will be recursively converted to JSON serializable as needed.
|
||||
from_pairs : Vector -> JS_Object
|
||||
@ -163,11 +162,13 @@ type JS_Object
|
||||
proxy = Array_Proxy.new keys.length (i-> Pair.new (keys.at i) (self.get (keys.at i)))
|
||||
Vector.from_polyglot_array proxy
|
||||
|
||||
## Convert the object to a JS_Object.
|
||||
## PRIVATE
|
||||
Convert the object to a JS_Object.
|
||||
to_js_object : JS_Object
|
||||
to_js_object self = self
|
||||
|
||||
## Convert to a Text.
|
||||
## PRIVATE
|
||||
Convert to a Text.
|
||||
to_text : Text
|
||||
to_text self = Json.stringify self
|
||||
|
||||
@ -175,8 +176,7 @@ type JS_Object
|
||||
to_json : Text
|
||||
to_json self = self.to_text
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Transform the vector into text for displaying as part of its default
|
||||
visualization.
|
||||
to_default_visualization_data : Text
|
||||
@ -185,6 +185,7 @@ type JS_Object
|
||||
|
||||
## PRIVATE
|
||||
type JS_Object_Comparator
|
||||
## PRIVATE
|
||||
compare : JS_Object -> JS_Object -> (Ordering|Nothing)
|
||||
compare obj1 obj2 =
|
||||
obj1_keys = obj1.field_names
|
||||
@ -193,6 +194,7 @@ type JS_Object_Comparator
|
||||
(obj1.get key == obj2.at key).catch No_Such_Key _->False
|
||||
if same_values then Ordering.Equal else Nothing
|
||||
|
||||
## PRIVATE
|
||||
hash : JS_Object -> Integer
|
||||
hash obj =
|
||||
values_hashes = obj.field_names.map field_name->
|
||||
@ -203,7 +205,6 @@ type JS_Object_Comparator
|
||||
|
||||
Comparable.from (_:JS_Object) = JS_Object_Comparator
|
||||
|
||||
|
||||
## PRIVATE
|
||||
Render the JS_Object to Text with truncated depth.
|
||||
render object depth=0 max_depth=5 max_length=100 = case object of
|
||||
|
@ -28,7 +28,8 @@ Any.to_json self = Json.stringify self
|
||||
Error.to_json : Text
|
||||
Error.to_json self = self.to_js_object.to_text
|
||||
|
||||
## Converts the given value to a JSON serializable object.
|
||||
## PRIVATE
|
||||
Converts the given value to a JSON serializable object.
|
||||
For Nothing, booleans, numbers and strings, this is the value itself.
|
||||
For arrays or vectors, the elements are converted recursively.
|
||||
For atoms and maps, the object is converted to a JS_Object.
|
||||
@ -37,7 +38,8 @@ Text.to_js_object self = case self of
|
||||
Text -> JS_Object.from_pairs [["type", "Text"]]
|
||||
_ -> self
|
||||
|
||||
## Converts the given value to a JSON serializable object.
|
||||
## PRIVATE
|
||||
Converts the given value to a JSON serializable object.
|
||||
For Nothing, booleans, numbers and strings, this is the value itself.
|
||||
For arrays or vectors, the elements are converted recursively.
|
||||
For atoms and maps, the object is converted to a JS_Object.
|
||||
@ -53,7 +55,8 @@ Number.to_js_object self = case self of
|
||||
JS_Object.from_pairs [["type", "BigInt"], ["value", self.to_text]]
|
||||
_ -> self
|
||||
|
||||
## Converts the given value to a JSON serializable object.
|
||||
## PRIVATE
|
||||
Converts the given value to a JSON serializable object.
|
||||
For Nothing, booleans, numbers and strings, this is the value itself.
|
||||
For arrays or vectors, the elements are converted recursively.
|
||||
For atoms and maps, the object is converted to a JS_Object.
|
||||
@ -62,14 +65,16 @@ Boolean.to_js_object self = case self of
|
||||
Boolean -> JS_Object.from_pairs [["type", "Boolean"]]
|
||||
_ -> self
|
||||
|
||||
## Converts the given value to a JSON serializable object.
|
||||
## PRIVATE
|
||||
Converts the given value to a JSON serializable object.
|
||||
For Nothing, booleans, numbers and strings, this is the value itself.
|
||||
For arrays or vectors, the elements are converted recursively.
|
||||
For atoms and maps, the object is converted to a JS_Object.
|
||||
Nothing.to_js_object : Nothing
|
||||
Nothing.to_js_object self = self
|
||||
|
||||
## Converts the given value to a JSON serializable object.
|
||||
## PRIVATE
|
||||
Converts the given value to a JSON serializable object.
|
||||
For Nothing, booleans, numbers and strings, this is the value itself.
|
||||
For arrays or vectors, the elements are converted recursively.
|
||||
For atoms and maps, the object is converted to a JS_Object.
|
||||
@ -79,7 +84,8 @@ Array.to_js_object self =
|
||||
proxy = Array_Proxy.new stripped.length i-> stripped.at i . to_js_object
|
||||
Vector.from_polyglot_array proxy
|
||||
|
||||
## Converts the given value to a JSON serializable object.
|
||||
## PRIVATE
|
||||
Converts the given value to a JSON serializable object.
|
||||
For Nothing, booleans, numbers and strings, this is the value itself.
|
||||
For arrays or vectors, the elements are converted recursively.
|
||||
For atoms, the object is converted to a JS_Object.
|
||||
@ -89,7 +95,8 @@ Vector.to_js_object self =
|
||||
proxy = Array_Proxy.new stripped.length i-> stripped.at i . to_js_object
|
||||
Vector.from_polyglot_array proxy
|
||||
|
||||
## Converts the given value to a JSON serializable object.
|
||||
## PRIVATE
|
||||
Converts the given value to a JSON serializable object.
|
||||
For Nothing, booleans, numbers and strings, this is the value itself.
|
||||
For arrays or vectors, the elements are converted recursively.
|
||||
For atoms, the object is converted to a JS_Object.
|
||||
@ -115,7 +122,8 @@ Any.to_js_object self =
|
||||
JS_Object.from_pairs [["type", type_name], ["constructor", m.name]]
|
||||
_ -> Error.throw ("Cannot convert " + self.to_text + " to JSON")
|
||||
|
||||
## Converts the given value to a JSON serializable object.
|
||||
## PRIVATE
|
||||
Converts the given value to a JSON serializable object.
|
||||
For Nothing, booleans, numbers and strings, this is the value itself.
|
||||
For arrays or vectors, the elements are converted recursively.
|
||||
For atoms, the object is converted to a JS_Object.
|
||||
@ -127,7 +135,8 @@ Error.to_js_object self =
|
||||
error_message = ["message", caught.to_display_text]
|
||||
JS_Object.from_pairs [error_type, error_content, error_message]
|
||||
|
||||
## Converts the given value to a JSON serializable object.
|
||||
## PRIVATE
|
||||
Converts the given value to a JSON serializable object.
|
||||
Custom serialization for Locale, serializes the language, country and variant.
|
||||
Locale.to_js_object : JS_Object
|
||||
Locale.to_js_object self =
|
||||
@ -139,7 +148,8 @@ Locale.to_js_object self =
|
||||
b.append ["variant", self.variant]
|
||||
JS_Object.from_pairs b.to_vector
|
||||
|
||||
## Converts the given value to a JSON serializable object.
|
||||
## PRIVATE
|
||||
Converts the given value to a JSON serializable object.
|
||||
For Map, this is serialized as a Vector of Key-Value pairs.
|
||||
|
||||
Enso Maps support arbitrary types as map keys, so we cannot serialize them into JS Objects because there only strings are accepted as keys.
|
||||
|
@ -464,7 +464,8 @@ type List
|
||||
builder.append elem
|
||||
builder.to_vector
|
||||
|
||||
## Generates a human-readable text representation of the list.
|
||||
## PRIVATE
|
||||
Generates a human-readable text representation of the list.
|
||||
to_text : Text
|
||||
to_text self =
|
||||
go l t e = case l of
|
||||
|
@ -38,8 +38,8 @@ type Locale
|
||||
java_locale = JavaLocale.new language country_text variant_text
|
||||
Locale.Value java_locale
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Convert a java locale to an Enso locale.
|
||||
|
||||
Arguments:
|
||||
@ -410,13 +410,7 @@ type Locale
|
||||
disp = self.java_locale.getDisplayVariant
|
||||
if disp.is_empty then Nothing else disp
|
||||
|
||||
## Converts the locale to text.
|
||||
|
||||
> Example
|
||||
Convert the default locale to text.
|
||||
|
||||
import Standard.Base.Data.Locale.Locale
|
||||
|
||||
example_to_text = Locale.default.to_text
|
||||
## PRIVATE
|
||||
Converts the locale to text.
|
||||
to_text : Text | Nothing
|
||||
to_text self = self.java_locale.toLanguageTag
|
||||
|
@ -349,7 +349,8 @@ type Map key value
|
||||
to_vector : Vector Any
|
||||
to_vector self = @Builtin_Method "Map.to_vector"
|
||||
|
||||
## Returns a text representation of this Map.
|
||||
## PRIVATE
|
||||
Returns a text representation of this Map.
|
||||
to_text : Text
|
||||
to_text self = @Builtin_Method "Map.to_text"
|
||||
|
||||
|
@ -942,10 +942,10 @@ type Integer
|
||||
A syntax error when parsing a double.
|
||||
@Builtin_Type
|
||||
type Number_Parse_Error
|
||||
## PRIVATE
|
||||
Error text
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the syntax error.
|
||||
to_display_text : Text
|
||||
to_display_text =
|
||||
|
@ -132,9 +132,11 @@ type Comparable
|
||||
comp = Comparable.from atom
|
||||
(comp.is_a Default_Comparator).not
|
||||
|
||||
## Default implementation of a _comparator_.
|
||||
## PRIVATE
|
||||
Default implementation of a _comparator_.
|
||||
@Builtin_Type
|
||||
type Default_Comparator
|
||||
## PRIVATE
|
||||
compare : Any -> Any -> (Ordering|Nothing)
|
||||
compare x y =
|
||||
case Comparable.equals_builtin x y of
|
||||
@ -149,13 +151,12 @@ type Default_Comparator
|
||||
True -> Ordering.Greater
|
||||
False -> Nothing
|
||||
|
||||
## PRIVATE
|
||||
hash : Number -> Integer
|
||||
hash x = Comparable.hash_builtin x
|
||||
|
||||
|
||||
Comparable.from (_:Any) = Default_Comparator
|
||||
|
||||
|
||||
## Types representing the ordering of values.
|
||||
@Builtin_Type
|
||||
type Ordering
|
||||
@ -191,7 +192,6 @@ type Ordering
|
||||
Ordering.Equal -> 0
|
||||
|
||||
## A lexicographical comparison.
|
||||
|
||||
and_then : Ordering -> Ordering
|
||||
and_then self ~other = case self of
|
||||
Ordering.Less -> Ordering.Less
|
||||
@ -211,8 +211,12 @@ type Ordering
|
||||
from_sign sign = if sign == 0 then Ordering.Equal else
|
||||
if sign > 0 then Ordering.Greater else Ordering.Less
|
||||
|
||||
## PRIVATE
|
||||
type Ordering_Comparator
|
||||
## PRIVATE
|
||||
compare x y = (Comparable.from x.to_sign).compare x.to_sign y.to_sign
|
||||
|
||||
## PRIVATE
|
||||
hash x = x.to_sign
|
||||
|
||||
Comparable.from (_:Ordering) = Ordering_Comparator
|
||||
|
@ -19,7 +19,8 @@ type Sort_Direction
|
||||
Sort_Direction.Descending
|
||||
Descending
|
||||
|
||||
## Convert into the sign of the direction
|
||||
## PRIVATE
|
||||
Convert into the sign of the direction
|
||||
to_sign : Integer
|
||||
to_sign self = case self of
|
||||
Sort_Direction.Ascending -> 1
|
||||
|
@ -78,7 +78,8 @@ type Fitted_Model
|
||||
## Fitted power series (y = a x ^ b).
|
||||
Power a:Number b:Number r_squared:Number=0.0
|
||||
|
||||
## Display the fitted line.
|
||||
## PRIVATE
|
||||
Display the fitted line.
|
||||
to_text : Text
|
||||
to_text self =
|
||||
equation = case self of
|
||||
|
@ -127,7 +127,8 @@ type Statistic
|
||||
- predicted: the series to compute the r_squared with.
|
||||
R_Squared (predicted:Vector)
|
||||
|
||||
## Gets the order needed to compute a statistic for a moment based statistic.
|
||||
## PRIVATE
|
||||
Gets the order needed to compute a statistic for a moment based statistic.
|
||||
order : Integer | Nothing
|
||||
order self = case self of
|
||||
Statistic.Sum -> 1
|
||||
|
@ -111,8 +111,6 @@ type Text
|
||||
not_empty self = self.is_empty.not
|
||||
|
||||
## PRIVATE
|
||||
UNSTABLE
|
||||
|
||||
Conversion to Text that overrides the default `to_text` behavior.
|
||||
to_text : Text
|
||||
to_text self = self
|
||||
|
@ -11,7 +11,9 @@ polyglot java import org.enso.base.Text_Utils
|
||||
|
||||
## Represents a character encoding.
|
||||
type Encoding
|
||||
## Get all available character sets from Java as Encodings.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Get all available character sets from Java as Encodings.
|
||||
Used to provide auto completion in the UI.
|
||||
all_character_sets : Vector Text
|
||||
all_character_sets =
|
||||
@ -30,7 +32,8 @@ type Encoding
|
||||
charset = Charset.forName name
|
||||
Encoding.Value charset.name
|
||||
|
||||
## Create a new Encoding object.
|
||||
## PRIVATE
|
||||
Create a new Encoding object.
|
||||
|
||||
Arguments:
|
||||
- character_set: java.nio.charset name.
|
||||
@ -76,7 +79,6 @@ type Encoding
|
||||
windows_1251 = Encoding.Value "windows-1251"
|
||||
|
||||
## ALIAS ISO-8859-1
|
||||
|
||||
Encoding for Western European (Windows).
|
||||
windows_1252 : Encoding
|
||||
windows_1252 = Encoding.Value "windows-1252"
|
||||
@ -86,7 +88,6 @@ type Encoding
|
||||
windows_1253 = Encoding.Value "windows-1253"
|
||||
|
||||
## ALIAS ISO-8859-9
|
||||
|
||||
Encoding for Turkish (Windows).
|
||||
windows_1254 : Encoding
|
||||
windows_1254 = Encoding.Value "windows-1254"
|
||||
|
@ -13,7 +13,8 @@ type Line_Ending_Style
|
||||
The text equivalent is `'\r\n'`.
|
||||
Mac_Legacy
|
||||
|
||||
## Returns the text equivalent of the line ending.
|
||||
## PRIVATE
|
||||
Returns the text equivalent of the line ending.
|
||||
to_text : Text
|
||||
to_text self = case self of
|
||||
Line_Ending_Style.Unix -> '\n'
|
||||
|
@ -40,9 +40,7 @@ compile self expression case_insensitive=Nothing =
|
||||
|
||||
Pattern.Value internal_regex_object
|
||||
|
||||
## ADVANCED
|
||||
|
||||
Escape the special characters in `expression` such that the result is a
|
||||
## Escape the special characters in `expression` such that the result is a
|
||||
valid literal pattern for the original string.
|
||||
|
||||
Arguments:
|
||||
@ -63,10 +61,10 @@ escape self expression = Regex_Utils.regexQuote expression
|
||||
Arguments:
|
||||
- id: The identifier of the group that was asked for but does not exist.
|
||||
type No_Such_Group
|
||||
## PRIVATE
|
||||
Error (id : Text | Integer)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Provides a human-readable representation of the `No_Such_Group`.
|
||||
to_display_text : Text
|
||||
to_display_text self = case self.id of
|
||||
|
@ -261,9 +261,9 @@ type Match
|
||||
## match.named_groups.keys.sort == ["empty", "letters"]
|
||||
named_groups : Any -> Map Text (Text | Any)
|
||||
named_groups self default=Nothing =
|
||||
named_group_names = self.pattern.group_names
|
||||
spans = named_group_names.map name-> self.text name default=default
|
||||
Map.from_vector (named_group_names.zip spans)
|
||||
pattern_named_groups = self.pattern.named_groups
|
||||
Map.from_vector <|
|
||||
pattern_named_groups.map name-> [name, self.text name default=default]
|
||||
|
||||
## Gets the grapheme span matched by the group with the provided index, or
|
||||
a default value if the group did not participate in the match.
|
||||
|
@ -102,9 +102,7 @@ type Pattern
|
||||
Helpers.expect_text input <|
|
||||
self.match_all input . map match_to_group_maybe
|
||||
|
||||
## ADVANCED
|
||||
|
||||
Splits the `input` text based on the pattern described by `self`.
|
||||
## Splits the `input` text based on the pattern described by `self`.
|
||||
|
||||
Arguments:
|
||||
- input: The text to split based on the pattern described by `self`.
|
||||
@ -148,9 +146,7 @@ type Pattern
|
||||
go it.next
|
||||
builder.to_vector
|
||||
|
||||
## ADVANCED
|
||||
|
||||
Takes an input string and returns all the matches as a `Vector Text`.
|
||||
## Takes an input string and returns all the matches as a `Vector Text`.
|
||||
If the pattern contains marked groups, the values are concatenated
|
||||
together; otherwise the whole match is returned. Non-participating
|
||||
groups are omitted.
|
||||
@ -177,9 +173,7 @@ type Pattern
|
||||
tokenize self input =
|
||||
self.match_all input . map (build_tokenization_output_from_match self _)
|
||||
|
||||
## ADVANCED
|
||||
|
||||
Replace all occurrences of the pattern described by `self` in the `input`
|
||||
## Replace all occurrences of the pattern described by `self` in the `input`
|
||||
with the specified `replacement`.
|
||||
|
||||
Arguments:
|
||||
@ -320,8 +314,8 @@ type Pattern
|
||||
group_count self = self.internal_regex_object.groupCount
|
||||
|
||||
## Return a vector of all named group names.
|
||||
group_names : Map Text Integer
|
||||
group_names self =
|
||||
named_groups : Vector Text
|
||||
named_groups self =
|
||||
map = polyglot_map_to_map self.internal_regex_object.groups
|
||||
map.keys
|
||||
|
||||
@ -342,12 +336,15 @@ type Pattern
|
||||
the string, unmatched, as a single Last value. (Used for `replace` with
|
||||
`only_first=True`.)
|
||||
type Match_Iterator
|
||||
## PRIVATE
|
||||
new : Pattern -> Text -> Match_Iterator
|
||||
new pattern input = Match_Iterator.Value pattern input 0
|
||||
|
||||
## PRIVATE
|
||||
Value (pattern : Pattern) (input : Text) (cursor : Integer)
|
||||
|
||||
## Return the next match, or the last filler string if there is no
|
||||
## PRIVATE
|
||||
Return the next match, or the last filler string if there is no
|
||||
additional match.
|
||||
|
||||
Also returns the next iterator, if there was a match.
|
||||
@ -368,30 +365,21 @@ type Match_Iterator
|
||||
next_iterator = Match_Iterator.Value self.pattern self.input next_cursor
|
||||
Match_Iterator_Value.Next filler_span match next_iterator
|
||||
|
||||
## Returns the remainder of the string, unmatched.
|
||||
## PRIVATE
|
||||
Returns the remainder of the string, unmatched.
|
||||
early_exit : Match_Iterator_Value
|
||||
early_exit self =
|
||||
filler_range = Range.new self.cursor (Text_Utils.char_length self.input)
|
||||
filler_span = Utf_16_Span.Value filler_range self.input
|
||||
Match_Iterator_Value.Last filler_span
|
||||
|
||||
to_text_debug : Vector Text
|
||||
to_text_debug self =
|
||||
vb = Vector.new_builder
|
||||
go it = case it.next of
|
||||
Match_Iterator_Value.Next filler match next_it ->
|
||||
vb.append ('\"' + filler.text + '\"')
|
||||
vb.append ("/" + (match.span 0).text + "/")
|
||||
go next_it
|
||||
Match_Iterator_Value.Last filler ->
|
||||
vb.append ('\"' + filler.text + '\"')
|
||||
go self
|
||||
vb.to_vector
|
||||
|
||||
## PRIVATE
|
||||
type Match_Iterator_Value
|
||||
Next (filler : Span) (match : Match) (next_iterator : Match_Iterator)
|
||||
Last (filler : Span)
|
||||
## PRIVATE
|
||||
Next (filler : Span) (match : Match) (next_iterator : Match_Iterator)
|
||||
|
||||
## PRIVATE
|
||||
Last (filler : Span)
|
||||
|
||||
## PRIVATE
|
||||
Convert the polyglot map to a Map.
|
||||
|
@ -35,7 +35,8 @@ type Replacer
|
||||
all the strings together to form the full replacement string.
|
||||
Value (replacement : Vector Replacement)
|
||||
|
||||
## Creates a new Replacer.
|
||||
## PRIVATE
|
||||
Creates a new Replacer.
|
||||
|
||||
Arguments
|
||||
- replacement_string: a string, possibly containing group references,
|
||||
@ -44,7 +45,8 @@ type Replacer
|
||||
new replacement_string pattern =
|
||||
Replacer.Value (build_replacement_vector_cached replacement_string pattern)
|
||||
|
||||
## Build a replacement string from a match.
|
||||
## PRIVATE
|
||||
Build a replacement string from a match.
|
||||
|
||||
Arguments:
|
||||
- match: the match from the original string that is to be replaced.
|
||||
@ -136,9 +138,12 @@ parse_group_number pattern match = case match.text.take 2 of
|
||||
n = Integer.parse <| match.text 2
|
||||
Replacement.Substitution (pattern.lookup_group n)
|
||||
|
||||
## PRIVATE
|
||||
type Replacement
|
||||
## A string literal to replace with.
|
||||
## PRIVATE
|
||||
A string literal to replace with.
|
||||
Literal (text : Text)
|
||||
|
||||
## Target group to insert.
|
||||
## PRIVATE
|
||||
Target group to insert.
|
||||
Substitution (group_number : Integer)
|
||||
|
@ -82,7 +82,8 @@ type Span
|
||||
text : Text
|
||||
text self = self.to_utf_16_span.text
|
||||
|
||||
## Converts the span of extended grapheme clusters to a corresponding span
|
||||
## ADVANCED
|
||||
Converts the span of extended grapheme clusters to a corresponding span
|
||||
of UTF-16 code units.
|
||||
|
||||
> Example
|
||||
|
@ -539,7 +539,8 @@ type Date
|
||||
_ ->
|
||||
Error.throw (Illegal_Argument.Error "Illegal period argument")
|
||||
|
||||
## Convert to a JS_Object representing this Date.
|
||||
## PRIVATE
|
||||
Convert to a JS_Object representing this Date.
|
||||
|
||||
> Example
|
||||
Convert the current date to a JS_Object.
|
||||
|
@ -584,18 +584,8 @@ type Date_Time
|
||||
Time_Utils.datetime_adjust self Time_Utils.AdjustOp.MINUS period.internal_period
|
||||
ensure_in_epoch result result
|
||||
|
||||
## Convert this time to text using the default formatter.
|
||||
|
||||
> Example
|
||||
Convert the current time to text.
|
||||
|
||||
from Standard.Base import Date_Time
|
||||
|
||||
example_to_text = Date_Time.now.to_text
|
||||
to_text : Text
|
||||
to_text self = @Builtin_Method "Date_Time.to_text"
|
||||
|
||||
## Convert to a JavaScript Object representing a Date_Time.
|
||||
## PRIVATE
|
||||
Convert to a JavaScript Object representing a Date_Time.
|
||||
|
||||
> Example
|
||||
Convert the current time to a JS_Object.
|
||||
|
@ -56,11 +56,15 @@ type Day_Of_Week
|
||||
|
||||
## PRIVATE
|
||||
type Day_Of_Week_Comparator
|
||||
## PRIVATE
|
||||
compare : Day_Of_Week -> Day_Of_Week -> Ordering
|
||||
compare x y =
|
||||
x_int = x.to_integer
|
||||
y_int = y.to_integer
|
||||
Comparable.from x_int . compare x_int y_int
|
||||
|
||||
## PRIVATE
|
||||
hash : Day_Of_Week -> Integer
|
||||
hash x = x.to_integer
|
||||
|
||||
Comparable.from (_:Day_Of_Week) = Day_Of_Week_Comparator
|
||||
|
@ -244,28 +244,8 @@ type Duration
|
||||
total_hours : Decimal ! Illegal_State
|
||||
total_hours self = self.total_minutes / 60.0
|
||||
|
||||
## Convert this duration to a Vector of hours, minutes, seconds, milliseconds
|
||||
and nanoseconds.
|
||||
|
||||
> Example
|
||||
Convert a duration of one hour to a vector resulting in
|
||||
`[1, 0, 30, 0, 0]`.
|
||||
|
||||
import Standard.Base.Data.Time.Duration
|
||||
|
||||
example_to_vec = (Duration.new hours=1 seconds=30).to_vector
|
||||
|
||||
> Example
|
||||
Convert duration of 800 nanoseconds to a vector returning
|
||||
`[0, 0, 0, 0, 0, 800]`
|
||||
|
||||
import Standard.Base.Data.Time.Duration
|
||||
|
||||
example_to_vec = (Duration.new nanoseconds=800)).to_vector
|
||||
to_vector : Vector Integer
|
||||
to_vector self = [self.hours, self.minutes, self.seconds, self.milliseconds, self.nanoseconds]
|
||||
|
||||
## Convert to a JavaScript Object representing a Duration.
|
||||
## PRIVATE
|
||||
Convert to a JavaScript Object representing a Duration.
|
||||
|
||||
> Example
|
||||
Convert a duration of 10 seconds to a JS_Object.
|
||||
@ -282,14 +262,3 @@ type Duration
|
||||
if self.milliseconds==0 . not then b.append ["milliseconds", self.milliseconds]
|
||||
if self.nanoseconds==0 . not then b.append ["nanoseconds", self.nanoseconds]
|
||||
JS_Object.from_pairs b.to_vector
|
||||
|
||||
## Check if this duration represents an empty time-span.
|
||||
|
||||
> Example
|
||||
Check if the duration of 10 seconds is empty.
|
||||
|
||||
import Standard.Base.Data.Time.Duration
|
||||
|
||||
example_is_empty = Duration.zero.is_empty
|
||||
is_empty : Boolean
|
||||
is_empty self = self.to_vector . all (==0)
|
||||
|
@ -284,7 +284,8 @@ type Time_Of_Day
|
||||
duration : Duration -> self.minus_builtin duration
|
||||
_ : Period -> Error.throw (Time_Error.Error "Time_Of_Day does not support date intervals (periods)")
|
||||
|
||||
## Convert to a JavaScript Object representing this Time_Of_Day.
|
||||
## PRIVATE
|
||||
Convert to a JavaScript Object representing this Time_Of_Day.
|
||||
|
||||
> Example
|
||||
Convert the current time to a JS_Object.
|
||||
|
@ -156,7 +156,8 @@ type Time_Zone
|
||||
zone_id : Text
|
||||
zone_id self = @Builtin_Method "Time_Zone.zone_id"
|
||||
|
||||
## Convert to a JavaScript Object representing this Time_Zone.
|
||||
## PRIVATE
|
||||
Convert to a JavaScript Object representing this Time_Zone.
|
||||
|
||||
> Example
|
||||
Convert your system's current timezone to a JS_Object.
|
||||
|
@ -66,7 +66,8 @@ type Vector a
|
||||
new : Integer -> (Integer -> Any) -> Vector Any
|
||||
new length constructor = @Builtin_Method "Vector.new"
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Converts an array into a vector by copying content of the array.
|
||||
|
||||
@ -122,7 +123,8 @@ type Vector a
|
||||
new_builder : Integer -> Builder
|
||||
new_builder (capacity=10) = Builder.new capacity
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Converts a polyglot value representing an array into a vector.
|
||||
|
||||
@ -136,7 +138,8 @@ type Vector a
|
||||
from_polyglot_array : Any -> Vector Any
|
||||
from_polyglot_array array = @Builtin_Method "Vector.from_polyglot_array"
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Copies content of a vector into an Array.
|
||||
to_array self = @Builtin_Method "Vector.to_array"
|
||||
|
||||
@ -591,16 +594,14 @@ type Vector a
|
||||
reverse : Vector Any
|
||||
reverse self = Vector.new self.length (i -> self.at (self.length - (1 + i)))
|
||||
|
||||
## Generates a human-readable text representation of the vector.
|
||||
|
||||
> Example
|
||||
Convert a vector of numbers to text.
|
||||
|
||||
[1, 2, 3].to_text == "[1, 2, 3]"
|
||||
## PRIVATE
|
||||
Generates a human-readable text representation of the vector.
|
||||
to_text : Text
|
||||
to_text self = self.map .to_text . join ", " "[" "]"
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Generates a human-readable text representation of the vector, keeping its
|
||||
length limited.
|
||||
|
||||
@ -932,8 +933,8 @@ type Vector a
|
||||
to_list self =
|
||||
self.reverse.fold List.Nil acc-> elem-> List.Cons elem acc
|
||||
|
||||
## PRIVATE
|
||||
type Builder
|
||||
|
||||
## PRIVATE
|
||||
|
||||
A builder type for Enso vectors.
|
||||
@ -968,7 +969,8 @@ type Builder
|
||||
that `Ref` and then `to_vector` could propagate that error.
|
||||
Value java_builder
|
||||
|
||||
## Creates a new builder.
|
||||
## PRIVATE
|
||||
Creates a new builder.
|
||||
|
||||
Arguments:
|
||||
- capacity: Initial capacity of the Vector.Builder
|
||||
@ -1111,13 +1113,10 @@ type Builder
|
||||
changes to the builder will not affect the returned vector.
|
||||
Vector.from_polyglot_array self.java_builder.toArray
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
An error that indicates that the vector is empty.
|
||||
type Empty_Error
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Pretty prints the empty error.
|
||||
to_display_text : Text
|
||||
to_display_text self = "The vector is empty."
|
||||
|
@ -20,7 +20,9 @@ from project.Data.Boolean import Boolean, True, False
|
||||
Enso graph.
|
||||
@Builtin_Type
|
||||
type Error
|
||||
## Creates a new dataflow error containing the provided payload.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a new dataflow error containing the provided payload.
|
||||
|
||||
Arguments:
|
||||
- payload: The contents of the dataflow error to be created.
|
||||
@ -49,7 +51,8 @@ type Error
|
||||
get_stack_trace_text : Text
|
||||
get_stack_trace_text self = @Builtin_Method "Error.get_stack_trace_text"
|
||||
|
||||
## Converts an error to a corresponding textual representation.
|
||||
## PRIVATE
|
||||
Converts an error to a corresponding textual representation.
|
||||
|
||||
> Example
|
||||
Converting a thrown error to text.
|
||||
@ -58,8 +61,7 @@ type Error
|
||||
to_text : Text
|
||||
to_text self = @Builtin_Method "Error.to_text"
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Returns a human-readable text representing this error.
|
||||
to_display_text : Text
|
||||
to_display_text self = "Error: " + (self.catch Any .to_display_text)
|
||||
@ -116,7 +118,6 @@ type Error
|
||||
map_error self f = self.catch Any (x -> Error.throw (f x))
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
|
||||
Returns the attached stack trace of the error.
|
||||
|
||||
|
@ -24,7 +24,6 @@ type Index_Out_Of_Bounds
|
||||
Error index length
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Pretty prints an index out of bounds error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
@ -152,8 +151,7 @@ type Incomparable_Values
|
||||
- right: The right value (second operand)
|
||||
Error left right
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Convert the Incomparable_Values error to a human-readable format.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
@ -161,7 +159,8 @@ type Incomparable_Values
|
||||
True -> "Incomparable_Values.Error"
|
||||
False -> "Cannot compare `" + self.left.to_text + "` with `" + self.right.to_text + "`"
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Catches possible errors from comparing values and throws an
|
||||
`Incomparable_Values` if any occur.
|
||||
handle_errors ~function =
|
||||
|
@ -43,8 +43,7 @@ type File_Error
|
||||
is not in the expected format.
|
||||
Corrupted_Format (file : File) (message : Text) (cause : Any | Nothing = Nothing)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Convert the File error to a human-readable format.
|
||||
to_display_text : Text
|
||||
to_display_text self = case self of
|
||||
|
@ -24,8 +24,8 @@ type Problem_Behavior
|
||||
Report the problem as a dataflow error and abort the operation
|
||||
Report_Error
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Attaches a problem to the given value according to the expected problem
|
||||
behavior.
|
||||
|
||||
@ -46,8 +46,8 @@ type Problem_Behavior
|
||||
if decorated_value.is_error then decorated_value else
|
||||
Error.throw problem
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Attaches a problem to the given value according to the expected problem
|
||||
behavior.
|
||||
|
||||
@ -65,8 +65,8 @@ type Problem_Behavior
|
||||
Report_Error ->
|
||||
Error.throw problem
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Attaches problems to the given value according to the expected problem
|
||||
behavior.
|
||||
|
||||
@ -96,8 +96,8 @@ type Problem_Behavior
|
||||
if problems.is_empty then decorated_value else
|
||||
Error.throw problems.first
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Attaches problems to the given value according to the expected problem
|
||||
behavior.
|
||||
|
||||
@ -127,8 +127,8 @@ type Problem_Behavior
|
||||
if decorated_value.is_error || problems.is_empty then decorated_value else
|
||||
Error.throw problems.first
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
A helper method that will handle any errors contained within the result
|
||||
according to the current problem behavior settings. If the `result` does
|
||||
not contain an error, it is returned as-is. Otherwise, if the problem
|
||||
@ -151,7 +151,8 @@ type Problem_Behavior
|
||||
values = ["Report_Error", "Report_Warning", "Ignore"]
|
||||
Single_Choice (values.map n-> Option n) display=Display.Expanded_Only
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Checks any warnings reported by the `action` and reports them according
|
||||
to this problem behavior - they may be kept as-is, ignored or escalated
|
||||
to errors.
|
||||
|
@ -12,12 +12,12 @@ type Unimplemented
|
||||
Error message
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Converts the unimplemented error to a human-readable error message.
|
||||
to_display_text : Text
|
||||
to_display_text self = "An implementation is missing: " + self.message
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
A function that can be used to indicate that something hasn't been
|
||||
implemented yet.
|
||||
|
@ -2,7 +2,9 @@ import project.Any.Any
|
||||
import project.Data.Text.Text
|
||||
import project.Nothing.Nothing
|
||||
|
||||
## Prints the provided message to standard error.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Prints the provided message to standard error.
|
||||
|
||||
Arguments:
|
||||
- message: The message to print. It will have to_text called on it to
|
||||
@ -15,7 +17,9 @@ import project.Nothing.Nothing
|
||||
print_err : Any -> Nothing
|
||||
print_err message = @Builtin_Method "IO.print_err"
|
||||
|
||||
## Prints the provided message to standard output.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Prints the provided message to standard output.
|
||||
|
||||
Arguments:
|
||||
- message: The message to print. It will have to_text called on it to
|
||||
@ -28,7 +32,9 @@ print_err message = @Builtin_Method "IO.print_err"
|
||||
println : Any -> Nothing
|
||||
println message = @Builtin_Method "IO.println"
|
||||
|
||||
## Reads a line from standard input.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Reads a line from standard input.
|
||||
|
||||
> Example
|
||||
Read a line from standard input.
|
||||
|
@ -108,6 +108,7 @@ import project.Data.Time.Time_Period.Time_Period
|
||||
import project.Data.Time.Time_Zone.Time_Zone
|
||||
import project.Errors.Problem_Behavior.Problem_Behavior
|
||||
import project.Network.Extensions
|
||||
import project.Network.HTTP.Header.Header
|
||||
import project.Network.HTTP.HTTP
|
||||
import project.Network.HTTP.HTTP_Method.HTTP_Method
|
||||
import project.Network.HTTP.HTTP_Status_Code.HTTP_Status_Code
|
||||
@ -156,6 +157,7 @@ export project.Data.Time.Time_Period.Time_Period
|
||||
export project.Data.Time.Time_Zone.Time_Zone
|
||||
export project.Errors.Problem_Behavior.Problem_Behavior
|
||||
export project.Network.Extensions
|
||||
export project.Network.HTTP.Header.Header
|
||||
export project.Network.HTTP.HTTP
|
||||
export project.Network.HTTP.HTTP_Method.HTTP_Method
|
||||
export project.Network.HTTP.HTTP_Status_Code.HTTP_Status_Code
|
||||
|
@ -18,7 +18,7 @@ import project.Error.Error as Base_Error
|
||||
from project.Data.Boolean import Boolean, True, False
|
||||
|
||||
type Type
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Type meta-representation.
|
||||
@ -27,16 +27,14 @@ type Type
|
||||
- value: The value of the type in the meta representation.
|
||||
Value value
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Returns a vector of `Meta.Constructor` for this type
|
||||
constructors : Vector
|
||||
constructors self =
|
||||
Vector.from_polyglot_array (get_type_constructors self.value Meta.Constructor.Value)
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Returns a vector of `Meta.Constructor` for this type
|
||||
methods : Vector
|
||||
@ -44,7 +42,7 @@ type Type
|
||||
Vector.from_polyglot_array (get_type_methods self.value)
|
||||
|
||||
type Atom
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
An Atom meta-representation.
|
||||
@ -53,15 +51,13 @@ type Atom
|
||||
- value: The value of the atom in the meta representation.
|
||||
Value value
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Returns a vector of field values of the given atom.
|
||||
fields : Vector
|
||||
fields self = Vector.from_polyglot_array (get_atom_fields self.value)
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Returns a constructor value of the given atom.
|
||||
constructor : Constructor
|
||||
@ -70,7 +66,7 @@ type Atom
|
||||
Meta.Constructor.Value java_constructor
|
||||
|
||||
type Constructor
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
A constructor meta-representation.
|
||||
@ -79,8 +75,7 @@ type Constructor
|
||||
- value: The value of the constructor in the meta representation.
|
||||
Value value
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Returns a vector of field names defined by a constructor.
|
||||
fields : Vector
|
||||
@ -88,8 +83,7 @@ type Constructor
|
||||
c = self.value ...
|
||||
Vector.from_polyglot_array (get_constructor_fields c)
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Returns the name of a constructor.
|
||||
name : Text
|
||||
@ -97,8 +91,7 @@ type Constructor
|
||||
c = self.value ...
|
||||
get_constructor_name c
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Creates a new atom of the given constructor.
|
||||
|
||||
@ -111,7 +104,7 @@ type Constructor
|
||||
new_atom ctor fields.to_array
|
||||
|
||||
type Primitive
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
A primitive value meta-representation.
|
||||
@ -121,7 +114,7 @@ type Primitive
|
||||
Value value
|
||||
|
||||
type Unresolved_Symbol
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
An unresolved symbol meta-representation.
|
||||
@ -130,7 +123,7 @@ type Unresolved_Symbol
|
||||
- value: The value of the unresolved symbol in the meta representation.
|
||||
Value value
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Returns a new unresolved symbol with its name changed to the provided
|
||||
@ -142,22 +135,20 @@ type Unresolved_Symbol
|
||||
rename self new_name =
|
||||
create_unresolved_symbol new_name self.scope
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Returns the name of an unresolved symbol.
|
||||
name : Text
|
||||
name self = get_unresolved_symbol_name self.value
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Returns the definition scope of an unresolved symbol.
|
||||
scope : Any
|
||||
scope self = get_unresolved_symbol_scope self.value
|
||||
|
||||
type Error
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
An error meta-representation, containing the payload of a dataflow error.
|
||||
@ -167,7 +158,7 @@ type Error
|
||||
Value value
|
||||
|
||||
type Polyglot
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
A polyglot value meta-representation.
|
||||
@ -176,8 +167,7 @@ type Polyglot
|
||||
- value: The polyglot value contained in the meta representation.
|
||||
Value value
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Returns the language with which a polyglot value is associated.
|
||||
get_language : Language
|
||||
@ -185,8 +175,7 @@ type Polyglot
|
||||
lang_str = get_polyglot_language self.value
|
||||
if lang_str == "java" then Language.Java else Language.Unknown
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Checks whether `self` represents the same underlying reference as `value`.
|
||||
|
||||
@ -196,8 +185,7 @@ type Polyglot
|
||||
Any.is_same_object_as : Any -> Boolean
|
||||
Any.is_same_object_as self value = is_same_object self value
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Checks if `self` is an instance of `typ`.
|
||||
|
||||
@ -206,8 +194,7 @@ Any.is_same_object_as self value = is_same_object self value
|
||||
Any.is_a : Any -> Boolean
|
||||
Any.is_a self typ = is_a self typ
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
Checks if `self` is an instance of `typ`.
|
||||
|
||||
@ -329,7 +316,7 @@ new_atom constructor fields = @Builtin_Method "Meta.new_atom"
|
||||
atom_with_hole : (Any -> Atom) -> Any
|
||||
atom_with_hole factory = @Builtin_Method "Meta.atom_with_hole_builtin"
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Returns a meta-representation of a given runtime entity.
|
||||
@ -345,7 +332,7 @@ meta value = if is_atom value then Atom.Value value else
|
||||
if is_type value then Type.Value value.catch else
|
||||
Primitive.Value value
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Checks whether two objects are represented by the same underlying reference.
|
||||
@ -356,7 +343,7 @@ meta value = if is_atom value then Atom.Value value else
|
||||
is_same_object : Any -> Any -> Boolean
|
||||
is_same_object value_1 value_2 = @Builtin_Method "Meta.is_same_object"
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Checks if `value` is an instance of `typ`.
|
||||
@ -373,7 +360,7 @@ java_instance_check value typ =
|
||||
typ_java = get_polyglot_language typ == "java"
|
||||
val_java && typ_java && Java.is_instance value typ
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Returns the type of the given value.
|
||||
@ -383,7 +370,7 @@ java_instance_check value typ =
|
||||
type_of : Any -> Any
|
||||
type_of value = @Builtin_Method "Meta.type_of"
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Given a type object, method name and a parameter name, return the associated annotation if it exists.
|
||||
@ -395,16 +382,16 @@ type_of value = @Builtin_Method "Meta.type_of"
|
||||
get_annotation : Any -> Text -> Text -> Any | Nothing
|
||||
get_annotation target method_name parameter_name = @Builtin_Method "Meta.get_annotation"
|
||||
|
||||
## Represents a polyglot language.
|
||||
## PRIVATE
|
||||
Represents a polyglot language.
|
||||
type Language
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
The Java language.
|
||||
Java
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
An unknown language.
|
||||
|
@ -4,7 +4,8 @@ import project.System.File.File
|
||||
## Functionality for inspecting the current project.
|
||||
@Builtin_Type
|
||||
type Project_Description
|
||||
## A representation of an Enso project.
|
||||
## PRIVATE
|
||||
A representation of an Enso project.
|
||||
|
||||
Arguments:
|
||||
- prim_root_file: The primitive root file of the project.
|
||||
|
@ -61,7 +61,6 @@ type HTTP
|
||||
new (timeout = (Duration.new seconds=10)) (follow_redirects = True) (proxy = Proxy.System) (version = HTTP_Version.HTTP_1_1) =
|
||||
HTTP.Value timeout follow_redirects proxy version
|
||||
|
||||
|
||||
## ALIAS Fetch Data
|
||||
|
||||
Send the Get request and return the body.
|
||||
@ -335,7 +334,8 @@ type HTTP
|
||||
req = Request.delete uri headers
|
||||
self.request req
|
||||
|
||||
## Create a request
|
||||
## ADVANCED
|
||||
Create a request
|
||||
|
||||
Arguments:
|
||||
- req: The HTTP request to send using `self` HTTP client.
|
||||
@ -466,7 +466,6 @@ type HTTP
|
||||
Response.Value (self.internal_http_client.send http_request body_handler)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Build an HTTP client.
|
||||
internal_http_client : HttpClient
|
||||
internal_http_client self =
|
||||
@ -497,18 +496,17 @@ type HTTP
|
||||
# build http client
|
||||
builder.build
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
An error when sending an HTTP request.
|
||||
|
||||
Arguments:
|
||||
- error_type: The type of the error.
|
||||
- message: The message for the error.
|
||||
type Request_Error
|
||||
## PRIVATE
|
||||
Error error_type message
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Convert a request error to a human-readable form.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
|
@ -31,7 +31,9 @@ type HTTP_Method
|
||||
## Custom unsupported HTTP method.
|
||||
Custom verb:Text
|
||||
|
||||
## Convert to a Text of the HTTP method name.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Convert to a Text of the HTTP method name.
|
||||
to_http_method_name : Text
|
||||
to_http_method_name self = case self of
|
||||
HTTP_Method.Options -> "OPTIONS"
|
||||
|
@ -1,3 +1,4 @@
|
||||
import project.Data.Numbers.Integer
|
||||
import project.Data.Text.Text
|
||||
import project.Nothing.Nothing
|
||||
|
||||
@ -33,8 +34,6 @@ type Header
|
||||
new : Text -> Text -> Header
|
||||
new name value = Header.Value name value
|
||||
|
||||
# Accept
|
||||
|
||||
## Create an "Accept" header.
|
||||
|
||||
Arguments:
|
||||
@ -92,7 +91,13 @@ type Header
|
||||
authorization_basic user pass =
|
||||
Header.authorization (Http_Utils.header_basic_auth user pass)
|
||||
|
||||
# Content-Type
|
||||
## Create bearer token auth header.
|
||||
|
||||
Arguments:
|
||||
- token: The token.
|
||||
authorization_bearer : Text -> Header
|
||||
authorization_bearer token =
|
||||
Header.authorization ("Bearer " + token)
|
||||
|
||||
## Create "Content-Type" header.
|
||||
|
||||
@ -170,10 +175,14 @@ type Header
|
||||
|
||||
## PRIVATE
|
||||
type Header_Comparator
|
||||
## PRIVATE
|
||||
compare : Header -> Header -> Ordering
|
||||
compare x y =
|
||||
if x.name.equals_ignore_case y.name && x.value == y.value then Ordering.Equal else
|
||||
Nothing
|
||||
|
||||
## PRIVATE
|
||||
hash : Header -> Integer
|
||||
hash x =
|
||||
key = x.name.to_case_insensitive_key + x.value
|
||||
Comparable.from key . hash key
|
||||
|
@ -54,7 +54,8 @@ type Response
|
||||
code : HTTP_Status_Code
|
||||
code self = HTTP_Status_Code.Value self.internal_http_response.statusCode
|
||||
|
||||
## Convert to a JavaScript Object representing this Response.
|
||||
## PRIVATE
|
||||
Convert to a JavaScript Object representing this Response.
|
||||
|
||||
> Example
|
||||
Convert a response to JS_Object.
|
||||
|
@ -9,22 +9,17 @@ import project.Nothing.Nothing
|
||||
import project.System.File.File
|
||||
import project.System.File.Write_Extensions
|
||||
|
||||
## PRIVATE
|
||||
type Response_Body
|
||||
|
||||
## Response body
|
||||
## PRIVATE
|
||||
Response body
|
||||
|
||||
Arguments:
|
||||
- bytes: The body of the response as binary data.
|
||||
Value bytes
|
||||
|
||||
## Convert response body to Text.
|
||||
|
||||
> Example
|
||||
Convert a response to text. NOTE: This example makes a network request.
|
||||
|
||||
import Standard.Examples
|
||||
|
||||
example_to_text = Examples.get_geo_data.to_text
|
||||
## PRIVATE
|
||||
Convert response body to Text.
|
||||
to_text : Text
|
||||
to_text self = Text.from_utf_8 self.bytes
|
||||
|
||||
|
@ -153,48 +153,43 @@ type URI
|
||||
fragment : Text ! Nothing
|
||||
fragment self = handle_nothing self.internal_uri.getFragment
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Get the unescaped user info part of this URI.
|
||||
raw_user_info : Text ! Nothing
|
||||
raw_user_info self = handle_nothing self.internal_uri.getRawUserInfo
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Get the unescaped authority part of this URI.
|
||||
raw_authority : Text ! Nothing
|
||||
raw_authority self = handle_nothing self.internal_uri.getRawAuthority
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Get the unescaped path part of this URI.
|
||||
raw_path : Text ! Nothing
|
||||
raw_path self = handle_nothing self.internal_uri.getRawPath
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Get the unescaped query part of this URI.
|
||||
raw_query : Text ! Nothing
|
||||
raw_query self = handle_nothing self.internal_uri.getRawQuery
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Get the unescaped fragment part of this URI.
|
||||
raw_fragment : Text ! Nothing
|
||||
raw_fragment self = handle_nothing self.internal_uri.getRawFragment
|
||||
|
||||
## Convert this URI to text.
|
||||
|
||||
> Example
|
||||
Convert a URI to text.
|
||||
|
||||
import Standard.Examples
|
||||
|
||||
example_to_text = Examples.uri.to_text
|
||||
## PRIVATE
|
||||
Convert this URI to text.
|
||||
to_text : Text
|
||||
to_text self = self.internal_uri.toString
|
||||
|
||||
## Convert to a JavaScript Object representing this URI.
|
||||
## PRIVATE
|
||||
Convert to a JavaScript Object representing this URI.
|
||||
|
||||
> Example
|
||||
Convert a URI to a JS_Object.
|
||||
|
@ -21,8 +21,9 @@ polyglot java import java.lang.Throwable
|
||||
to be handled through non-linear control flow mechanisms.
|
||||
@Builtin_Type
|
||||
type Panic
|
||||
|
||||
## Throws a new panic with the provided payload.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Throws a new panic with the provided payload.
|
||||
|
||||
Arguments:
|
||||
- payload: The contents of the panic to be thrown. If the payload is a
|
||||
@ -54,7 +55,6 @@ type Panic
|
||||
primitive_get_attached_stack_trace throwable = @Builtin_Method "Panic.primitive_get_attached_stack_trace"
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
|
||||
Returns the attached stack trace of the given throwable. Can be used to get
|
||||
an Enso friendly stack trace from native Java exceptions.
|
||||
@ -70,7 +70,9 @@ type Panic
|
||||
stack_with_prims = Vector.from_polyglot_array prim_stack
|
||||
stack_with_prims.map Runtime.wrap_primitive_stack_trace_element
|
||||
|
||||
## Takes any value, and if it is a dataflow error, throws it as a Panic,
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Takes any value, and if it is a dataflow error, throws it as a Panic,
|
||||
otherwise, returns the original value unchanged.
|
||||
|
||||
Arguments:
|
||||
@ -160,7 +162,9 @@ type Panic
|
||||
True -> caught_panic.convert_to_dataflow_error
|
||||
False -> Panic.throw caught_panic
|
||||
|
||||
## If a dataflow error had occurred, wrap it in a `Wrapped_Dataflow_Error` and promote to a Panic.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
If a dataflow error had occurred, wrap it in a `Wrapped_Dataflow_Error` and promote to a Panic.
|
||||
|
||||
Arguments:
|
||||
- value: value to return if not an error, or rethrow as a Panic.
|
||||
@ -168,7 +172,9 @@ type Panic
|
||||
throw_wrapped_if_error ~value =
|
||||
if value.is_error then Panic.throw (Wrapped_Dataflow_Error.Error value.catch) else value
|
||||
|
||||
## Catch any `Wrapped_Dataflow_Error` Panic and rethrow it as a dataflow error.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Catch any `Wrapped_Dataflow_Error` Panic and rethrow it as a dataflow error.
|
||||
|
||||
Arguments:
|
||||
- action: The code to execute that potentially raised a Wrapped_Dataflow_Error.
|
||||
@ -177,9 +183,11 @@ type Panic
|
||||
Panic.catch Wrapped_Dataflow_Error action caught_panic->
|
||||
Error.throw caught_panic.payload.payload
|
||||
|
||||
## PRIVATE
|
||||
@Builtin_Type
|
||||
type Caught_Panic
|
||||
## A wrapper for a caught panic.
|
||||
## PRIVATE
|
||||
A wrapper for a caught panic.
|
||||
|
||||
Arguments:
|
||||
- payload: the payload carried by the error.
|
||||
@ -201,9 +209,9 @@ type Caught_Panic
|
||||
Wraps a dataflow error lifted to a panic, making possible to distinguish it
|
||||
from other panics.
|
||||
type Wrapped_Dataflow_Error
|
||||
## PRIVATE
|
||||
Error payload
|
||||
|
||||
## PRIVATE
|
||||
Throws the original error.
|
||||
unwrap self = Error.throw self.payload
|
||||
|
||||
|
@ -12,21 +12,27 @@ import project.Runtime.Source_Location.Source_Location
|
||||
|
||||
@Builtin_Type
|
||||
type Polyglot
|
||||
## Reads the number of elements in a given polyglot array object.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Reads the number of elements in a given polyglot array object.
|
||||
|
||||
Arguments:
|
||||
- array: a polyglot array object, originating in any supported language.
|
||||
get_array_size : Any -> Integer
|
||||
get_array_size array = @Builtin_Method "Polyglot.get_array_size"
|
||||
|
||||
## Reads the element in a given polyglot array object.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Reads the element in a given polyglot array object.
|
||||
|
||||
Arguments:
|
||||
- index: The index to get the element from.
|
||||
read_array_element : Any -> Integer -> Any
|
||||
read_array_element array index = @Builtin_Method "Polyglot.read_array_element"
|
||||
|
||||
## Executes a polyglot function object (e.g. a lambda).
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Executes a polyglot function object (e.g. a lambda).
|
||||
|
||||
Arguments:
|
||||
- callable: The polyglot function object to execute.
|
||||
@ -34,7 +40,9 @@ type Polyglot
|
||||
execute : Any -> Vector -> Any
|
||||
execute callable arguments = @Builtin_Method "Polyglot.execute"
|
||||
|
||||
## Performs a by-name lookup for a member in a polyglot object.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Performs a by-name lookup for a member in a polyglot object.
|
||||
|
||||
Arguments:
|
||||
- object: The polyglot object on which to perform the member lookup.
|
||||
@ -46,7 +54,9 @@ type Polyglot
|
||||
get_member : Any -> Text -> Any
|
||||
get_member object member_name = @Builtin_Method "Polyglot.get_member"
|
||||
|
||||
## Returns a polyglot array of all of the members of the provided object.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns a polyglot array of all of the members of the provided object.
|
||||
|
||||
Arguments:
|
||||
- object: The object from which to get a list of member names.
|
||||
@ -57,7 +67,9 @@ type Polyglot
|
||||
get_members : Any -> Array
|
||||
get_members object = @Builtin_Method "Polyglot.get_members"
|
||||
|
||||
## Instantiates a polyglot object using the provided constructor.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Instantiates a polyglot object using the provided constructor.
|
||||
|
||||
Arguments:
|
||||
- constructor: The constructor with which to instantiate the object.
|
||||
@ -70,7 +82,9 @@ type Polyglot
|
||||
new : Any -> Vector -> Any
|
||||
new constructor arguments = @Builtin_Method "Polyglot.new"
|
||||
|
||||
## Invokes a method on a polyglot object by name.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Invokes a method on a polyglot object by name.
|
||||
|
||||
Arguments:
|
||||
- target: The polyglot object on which to call the method.
|
||||
@ -79,45 +93,48 @@ type Polyglot
|
||||
invoke : Any -> Text -> Vector -> Any
|
||||
invoke target name arguments = @Builtin_Method "Polyglot.invoke"
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Checks if `value` defines a source location.
|
||||
Checks if `value` defines a source location.
|
||||
|
||||
Source locations are typically exposed by functions, classes, sometimes
|
||||
also other objects to specify their allocation sites.
|
||||
Source locations are typically exposed by functions, classes, sometimes
|
||||
also other objects to specify their allocation sites.
|
||||
has_source_location : Any -> Boolean
|
||||
has_source_location value = @Builtin_Method "Polyglot.has_source_location"
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Gets the source location of `value`.
|
||||
Gets the source location of `value`.
|
||||
|
||||
Source locations are typically exposed by functions, classes, sometimes
|
||||
also other objects to specify their allocation sites.
|
||||
This method will throw a polyglot exception if
|
||||
`Polyglot.has_source_location value` returns `False`.
|
||||
Source locations are typically exposed by functions, classes, sometimes
|
||||
also other objects to specify their allocation sites.
|
||||
This method will throw a polyglot exception if
|
||||
`Polyglot.has_source_location value` returns `False`.
|
||||
get_source_location : Any -> Source_Location
|
||||
get_source_location value = @Builtin_Method "Polyglot.get_source_location"
|
||||
|
||||
## Checks if a polyglot language is installed in the runtime environment.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Checks if a polyglot language is installed in the runtime environment.
|
||||
|
||||
Arguments:
|
||||
- langauge_name: The name of the language to test
|
||||
Arguments:
|
||||
- language_name: The name of the language to test.
|
||||
is_language_installed : Text -> Boolean
|
||||
is_language_installed language_name = @Builtin_Method "Polyglot.is_language_installed"
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns the executable name of a polyglot object.
|
||||
get_executable_name : Any -> Text
|
||||
get_executable_name value = @Builtin_Method "Polyglot.get_executable_name"
|
||||
|
||||
## Utilities for working with Java polyglot objects.
|
||||
type Java
|
||||
## Adds the provided entry to the host class path.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Adds the provided entry to the host class path.
|
||||
|
||||
Arguments:
|
||||
- path: The java classpath entry to add.
|
||||
@ -132,7 +149,9 @@ type Java
|
||||
add_to_class_path : Text -> Nothing
|
||||
add_to_class_path path = @Builtin_Method "Java.add_to_class_path"
|
||||
|
||||
## Looks up a java symbol on the classpath by name.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Looks up a java symbol on the classpath by name.
|
||||
|
||||
Arguments:
|
||||
- name: The name of the java symbol to look up.
|
||||
@ -148,7 +167,6 @@ type Java
|
||||
lookup_class name = @Builtin_Method "Java.lookup_class"
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Checks whether an object is an instance of a given class.
|
||||
|
||||
Arguments:
|
||||
|
@ -17,8 +17,8 @@ from project.Data.Index_Sub_Range.Index_Sub_Range import First, Last
|
||||
primitive_get_stack_trace : Array
|
||||
primitive_get_stack_trace = @Builtin_Method "Runtime.primitive_get_stack_trace"
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Returns the execution stack trace of its call site. The ordering of the
|
||||
resulting vector is such that the top stack frame is the first element.
|
||||
@ -30,7 +30,8 @@ get_stack_trace =
|
||||
stack = stack_with_prims.drop (First 2)
|
||||
stack.map wrap_primitive_stack_trace_element
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Suggests that the runtime perform garbage collection.
|
||||
|
||||
@ -44,7 +45,8 @@ get_stack_trace =
|
||||
gc : Nothing
|
||||
gc = @Builtin_Method "Runtime.gc"
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Executes the provided action without allowing it to inline.
|
||||
|
||||
@ -62,8 +64,8 @@ gc = @Builtin_Method "Runtime.gc"
|
||||
no_inline : Any -> Any
|
||||
no_inline ~action = @Builtin_Method "Runtime.no_inline"
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Applies the following function to the given argument, without allowing
|
||||
them to inline.
|
||||
@ -88,8 +90,8 @@ wrap_primitive_stack_trace_element el =
|
||||
name = Polyglot.get_executable_name el
|
||||
Stack_Trace_Element.Value name loc
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Represents a single stack frame in an Enso stack trace.
|
||||
type Stack_Trace_Element
|
||||
@ -104,15 +106,20 @@ type Stack_Trace_Element
|
||||
loc -> loc.formatted_coordinates
|
||||
"at "+self.name+" ("+loc+")"
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Types indicating allowed IO operations
|
||||
type IO_Permissions
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Input
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Output
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Allows an action in the `Input` context to be performed in the given `env`,
|
||||
regardless of the Env configuration.
|
||||
@ -122,8 +129,8 @@ type IO_Permissions
|
||||
allow_input_in : Text -> Any -> Any
|
||||
allow_input_in env ~action = @Builtin_Method "Runtime.allow_input_in"
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Allows an action in the `Output` context to be performed in the given `env`,
|
||||
regardless of the Env configuration.
|
||||
|
@ -19,7 +19,9 @@ import project.Nothing.Nothing
|
||||
breakpoint : Nothing
|
||||
breakpoint = @Builtin_Method "Debug.breakpoint"
|
||||
|
||||
## Evaluates the provided Enso code in the caller frame.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Evaluates the provided Enso code in the caller frame.
|
||||
|
||||
Arguments:
|
||||
- expression: The enso code to evaluate.
|
||||
|
@ -5,7 +5,8 @@ import project.Panic.Caught_Panic
|
||||
import project.Panic.Panic
|
||||
import project.Runtime.Ref.Ref
|
||||
|
||||
## Holds a value that is computed on first access.
|
||||
## PRIVATE
|
||||
Holds a value that is computed on first access.
|
||||
type Lazy
|
||||
## PRIVATE
|
||||
Lazy (cached_ref : Ref) (builder : Nothing -> Any)
|
||||
@ -13,14 +14,18 @@ type Lazy
|
||||
## PRIVATE
|
||||
Eager (value : Any)
|
||||
|
||||
## Creates a new lazy value.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a new lazy value.
|
||||
new : Any -> Lazy
|
||||
new ~lazy_computation =
|
||||
builder _ = lazy_computation
|
||||
cached_ref = Ref.new Lazy_Not_Computed_Mark
|
||||
Lazy.Lazy cached_ref builder
|
||||
|
||||
## Creates a pre-computed lazy value.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a pre-computed lazy value.
|
||||
This can be useful if a value needs to admit the Lazy type API, but is
|
||||
known beforehand.
|
||||
new_eager value = Lazy.Eager value
|
||||
|
@ -16,7 +16,8 @@ import project.Nothing.Nothing
|
||||
abstractions, and is not expected to be used by end-users.
|
||||
@Builtin_Type
|
||||
type Managed_Resource
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Acquires a resource, performs an action on it, and destroys it safely,
|
||||
even in the presence of panics.
|
||||
@ -29,7 +30,8 @@ type Managed_Resource
|
||||
bracket : Any -> (Any -> Nothing) -> (Any -> Any) -> Any
|
||||
bracket ~constructor ~destructor ~action = @Builtin_Method "Resource.bracket"
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Registers a resource with the resource manager to be cleaned up using
|
||||
function once it is no longer in use.
|
||||
@ -40,14 +42,16 @@ type Managed_Resource
|
||||
register : Any -> (Any -> Nothing) -> Managed_Resource
|
||||
register resource function = @Builtin_Method "Managed_Resource.register"
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Forces finalization of a managed resource using the registered finalizer,
|
||||
even if the resource is still reachable.
|
||||
finalize : Nothing
|
||||
finalize self = @Builtin_Method "Managed_Resource.finalize"
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Executes the provided action on the resource managed by the managed
|
||||
resource object.
|
||||
@ -58,7 +62,8 @@ type Managed_Resource
|
||||
with : (Any -> Any) -> Any
|
||||
with self ~action = @Builtin_Method "Managed_Resource.with"
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Takes the value held by the managed resource and unregisters the
|
||||
finalization step for this resource, effectively removing it from the
|
||||
|
@ -1,9 +1,13 @@
|
||||
import project.Any.Any
|
||||
|
||||
## A mutable reference type.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
A mutable reference type.
|
||||
@Builtin_Type
|
||||
type Ref
|
||||
## Creates a new reference containing the provided value.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a new reference containing the provided value.
|
||||
|
||||
Arguments:
|
||||
- value: The value to be contained in the ref.
|
||||
|
@ -4,47 +4,37 @@ import project.System.File.File
|
||||
|
||||
from project.Data.Boolean import Boolean, True, False
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Represents a source location in Enso code. Contains information about the
|
||||
source file and code position within it.
|
||||
type Source_Location
|
||||
## PRIVATE
|
||||
Value prim_location
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
Pretty prints the location.
|
||||
to_text : Text
|
||||
to_text self =
|
||||
'(Source_Location ' + self.formatted_coordinates + ')'
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns the 1-based line index of the start of this code range.
|
||||
## Returns the 1-based line index of the start of this code range.
|
||||
start_line : Integer
|
||||
start_line self = self.prim_location.getStartLine
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns the 1-based line index of the end of this code range.
|
||||
## Returns the 1-based line index of the end of this code range.
|
||||
end_line : Integer
|
||||
end_line self = self.prim_location.getEndLine
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns the 1-based column index of the start of this code range.
|
||||
## Returns the 1-based column index of the start of this code range.
|
||||
start_column : Integer
|
||||
start_column self = self.prim_location.getStartColumn
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns the 1-based column index of the end of this code range.
|
||||
## Returns the 1-based column index of the end of this code range.
|
||||
end_column : Integer
|
||||
end_column self = self.prim_location.getEndColumn
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns a pretty-printed location (file and line info).
|
||||
## Returns a pretty-printed location (file and line info).
|
||||
formatted_coordinates : Text
|
||||
formatted_coordinates self =
|
||||
start_line = self.start_line
|
||||
@ -64,8 +54,6 @@ type Source_Location
|
||||
_ -> file.path
|
||||
formatted_file + ":" + indices
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Return the source file corresponding to this location.
|
||||
## Return the source file corresponding to this location.
|
||||
file : File
|
||||
file self = File.new self.prim_location.getSource.getPath
|
||||
|
@ -6,7 +6,9 @@ import project.Any.Any
|
||||
|
||||
from project.Errors.Common import Uninitialized_State
|
||||
|
||||
## Executes a stateful computation in a local state environment.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Executes a stateful computation in a local state environment.
|
||||
|
||||
Arguments:
|
||||
- key: The key to associate your local_state with in the environment.
|
||||
@ -23,7 +25,9 @@ from project.Errors.Common import Uninitialized_State
|
||||
run : Any -> Any -> Any -> Any
|
||||
run key local_state ~computation = @Builtin_Method "State.run"
|
||||
|
||||
## Returns the current value for the provided key contained in the monadic
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns the current value for the provided key contained in the monadic
|
||||
state.
|
||||
|
||||
Arguments:
|
||||
@ -40,7 +44,9 @@ run key local_state ~computation = @Builtin_Method "State.run"
|
||||
get : Any -> Any ! Uninitialized_State
|
||||
get key = @Builtin_Method "State.get"
|
||||
|
||||
## Associates a new_state with the provided key in the runtime's monadic
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Associates a new_state with the provided key in the runtime's monadic
|
||||
state, returning the provided state.
|
||||
|
||||
Arguments:
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
import project.Any.Any
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Executes an action with a handler for the executing thread being
|
||||
interrupted.
|
||||
|
||||
|
@ -26,7 +26,9 @@ polyglot java import java.lang.System as Java_System
|
||||
create_process : Text -> Array -> Text -> Boolean -> Boolean -> Boolean -> System_Process_Result
|
||||
create_process command arguments input redirect_in redirect_out redirect_err = @Builtin_Method "System.create_process"
|
||||
|
||||
## Exits the Enso program, returning the provided code to the parent
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Exits the Enso program, returning the provided code to the parent
|
||||
process.
|
||||
|
||||
Arguments:
|
||||
@ -39,7 +41,9 @@ create_process command arguments input redirect_in redirect_out redirect_err = @
|
||||
exit : Integer -> Nothing
|
||||
exit code = @Builtin_Method "System.exit"
|
||||
|
||||
## Gets the nanosecond resolution system time at the moment of the call.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Gets the nanosecond resolution system time at the moment of the call.
|
||||
|
||||
> Example
|
||||
Getting the current value of the nanosecond timer.
|
||||
|
@ -90,7 +90,9 @@ type File
|
||||
home : File
|
||||
home = @Builtin_Method "File.home"
|
||||
|
||||
## Creates a new output stream for this file and runs the specified action
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a new output stream for this file and runs the specified action
|
||||
on it.
|
||||
|
||||
Arguments:
|
||||
@ -117,8 +119,7 @@ type File
|
||||
Managed_Resource.bracket (self.new_output_stream open_options) (_.close) action
|
||||
|
||||
## PRIVATE
|
||||
|
||||
## Creates a new output stream for this file. Recommended to use
|
||||
Creates a new output stream for this file. Recommended to use
|
||||
`File.with_output_stream` instead, which does resource management.
|
||||
|
||||
Arguments:
|
||||
@ -128,8 +129,7 @@ type File
|
||||
output_stream self options = @Builtin_Method "File.output_stream"
|
||||
|
||||
## PRIVATE
|
||||
|
||||
## Creates a new input stream for this file. Recommended to use
|
||||
Creates a new input stream for this file. Recommended to use
|
||||
`File.with_input_stream` instead, which does resource management.
|
||||
|
||||
Arguments:
|
||||
@ -138,7 +138,9 @@ type File
|
||||
input_stream : Vector File_Access -> Input_Stream
|
||||
input_stream self options = @Builtin_Method "File.input_stream"
|
||||
|
||||
## Creates a new input stream for this file and runs the specified action
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a new input stream for this file and runs the specified action
|
||||
on it.
|
||||
|
||||
Arguments:
|
||||
@ -279,7 +281,8 @@ type File
|
||||
resolve : File
|
||||
resolve self = @Builtin_Method "File.resolve"
|
||||
|
||||
## Convert the file descriptor to a JS_Object.
|
||||
## PRIVATE
|
||||
Convert the file descriptor to a JS_Object.
|
||||
|
||||
> Example
|
||||
Convert a file to a JS_Object.
|
||||
@ -532,8 +535,8 @@ type File
|
||||
delete_if_exists : Nothing ! File_Error
|
||||
delete_if_exists self = if self.exists then self.delete else Nothing
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns a new input stream for this file.
|
||||
|
||||
Arguments:
|
||||
@ -550,8 +553,8 @@ type File
|
||||
resource = Managed_Resource.register stream close_stream
|
||||
Input_Stream.Value self resource
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns a new output stream for this file.
|
||||
|
||||
Arguments:
|
||||
@ -580,7 +583,6 @@ type File
|
||||
Output_Stream.Value self resource
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Reads last `n` bytes from the file (or less if the file is too small) and
|
||||
returns a vector of bytes.
|
||||
read_last_bytes : Integer -> Vector ! File_Error
|
||||
@ -655,32 +657,27 @@ type File
|
||||
matcher.matches (Path.of pathStr)
|
||||
filtered
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Checks if `self` is a child path of `other`.
|
||||
## Checks if `self` is a child path of `other`.
|
||||
is_child_of : File -> Boolean
|
||||
is_child_of self other = self.starts_with other
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Transforms `child` to a relative path with respect to `self`.
|
||||
## Transforms `child` to a relative path with respect to `self`.
|
||||
relativize : File -> Boolean
|
||||
relativize self child = @Builtin_Method "File.relativize"
|
||||
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Utility function that lists immediate children of a directory.
|
||||
list_immediate_children : Vector File
|
||||
list_immediate_children self = Vector.from_polyglot_array (self.list_immediate_children_array)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Return the absolute path of this File
|
||||
to_text : Text
|
||||
to_text self = self.absolute . path
|
||||
|
||||
## An output stream, allowing for interactive writing of contents into an
|
||||
## PRIVATE
|
||||
An output stream, allowing for interactive writing of contents into an
|
||||
open file.
|
||||
type Output_Stream
|
||||
## PRIVATE
|
||||
@ -694,8 +691,8 @@ type Output_Stream
|
||||
stream.
|
||||
Value file stream_resource
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Writes a vector of bytes into the file at the current stream position.
|
||||
|
||||
Arguments:
|
||||
@ -719,8 +716,8 @@ type Output_Stream
|
||||
java_stream.flush
|
||||
Nothing
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Closes this stream.
|
||||
|
||||
Even though Streams are closed automatically upon garbage collection, it
|
||||
@ -741,7 +738,7 @@ type Output_Stream
|
||||
close self = self.stream_resource . finalize
|
||||
|
||||
## PRIVATE
|
||||
|
||||
ADVANCED
|
||||
Exposes operations on the underlying Java output stream.
|
||||
|
||||
Arguments:
|
||||
@ -753,6 +750,7 @@ type Output_Stream
|
||||
with_java_stream self f = self.stream_resource . with f
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Runs an action with a `ReportingStreamEncoder` encoding data to the
|
||||
output stream with the specified encoding.
|
||||
with_stream_encoder : Encoding -> Problem_Behavior -> (ReportingStreamEncoder -> Any) -> Any
|
||||
@ -769,7 +767,8 @@ type Output_Stream
|
||||
problems = Vector.from_polyglot_array results.problems . map Encoding_Error.Error
|
||||
on_problems.attach_problems_after results.result problems
|
||||
|
||||
## An input stream, allowing for interactive reading of contents from an open
|
||||
## PRIVATE
|
||||
An input stream, allowing for interactive reading of contents from an open
|
||||
file.
|
||||
type Input_Stream
|
||||
|
||||
@ -784,8 +783,8 @@ type Input_Stream
|
||||
stream.
|
||||
Value file stream_resource
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Reads all the bytes in this file into a vector of bytes.
|
||||
|
||||
> Example
|
||||
@ -805,8 +804,8 @@ type Input_Stream
|
||||
File_Error.handle_java_exceptions self.file <|
|
||||
Vector.from_polyglot_array java_stream.readAllBytes
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Reads _up to_ the provided number of bytes from the stream.
|
||||
|
||||
Arguments:
|
||||
@ -836,8 +835,8 @@ type Input_Stream
|
||||
bytes = java_stream.readNBytes n
|
||||
Vector.from_polyglot_array bytes
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Reads the next byte from the stream.
|
||||
|
||||
The returned value is an integer in the range 0-255 representing the
|
||||
@ -860,8 +859,8 @@ type Input_Stream
|
||||
File_Error.handle_java_exceptions self.file <|
|
||||
java_stream.read
|
||||
|
||||
## ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Closes this stream.
|
||||
|
||||
Even though Streams are closed automatically upon garbage collection, it
|
||||
|
@ -14,10 +14,13 @@ type Permission
|
||||
Execute
|
||||
|
||||
type File_Permissions
|
||||
## Access permissions for a file.
|
||||
## PRIVATE
|
||||
Access permissions for a file.
|
||||
Value (owner : Vector Permission) (group : Vector Permission) (others : Vector Permission)
|
||||
|
||||
## Converts the Enso atom to its Java enum counterpart.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Converts the Enso atom to its Java enum counterpart.
|
||||
to_java : Vector PosixFilePermission
|
||||
to_java self =
|
||||
result = Vector.new_builder
|
||||
@ -77,7 +80,9 @@ type File_Permissions
|
||||
others_execute : Boolean
|
||||
others_execute self = self.others.contains Permission.Execute
|
||||
|
||||
## Converts a Java `Set` of Java `PosixFilePermission` to `File_Permissions`.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Converts a Java `Set` of Java `PosixFilePermission` to `File_Permissions`.
|
||||
from_java_set java_set =
|
||||
owner = Vector.new_builder
|
||||
group = Vector.new_builder
|
||||
|
@ -35,7 +35,6 @@ get_format callback =
|
||||
@Tail_Call reader (idx + 1)
|
||||
reader 0
|
||||
|
||||
|
||||
type Auto_Detect
|
||||
## PRIVATE
|
||||
Implements the `File.read` for this `File_Format`
|
||||
@ -55,7 +54,6 @@ type Auto_Detect
|
||||
get_web_parser content_type uri =
|
||||
get_format f-> f.for_web content_type uri
|
||||
|
||||
|
||||
type File_Format
|
||||
## Gets all the currently available file formats.
|
||||
|
||||
@ -73,7 +71,8 @@ type File_Format
|
||||
type Plain_Text_Format
|
||||
Plain_Text (encoding:Encoding=Encoding.utf_8)
|
||||
|
||||
## If the File_Format supports reading from the file, return a configured instance.
|
||||
## PRIVATE
|
||||
If the File_Format supports reading from the file, return a configured instance.
|
||||
for_file : File -> Plain_Text_Format | Nothing
|
||||
for_file file =
|
||||
case file.extension of
|
||||
@ -81,7 +80,8 @@ type Plain_Text_Format
|
||||
".log" -> Plain_Text_Format.Plain_Text
|
||||
_ -> Nothing
|
||||
|
||||
## If the File_Format supports reading from the web response, return a configured instance.
|
||||
## PRIVATE
|
||||
If the File_Format supports reading from the web response, return a configured instance.
|
||||
for_web : Text -> URI -> Plain_Text_Format | Nothing
|
||||
for_web content_type _ =
|
||||
parts = content_type.split ";" . map .trim
|
||||
@ -107,14 +107,16 @@ type Plain_Text_Format
|
||||
Text.from_bytes response.body.bytes self.encoding
|
||||
|
||||
type Bytes
|
||||
## If the File_Format supports reading from the file, return a configured instance.
|
||||
## PRIVATE
|
||||
If the File_Format supports reading from the file, return a configured instance.
|
||||
for_file : File -> Bytes | Nothing
|
||||
for_file file =
|
||||
case file.extension of
|
||||
".dat" -> Bytes
|
||||
_ -> Nothing
|
||||
|
||||
## If the File_Format supports reading from the web response, return a configured instance.
|
||||
## PRIVATE
|
||||
If the File_Format supports reading from the web response, return a configured instance.
|
||||
As `Bytes`, does not support reading from the web returns `Nothing`.
|
||||
for_web : Text -> URI -> Bytes | Nothing
|
||||
for_web _ _ = Nothing
|
||||
@ -126,7 +128,8 @@ type Bytes
|
||||
file.read_bytes
|
||||
|
||||
type JSON_File
|
||||
## If the File_Format supports reading from the file, return a configured instance.
|
||||
## PRIVATE
|
||||
If the File_Format supports reading from the file, return a configured instance.
|
||||
for_file : File -> JSON_File | Nothing
|
||||
for_file file =
|
||||
case file.extension of
|
||||
@ -134,7 +137,8 @@ type JSON_File
|
||||
".geojson" -> JSON_File
|
||||
_ -> Nothing
|
||||
|
||||
## If the File_Format supports reading from the web response, return a configured instance.
|
||||
## PRIVATE
|
||||
If the File_Format supports reading from the web response, return a configured instance.
|
||||
for_web : Text -> URI -> JSON_File | Nothing
|
||||
for_web content_type _ =
|
||||
first = content_type.split ';' . first . trim
|
||||
|
@ -4,7 +4,6 @@ import project.System
|
||||
|
||||
## A representation of the various operating systems on which Enso can run.
|
||||
type OS
|
||||
|
||||
## The Linux operating system.
|
||||
Linux
|
||||
|
||||
@ -33,7 +32,6 @@ is_unix : Boolean
|
||||
is_unix = @Builtin_Method "System.is_unix"
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create an Os object from text.
|
||||
from_text : Text -> OS
|
||||
from_text os = case os of
|
||||
|
@ -29,7 +29,9 @@ run : Text -> Vector Text -> Text -> Process_Result
|
||||
run command arguments=[] stdin="" =
|
||||
new_builder command arguments stdin . create
|
||||
|
||||
## Create a new process builder.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Create a new process builder.
|
||||
|
||||
Arguments:
|
||||
- command: The command to execute on the system.
|
||||
|
@ -2,7 +2,9 @@ import project.Data.Numbers.Integer
|
||||
|
||||
## The exit codes that the process can return.
|
||||
type Exit_Code
|
||||
## Create exit code from a number.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Create exit code from a number.
|
||||
|
||||
Arguments:
|
||||
- code: The exit code you want to create.
|
||||
|
@ -6,8 +6,8 @@ import project.System.System_Process_Result
|
||||
|
||||
from project.Data.Boolean import Boolean, True, False
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
The builder object that is used to create operating system processes.
|
||||
type Process_Builder
|
||||
## PRIVATE
|
||||
@ -25,9 +25,7 @@ type Process_Builder
|
||||
set arguments and standard output. It results in much clearer code.
|
||||
Value command arguments stdin
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Sets the arguments that should be passed to the created process.
|
||||
## Sets the arguments that should be passed to the created process.
|
||||
|
||||
Arguments:
|
||||
- arguments: The arguments to pass to the process.
|
||||
@ -43,9 +41,7 @@ type Process_Builder
|
||||
set_arguments : Vector Text -> Process_Builder
|
||||
set_arguments self arguments = Process_Builder.Value self.command arguments self.stdin
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Sets the text that will be used to feed standard input to the created
|
||||
## Sets the text that will be used to feed standard input to the created
|
||||
process.
|
||||
|
||||
Arguments:
|
||||
@ -62,9 +58,7 @@ type Process_Builder
|
||||
set_stdin : Text -> Process_Builder
|
||||
set_stdin self stdin = Process_Builder.Value self.command self.arguments stdin
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Create a process using a builder returning the result of execution.
|
||||
## Create a process using a builder returning the result of execution.
|
||||
|
||||
> Example
|
||||
Execute the process contained in the builder.
|
||||
|
@ -17,28 +17,26 @@ from project.Data.Boolean import Boolean, True, False
|
||||
## A representation of a dataflow warning attached to a value.
|
||||
@Builtin_Type
|
||||
type Warning
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Attaches a new warning to the value.
|
||||
attach : Any -> Any -> Any
|
||||
attach warning value =
|
||||
origin = Runtime.get_stack_trace
|
||||
attach_with_stacktrace value warning (origin.drop (Index_Sub_Range.First 1))
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## ADVANCED
|
||||
Are any warnings attached to the value?
|
||||
has_warnings : Any -> Boolean
|
||||
has_warnings value = has_warnings_builtin value
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## ADVANCED
|
||||
Gets all the warnings attached to the given value. Warnings are returned in the
|
||||
reverse-chronological order with respect to their attachment time.
|
||||
get_all : Any -> Vector Warning
|
||||
get_all value = Vector.from_polyglot_array (get_all_array value)
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Sets a new list of warnings for the given value. Any warnings already present
|
||||
@ -50,8 +48,7 @@ type Warning
|
||||
set : Any -> Vector Warning -> Any
|
||||
set value warnings = set_array value warnings.to_array
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
Returns the provided value with any warnings removed from it.
|
||||
|
||||
Arguments:
|
||||
@ -59,7 +56,7 @@ type Warning
|
||||
clear : Any -> Any
|
||||
clear value = Warning.set value []
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Executes the provided function with the given argument with its warnings
|
||||
suspended.
|
||||
@ -93,8 +90,8 @@ type Warning
|
||||
case arg of
|
||||
_ -> function (Warning.clear arg)
|
||||
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Maps warnings attached to a value.
|
||||
|
||||
Arguments:
|
||||
@ -115,7 +112,8 @@ type Warning
|
||||
map_attached_warnings mapper value =
|
||||
map_attached_warnings_helper mapper value 1
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
An utility function which applies the mapping function both to any attached
|
||||
warnings and dataflow errors.
|
||||
|
||||
@ -143,7 +141,7 @@ type Warning
|
||||
original dataflow error as-is, to preserve its stacktrace.
|
||||
Nothing -> mapped_warnings_or_error
|
||||
|
||||
## UNSTABLE
|
||||
## ADVANCED
|
||||
A helper function which selects warnings matching a predicate and returns a
|
||||
pair whose first element is the original value with the matched warnings
|
||||
removed and the second element is the list of matched warnings.
|
||||
@ -167,7 +165,8 @@ type Warning
|
||||
remaining = result.second
|
||||
Pair.new (Warning.set value remaining) matched
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
A helper function which gathers warnings matching some predicate and passes
|
||||
them into a function which can aggregate them.
|
||||
|
||||
@ -195,20 +194,17 @@ type Warning
|
||||
new_warnings.fold result.first acc-> warning->
|
||||
Warning.attach warning acc
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns the warning value – usually its explanation or other contents.
|
||||
## Returns the warning value – usually its explanation or other contents.
|
||||
value : Any
|
||||
value self = @Builtin_Method "Warning.value"
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## ADVANCED
|
||||
|
||||
A stack trace for the original warning creation.
|
||||
origin : Vector Stack_Trace_Element
|
||||
origin self = @Builtin_Method "Warning.origin"
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
A list of locations where the warning was reassigned in the order of
|
||||
|
@ -33,7 +33,8 @@ type Connection
|
||||
- dialect: the dialect associated with the database we are connected to.
|
||||
Value jdbc_connection dialect
|
||||
|
||||
## Closes the connection releasing the underlying database resources
|
||||
## PRIVATE
|
||||
Closes the connection releasing the underlying database resources
|
||||
immediately instead of waiting for them to be automatically released.
|
||||
|
||||
The connection is not usable afterwards.
|
||||
@ -41,18 +42,21 @@ type Connection
|
||||
close self = self.jdbc_connection.close
|
||||
|
||||
|
||||
## Returns the list of databases (or catalogs) for the connection.
|
||||
## PRIVATE
|
||||
Returns the list of databases (or catalogs) for the connection.
|
||||
databases : Vector Text
|
||||
databases self =
|
||||
self.jdbc_connection.with_metadata metadata->
|
||||
read_column metadata.getCatalogs "TABLE_CAT"
|
||||
|
||||
## Returns the name of the current database (or catalog).
|
||||
## PRIVATE
|
||||
Returns the name of the current database (or catalog).
|
||||
database : Text
|
||||
database self =
|
||||
self.jdbc_connection.with_connection connection->connection.getCatalog
|
||||
|
||||
## Returns a new Connection with the specified database set as default.
|
||||
## PRIVATE
|
||||
Returns a new Connection with the specified database set as default.
|
||||
|
||||
Arguments:
|
||||
- database: The name of the database to connect to.
|
||||
@ -61,18 +65,21 @@ type Connection
|
||||
if database == self.database then self else
|
||||
SQL_Error.throw_sql_error "Changing database is not supported."
|
||||
|
||||
## Returns the list of schemas for the connection within the current database (or catalog).
|
||||
## PRIVATE
|
||||
Returns the list of schemas for the connection within the current database (or catalog).
|
||||
schemas : Vector Text
|
||||
schemas self =
|
||||
self.jdbc_connection.with_metadata metadata->
|
||||
read_column metadata.getSchemas "TABLE_SCHEM"
|
||||
|
||||
## Returns the name of the current schema.
|
||||
## PRIVATE
|
||||
Returns the name of the current schema.
|
||||
schema : Text
|
||||
schema self =
|
||||
self.jdbc_connection.with_connection .getSchema
|
||||
|
||||
## Returns a new Connection with the specified schema set as default.
|
||||
## PRIVATE
|
||||
Returns a new Connection with the specified schema set as default.
|
||||
|
||||
Arguments:
|
||||
- schema: The name of the schema to connect to.
|
||||
@ -81,13 +88,15 @@ type Connection
|
||||
if schema == self.schema then self else
|
||||
SQL_Error.throw_sql_error "Changing schema is not supported."
|
||||
|
||||
## Gets a list of the table types
|
||||
## PRIVATE
|
||||
Gets a list of the table types
|
||||
table_types : [Text]
|
||||
table_types self =
|
||||
self.jdbc_connection.with_metadata metadata->
|
||||
read_column metadata.getTableTypes "TABLE_TYPE"
|
||||
|
||||
## Returns a materialized Table of all the matching views and tables.
|
||||
## PRIVATE
|
||||
Returns a materialized Table of all the matching views and tables.
|
||||
|
||||
Arguments:
|
||||
- name_like: The table name pattern to search for. Supports SQL wildcards (`%`, `_`). Defaults to `Nothing` which
|
||||
@ -107,7 +116,8 @@ type Connection
|
||||
if all_fields then renamed else
|
||||
renamed.select_columns ["Database", "Schema", "Name", "Type", "Description"]
|
||||
|
||||
## Set up a query returning a Table object, which can be used to work with
|
||||
## PRIVATE
|
||||
Set up a query returning a Table object, which can be used to work with
|
||||
data within the database or load it into memory.
|
||||
|
||||
Arguments:
|
||||
@ -150,7 +160,8 @@ type Connection
|
||||
result.catch SQL_Error sql_error->
|
||||
Error.throw (Table_Not_Found.Error name sql_error treated_as_query=False)
|
||||
|
||||
## Execute the query and load the results into memory as a Table.
|
||||
## PRIVATE
|
||||
Execute the query and load the results into memory as a Table.
|
||||
|
||||
Arguments:
|
||||
- query: name of the table or sql statement to query.
|
||||
@ -171,14 +182,15 @@ type Connection
|
||||
to ensure that default `ResultSet` metadata is used for these columns.
|
||||
- last_row_only: If set true, only the last row of the query is fetched.
|
||||
Defaults to false.
|
||||
read_statement : SQL_Statement -> (Nothing | Vector SQL_Type_Reference) -> Materialized_Table
|
||||
read_statement : SQL_Statement -> (Nothing | Vector SQL_Type_Reference) -> Boolean -> Materialized_Table
|
||||
read_statement self statement column_type_suggestions=Nothing last_row_only=False =
|
||||
type_overrides = self.dialect.get_type_mapping.prepare_type_overrides column_type_suggestions
|
||||
statement_setter = self.dialect.get_statement_setter
|
||||
self.jdbc_connection.with_prepared_statement statement statement_setter stmt->
|
||||
result_set_to_table stmt.executeQuery self.dialect.make_column_fetcher_for_type type_overrides last_row_only
|
||||
|
||||
## ADVANCED
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
Executes a raw update query. If the query was inserting, updating or
|
||||
deleting rows, the number of affected rows is returned; otherwise it
|
||||
|
@ -1,11 +1,12 @@
|
||||
from Standard.Base import all
|
||||
|
||||
|
||||
type Connection_Options
|
||||
## Hold a set of key value pairs used to configure the connection.
|
||||
Value options:Vector=[]
|
||||
|
||||
## Merge the base set of options with the overrides in this object.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Merge the base set of options with the overrides in this object.
|
||||
merge : Vector -> Vector
|
||||
merge self base_options =
|
||||
base_options.filter x->(self.options.any (y->y.first==x.first) . not) + self.options
|
||||
|
@ -4,6 +4,7 @@ type Credentials
|
||||
## Simple username and password type.
|
||||
Username_And_Password username:Text password:Text
|
||||
|
||||
## Override `to_text` to mask the password field.
|
||||
## PRIVATE
|
||||
Override `to_text` to mask the password field.
|
||||
to_text : Text
|
||||
to_text self = 'Credentials ' + self.username + ' *****'
|
||||
|
@ -28,7 +28,8 @@ type Postgres_Options
|
||||
- client_cert: The client certificate to use or `Nothing` if not needed.
|
||||
Postgres (host:Text=default_postgres_host) (port:Integer=default_postgres_port) (database:Text=default_postgres_database) (schema:Text="") (credentials:(Credentials|Nothing)=Nothing) (use_ssl:SSL_Mode=SSL_Mode.Prefer) (client_cert:(Client_Certificate|Nothing)=Nothing)
|
||||
|
||||
## Build the Connection resource.
|
||||
## PRIVATE
|
||||
Build the Connection resource.
|
||||
|
||||
Arguments:
|
||||
- options: Overrides for the connection properties.
|
||||
@ -44,12 +45,14 @@ type Postgres_Options
|
||||
|
||||
Postgres_Connection.create self.jdbc_url properties make_new
|
||||
|
||||
## Provides the jdbc url for the connection.
|
||||
## PRIVATE
|
||||
Provides the jdbc url for the connection.
|
||||
jdbc_url : Text
|
||||
jdbc_url self =
|
||||
'jdbc:postgresql://' + self.host + ':' + self.port.to_text + (if self.database == '' then '' else '/' + self.database)
|
||||
|
||||
## Provides the properties for the connection.
|
||||
## PRIVATE
|
||||
Provides the properties for the connection.
|
||||
jdbc_properties : [Pair Text Text]
|
||||
jdbc_properties self =
|
||||
credentials = case self.credentials of
|
||||
|
@ -25,7 +25,8 @@ type Redshift_Options
|
||||
- client_cert: The client certificate to use or `Nothing` if not needed.
|
||||
Redshift (host:Text) (port:Integer=5439) (schema:Text='') (credentials:Credentials|AWS_Credential|Nothing=Nothing) (use_ssl:SSL_Mode=SSL_Mode.Require) (client_cert:Client_Certificate|Nothing=Nothing)
|
||||
|
||||
## Build the Connection resource.
|
||||
## PRIVATE
|
||||
Build the Connection resource.
|
||||
|
||||
Arguments:
|
||||
- options: Overrides for the connection properties.
|
||||
@ -41,7 +42,8 @@ type Redshift_Options
|
||||
jdbc_connection = JDBC_Connection.create self.jdbc_url properties
|
||||
Connection.Value jdbc_connection Dialect.redshift
|
||||
|
||||
## Provides the jdbc url for the connection.
|
||||
## PRIVATE
|
||||
Provides the jdbc url for the connection.
|
||||
jdbc_url : Text
|
||||
jdbc_url self =
|
||||
prefix = case self.credentials of
|
||||
@ -49,7 +51,8 @@ type Redshift_Options
|
||||
_ -> 'jdbc:redshift://'
|
||||
prefix + self.host + ':' + self.port.to_text + (if self.schema == '' then '' else '/' + self.schema)
|
||||
|
||||
## Provides the properties for the connection.
|
||||
## PRIVATE
|
||||
Provides the properties for the connection.
|
||||
jdbc_properties : [Pair Text Text]
|
||||
jdbc_properties self =
|
||||
credentials = case self.credentials of
|
||||
|
@ -9,7 +9,8 @@ type SQLite_Format
|
||||
## Read SQLite files
|
||||
For_File
|
||||
|
||||
## If the File_Format supports reading from the file, return a configured instance.
|
||||
## PRIVATE
|
||||
If the File_Format supports reading from the file, return a configured instance.
|
||||
for_file : File -> SQLite_Format | Nothing
|
||||
for_file file =
|
||||
case file.extension of
|
||||
@ -17,13 +18,15 @@ type SQLite_Format
|
||||
".sqlite" -> SQLite_Format.For_File
|
||||
_ -> Nothing
|
||||
|
||||
## If the File_Format supports reading from the web response, return a configured instance.
|
||||
## PRIVATE
|
||||
If the File_Format supports reading from the web response, return a configured instance.
|
||||
for_web : Text -> URI -> SQLite_Format | Nothing
|
||||
for_web _ _ =
|
||||
## Currently not loading SQLite files automatically.
|
||||
Nothing
|
||||
|
||||
## Implements the `File.read` for this `File_Format`
|
||||
## PRIVATE
|
||||
Implements the `File.read` for this `File_Format`
|
||||
read : File -> Problem_Behavior -> Any
|
||||
read self file on_problems =
|
||||
_ = [on_problems]
|
||||
|
@ -10,7 +10,8 @@ type SQLite_Options
|
||||
- location: Location of the SQLite database to connect to.
|
||||
SQLite (location:(In_Memory|File|Text))
|
||||
|
||||
## Build the Connection resource.
|
||||
## PRIVATE
|
||||
Build the Connection resource.
|
||||
|
||||
Arguments:
|
||||
- options: Overrides for the connection properties.
|
||||
@ -19,13 +20,15 @@ type SQLite_Options
|
||||
properties = options.merge self.jdbc_properties
|
||||
SQLite_Connection.create self.jdbc_url properties
|
||||
|
||||
## Provides the jdbc url for the connection.
|
||||
## PRIVATE
|
||||
Provides the jdbc url for the connection.
|
||||
jdbc_url : Text
|
||||
jdbc_url self = case self.location of
|
||||
In_Memory -> "jdbc:sqlite::memory:"
|
||||
_ -> "jdbc:sqlite:" + ((File.new self.location).absolute.path.replace '\\' '/')
|
||||
|
||||
## Provides the properties for the connection.
|
||||
## PRIVATE
|
||||
Provides the properties for the connection.
|
||||
jdbc_properties : Vector
|
||||
jdbc_properties self = []
|
||||
|
||||
|
@ -26,9 +26,7 @@ from project.Errors import Unsupported_Database_Operation, Integrity_Error, Unsu
|
||||
polyglot java import org.enso.table.data.column.operation.map.MapOperationProblemBuilder
|
||||
|
||||
type Column
|
||||
|
||||
## UNSTABLE
|
||||
PRIVATE
|
||||
## PRIVATE
|
||||
|
||||
Represents a single column backed by a database.
|
||||
|
||||
@ -47,8 +45,8 @@ type Column
|
||||
able to be combined.
|
||||
Value name:Text connection:Connection sql_type_reference:SQL_Type_Reference expression:SQL_Expression context:Context
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns a text containing an ASCII-art table displaying this data.
|
||||
|
||||
Arguments:
|
||||
@ -58,8 +56,8 @@ type Column
|
||||
display self show_rows=10 format_terminal=False =
|
||||
self.to_table.display show_rows format_terminal
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Prints an ASCII-art table with this data to the standard output.
|
||||
|
||||
Arguments:
|
||||
@ -69,22 +67,17 @@ type Column
|
||||
IO.println (self.display show_rows format_terminal=True)
|
||||
IO.println ''
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Converts this column to JS_Object representation.
|
||||
to_js_object : JS_Object
|
||||
to_js_object self = self.to_sql.to_js_object
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Converts this column into a single-column table.
|
||||
## Converts this column into a single-column table.
|
||||
to_table : Table
|
||||
to_table self =
|
||||
Table.Value self.name self.connection [self.as_internal] self.context
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns a materialized column containing rows of this column.
|
||||
## Returns a materialized column containing rows of this column.
|
||||
|
||||
Arguments:
|
||||
- max_rows: specifies a maximum amount of rows to fetch; if not set, all
|
||||
@ -93,9 +86,7 @@ type Column
|
||||
read self max_rows=Nothing =
|
||||
self.to_table.read max_rows . at self.name
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns a vector containing all the elements in this column.
|
||||
## Returns a vector containing all the elements in this column.
|
||||
to_vector : Vector Any
|
||||
to_vector self =
|
||||
self.to_table.read . at self.name . to_vector
|
||||
@ -110,9 +101,7 @@ type Column
|
||||
mapping = self.connection.dialect.get_type_mapping
|
||||
mapping.sql_type_to_value_type self.sql_type
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns an SQL statement that will be used for materializing this column.
|
||||
## Returns an SQL statement that will be used for materializing this column.
|
||||
to_sql : SQL_Statement
|
||||
to_sql self = self.to_table.to_sql
|
||||
|
||||
@ -660,7 +649,7 @@ type Column
|
||||
|
||||
Returns a new column where missing values have been replaced with the
|
||||
provided default.
|
||||
fill_nothing : Any -> Column
|
||||
fill_nothing : Column | Any -> Column
|
||||
fill_nothing self default =
|
||||
new_name = self.naming_helpers.function_name "fill_nothing" [self, default]
|
||||
self.make_binary_op "FILL_NULL" default new_name
|
||||
@ -820,7 +809,7 @@ type Column
|
||||
|
||||
Applies only to columns that hold the `Date` or `Date_Time` types.
|
||||
Returns a column of `Integer` type.
|
||||
year : Column -> Column ! Invalid_Value_Type
|
||||
year : Column ! Invalid_Value_Type
|
||||
year self = Value_Type.expect_has_date self.value_type related_column=self.name <|
|
||||
self.make_unary_op "year"
|
||||
|
||||
@ -828,7 +817,7 @@ type Column
|
||||
|
||||
Applies only to columns that hold the `Date` or `Date_Time` types.
|
||||
Returns a column of `Integer` type.
|
||||
month : Column -> Column ! Invalid_Value_Type
|
||||
month : Column ! Invalid_Value_Type
|
||||
month self = Value_Type.expect_has_date self.value_type related_column=self.name <|
|
||||
self.make_unary_op "month"
|
||||
|
||||
@ -837,7 +826,7 @@ type Column
|
||||
|
||||
Applies only to columns that hold the `Date` or `Date_Time` types.
|
||||
Returns a column of `Integer` type.
|
||||
day : Column -> Column ! Invalid_Value_Type
|
||||
day : Column ! Invalid_Value_Type
|
||||
day self = Value_Type.expect_has_date self.value_type related_column=self.name <|
|
||||
self.make_unary_op "day"
|
||||
|
||||
@ -964,7 +953,8 @@ type Column
|
||||
as_internal : Internal_Column
|
||||
as_internal self = Internal_Column.Value self.name self.sql_type_reference self.expression
|
||||
|
||||
## Provides a simplified text representation for display in the REPL and errors.
|
||||
## PRIVATE
|
||||
Provides a simplified text representation for display in the REPL and errors.
|
||||
to_text : Text
|
||||
to_text self = "(Database Column "+self.name.to_text+")"
|
||||
|
||||
|
@ -6,7 +6,7 @@ import Standard.Table.Internal.Vector_Builder.Vector_Builder
|
||||
import project.Data.SQL_Type.SQL_Type
|
||||
import project.Data.SQL_Statement.SQL_Statement
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
|
||||
A fragment of a SQL query.
|
||||
|
||||
@ -14,7 +14,7 @@ import project.Data.SQL_Statement.SQL_Statement
|
||||
SQL_Fragment.Interpolation which represents an object that will be
|
||||
interpolated into the query.
|
||||
type SQL_Fragment
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
|
||||
A SQL fragment that represents raw SQL code.
|
||||
|
||||
@ -22,7 +22,7 @@ type SQL_Fragment
|
||||
- code: A fragment of SQL code.
|
||||
Code_Part code:Text
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
|
||||
A SQL fragment that represents an object which will be interpolated into
|
||||
the query.
|
||||
@ -31,12 +31,17 @@ type SQL_Fragment
|
||||
- object: A value that will be interpolated into the query.
|
||||
Interpolation object:Any
|
||||
|
||||
## PRIVATE
|
||||
type Builder
|
||||
## Creates a Builder representing and empty code fragment.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a Builder representing and empty code fragment.
|
||||
empty : Builder
|
||||
empty = Builder.Value (Vector_Builder.empty)
|
||||
|
||||
## Creates a Builder representing a code fragment containing the specified raw
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a Builder representing a code fragment containing the specified raw
|
||||
code.
|
||||
|
||||
Arguments:
|
||||
@ -46,7 +51,9 @@ type Builder
|
||||
vec = if text.is_empty then [] else [SQL_Fragment.Code_Part text]
|
||||
Builder.Value (Vector_Builder.from_vector vec)
|
||||
|
||||
## Creates a Builder representing an interpolation of the given object.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a Builder representing an interpolation of the given object.
|
||||
|
||||
Arguments:
|
||||
- object: The object to be interpolated into the query as if it has the type
|
||||
@ -54,7 +61,9 @@ type Builder
|
||||
interpolation : Any -> Builder
|
||||
interpolation object = Builder.Value (Vector_Builder.from_vector [SQL_Fragment.Interpolation object])
|
||||
|
||||
## Joins a vector of code fragments with the provided separator.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Joins a vector of code fragments with the provided separator.
|
||||
|
||||
Arguments:
|
||||
- separator: The separator to use when joining the code fragments.
|
||||
@ -79,8 +88,8 @@ type Builder
|
||||
end build the actual query in linear time.
|
||||
Value (fragments:(Vector_Builder SQL_Fragment))
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Concatenates two code fragments.
|
||||
|
||||
Arguments:
|
||||
@ -90,28 +99,28 @@ type Builder
|
||||
text : Text -> if text == "" then self else Builder.Value (self.fragments ++ (Builder.code text).fragments)
|
||||
_ -> Builder.Value (self.fragments ++ other.fragments)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Checks if the builder represents an empty code fragment.
|
||||
is_empty : Boolean
|
||||
is_empty self = self.fragments.is_empty
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Builds a SQL statement.
|
||||
build : SQL_Statement
|
||||
build self =
|
||||
fragments = optimize_fragments self.fragments.build
|
||||
SQL_Statement.Value fragments
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Wraps the code fragment in parentheses.
|
||||
paren : Builder
|
||||
paren self = Builder.code "(" ++ self ++ ")"
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
If the fragment is non empty, prepends the specified prefix to it.
|
||||
|
||||
Arguments:
|
||||
|
@ -2,9 +2,9 @@ from Standard.Base import all
|
||||
|
||||
import project.Data.SQL.SQL_Fragment
|
||||
|
||||
## PRIVATE
|
||||
type SQL_Statement
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
|
||||
Represents a built SQL statement.
|
||||
|
||||
@ -15,8 +15,8 @@ type SQL_Statement
|
||||
interpolated for these parameters.
|
||||
Value (internal_fragments:(Vector SQL_Fragment))
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
A vector of code fragments.
|
||||
|
||||
Consists of two types of values:
|
||||
@ -26,10 +26,9 @@ type SQL_Statement
|
||||
fragments : Vector SQL_Fragment
|
||||
fragments self = self.internal_fragments
|
||||
|
||||
## UNSAFE
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
|
||||
UNSAFE
|
||||
This function returns a raw SQL string for the query, manually handling
|
||||
the interpolation that is normally handled by the database engine itself.
|
||||
|
||||
@ -52,8 +51,8 @@ type SQL_Statement
|
||||
_ -> "'" + obj.to_text.replace "'" "''" + "'"
|
||||
strings.join ""
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns a pair consisting of the SQL code with holes for values and
|
||||
a list for values that should be substituted.
|
||||
prepare self =
|
||||
@ -67,8 +66,7 @@ type SQL_Statement
|
||||
substitutions = self.fragments.flat_map to_subst
|
||||
[sql, substitutions]
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Returns a JS_Object representation of the statement.
|
||||
to_js_object : JS_Object
|
||||
to_js_object self =
|
||||
|
@ -6,10 +6,11 @@ import project.Data.Column.Column
|
||||
polyglot java import java.sql.Types
|
||||
polyglot java import java.sql.ResultSetMetaData
|
||||
|
||||
## Represents an internal SQL data-type.
|
||||
## PRIVATE
|
||||
Represents an internal SQL data-type.
|
||||
type SQL_Type
|
||||
|
||||
## Represents an internal SQL data-type.
|
||||
## PRIVATE
|
||||
Represents an internal SQL data-type.
|
||||
|
||||
Arguments:
|
||||
- typeid: a numerical type id, as defined in `java.sql.Types`.
|
||||
@ -24,7 +25,9 @@ type SQL_Type
|
||||
TODO: the precise meaning of this will be revised with #5872.
|
||||
Value (typeid : Integer) (name : Text) (precision : Nothing | Integer = Nothing) (scale : Integer = 0) (nullable : Boolean | Nothing = Nothing)
|
||||
|
||||
## The SQL type representing a null value.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
The SQL type representing a null value.
|
||||
null : SQL_Type
|
||||
null = SQL_Type.Value Types.NULL "NULL"
|
||||
|
||||
|
@ -61,8 +61,8 @@ type Table
|
||||
- context: The context associated with this table.
|
||||
Value name:Text connection:Connection (internal_columns:(Vector Internal_Column)) context:IR.Context
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns a text containing an ASCII-art table displaying this data.
|
||||
|
||||
Arguments:
|
||||
@ -74,8 +74,8 @@ type Table
|
||||
all_rows_count = self.row_count
|
||||
display_dataframe df indices_count=0 all_rows_count format_terminal
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Prints an ASCII-art table with this data to the standard output.
|
||||
|
||||
Arguments:
|
||||
@ -85,8 +85,7 @@ type Table
|
||||
IO.println (self.display show_rows format_terminal=True)
|
||||
IO.println ''
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Converts this column to JS_Object representation.
|
||||
to_js_object : JS_Object
|
||||
to_js_object self = case self.internal_columns.is_empty of
|
||||
@ -1390,7 +1389,7 @@ type Table
|
||||
|
||||
The table lists all columns, counts of non-null items and storage types
|
||||
of each column.
|
||||
info : Table
|
||||
info : Materialized_Table
|
||||
info self =
|
||||
cols = self.internal_columns
|
||||
count_query =
|
||||
@ -1494,7 +1493,8 @@ type Table
|
||||
False -> Error.throw <| Illegal_State.Error "The update unexpectedly affected "+affected_rows.to_text+" rows."
|
||||
True -> Nothing
|
||||
|
||||
## Provides a simplified text representation for display in the REPL and errors.
|
||||
## PRIVATE
|
||||
Provides a simplified text representation for display in the REPL and errors.
|
||||
to_text : Text
|
||||
to_text self = "(Database Table "+self.name.to_text+")"
|
||||
|
||||
|
@ -5,25 +5,23 @@ polyglot java import java.sql.SQLException
|
||||
## Indicates that a requested operation is not supported, for example because a
|
||||
particular database backend does not support it.
|
||||
type Unsupported_Database_Operation
|
||||
## PRIVATE
|
||||
Error message
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Convert the SQL error to a textual representation.
|
||||
to_text : Text
|
||||
to_text self =
|
||||
"Unsupported database operation: " + self.message
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"Unsupported database operation: " + self.message
|
||||
|
||||
type SQL_Error
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Indicates an error with executing a query, update or connecting to the
|
||||
database.
|
||||
|
||||
@ -33,29 +31,26 @@ type SQL_Error
|
||||
error is related to.
|
||||
Error java_exception related_query=Nothing
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Convert the SQL error to a textual representation.
|
||||
to_text : Text
|
||||
to_text self =
|
||||
query = if self.related_query.is_nothing.not then " [Query was: " + self.related_query + "]" else ""
|
||||
"There was an SQL error: " + self.java_exception.getMessage.to_text + "." + query
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the SQL error.
|
||||
to_display_text : Text
|
||||
to_display_text self = self.to_text
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Throws an error as if a SQL Exception was thrown.
|
||||
throw_sql_error : Text -> SQL_Error
|
||||
throw_sql_error message =
|
||||
Error.throw (SQL_Error.Error (SQLException.new message))
|
||||
|
||||
type SQL_Timeout
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
|
||||
Indicates that an operation has timed out.
|
||||
|
||||
@ -65,24 +60,20 @@ type SQL_Timeout
|
||||
error is related to.
|
||||
Error java_exception related_query=Nothing
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Convert the timeout error to a textual representation.
|
||||
to_text : Text
|
||||
to_text self =
|
||||
query = if self.related_query.is_nothing.not then " [Query was: " + query + "]" else ""
|
||||
"The SQL connection timed out: " + self.java_exception.getMessage + "." + query
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the timeout error.
|
||||
to_display_text : Text
|
||||
to_display_text self = self.to_text
|
||||
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Signals that a name for a column or table is not supported.
|
||||
## Signals that a name for a column or table is not supported.
|
||||
|
||||
Arguments:
|
||||
- text: The name that is not supported.
|
||||
@ -91,25 +82,23 @@ type SQL_Timeout
|
||||
underscore. This is a temporary limitation simplifying name handling. It will
|
||||
be removed in a future version.
|
||||
type Unsupported_Name
|
||||
## PRIVATE
|
||||
Error text
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Creates a human-readable representation of the unsupported name error.
|
||||
to_text : Text
|
||||
to_text self =
|
||||
"The name " + self.text + " is not currently supported by the Database library."
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the unsupported name error.
|
||||
to_display_text : Text
|
||||
to_display_text self = self.to_text
|
||||
|
||||
|
||||
type Integrity_Error
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Signalizes that an operation tried using objects coming from different
|
||||
contexts.
|
||||
|
||||
@ -122,14 +111,14 @@ type Integrity_Error
|
||||
to_text : Text
|
||||
to_text self = self.object_description + " comes from a different context."
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the integrity error.
|
||||
to_display_text : Text
|
||||
to_display_text self = self.to_text
|
||||
|
||||
type Table_Not_Found
|
||||
## Indicates that a table was not found in the database.
|
||||
## PRIVATE
|
||||
Indicates that a table was not found in the database.
|
||||
|
||||
Arguments:
|
||||
- table_name: The name of the table that was not found.
|
||||
@ -139,6 +128,8 @@ type Table_Not_Found
|
||||
string.
|
||||
Error (name:Text) (related_query_error:SQL_Error) (treated_as_query:Boolean)
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the table not found error.
|
||||
to_display_text : Text
|
||||
to_display_text self = case self.treated_as_query of
|
||||
True -> "The name " + self.name + " was treated as a query, but the query failed with the following error: " + self.related_query_error.to_display_text + "; if you want to force to use that as a table name, wrap it in `SQL_Query.Table_Name`."
|
||||
|
@ -5,10 +5,10 @@ import Standard.Table.Data.Aggregate_Column.Aggregate_Column
|
||||
from Standard.Table.Data.Aggregate_Column.Aggregate_Column import all
|
||||
|
||||
import project.Data.Dialect.Dialect
|
||||
import project.Data.SQL_Type.SQL_Type
|
||||
import project.Data.Table.Table
|
||||
import project.Internal.IR.SQL_Expression.SQL_Expression
|
||||
import project.Internal.IR.Internal_Column.Internal_Column
|
||||
import project.Internal.SQL_Type_Reference.SQL_Type_Reference
|
||||
|
||||
from project.Errors import Unsupported_Database_Operation
|
||||
|
||||
@ -22,7 +22,7 @@ from project.Errors import Unsupported_Database_Operation
|
||||
- infer_return_type: A function that takes 3 arguments (name of the
|
||||
operation, list of input columns and a raw SQL IR Expression) and returns
|
||||
the inferred type for the aggregation.
|
||||
make_aggregate_column : Aggregate_Column -> Text -> Dialect -> SQL_Expression
|
||||
make_aggregate_column : Aggregate_Column -> Text -> Dialect -> (Any -> Any -> Any -> SQL_Type_Reference) -> SQL_Expression
|
||||
make_aggregate_column aggregate new_name dialect infer_return_type =
|
||||
is_non_empty_selector v = v.is_nothing.not && v.not_empty
|
||||
simple_aggregate op_kind columns =
|
||||
|
@ -8,7 +8,9 @@ import project.Internal.IR.SQL_Expression.SQL_Expression
|
||||
import project.Internal.SQL_Type_Reference.SQL_Type_Reference
|
||||
|
||||
type SQL_Type_Mapping
|
||||
## Converts the given Value_Type to its corresponding SQL_Type.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Converts the given Value_Type to its corresponding SQL_Type.
|
||||
|
||||
Some SQL dialects may not support all Value_Types (in fact most will
|
||||
have at least a few exceptions, and some like SQLite may have very
|
||||
@ -24,13 +26,17 @@ type SQL_Type_Mapping
|
||||
_ = [value_type, on_problems]
|
||||
Unimplemented.throw "This is an interface only."
|
||||
|
||||
## Converts the given SQL_Type to its corresponding Value_Type.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Converts the given SQL_Type to its corresponding Value_Type.
|
||||
sql_type_to_value_type : SQL_Type -> Value_Type
|
||||
sql_type_to_value_type sql_type =
|
||||
_ = sql_type
|
||||
Unimplemented.throw "This is an interface only."
|
||||
|
||||
## Returns a `SQL_Type_Reference` that will resolve to the resulting type of
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns a `SQL_Type_Reference` that will resolve to the resulting type of
|
||||
the given operation.
|
||||
|
||||
In most cases this will just delegate to `infer_from_database_callback`
|
||||
|
@ -136,7 +136,8 @@ type SQLite_Type_Mapping
|
||||
Nothing -> Nothing
|
||||
_ : Vector -> column_type_suggestions.map .get
|
||||
|
||||
## The types that SQLite JDBC driver will report are: BOOLEAN, TINYINT,
|
||||
## PRIVATE
|
||||
The types that SQLite JDBC driver will report are: BOOLEAN, TINYINT,
|
||||
SMALLINT, BIGINT, INTEGER, DECIMAL, DOUBLE, REAL, FLOAT, NUMERIC, DATE,
|
||||
TIMESTAMP, CHAR, VARCHAR, BINARY, BLOB, CLOB.
|
||||
|
||||
@ -155,6 +156,7 @@ simple_types_map = Map.from_vector <|
|
||||
special_types = [[Types.BOOLEAN, Value_Type.Boolean]]
|
||||
ints + floats + numerics + strings + blobs + special_types
|
||||
|
||||
## PRIVATE
|
||||
type SQLite_Types
|
||||
## PRIVATE
|
||||
text = SQL_Type.Value Types.VARCHAR "TEXT"
|
||||
|
@ -1,10 +1,9 @@
|
||||
from Standard.Base import all
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
type Histogram
|
||||
|
||||
## PRIVATE
|
||||
|
||||
The histogram of a single image channel.
|
||||
|
||||
Arguments:
|
||||
@ -12,8 +11,7 @@ type Histogram
|
||||
- data: The histogram data.
|
||||
Value channel data
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Convert histogram data to a JS_Object.
|
||||
|
||||
> Example
|
||||
|
@ -108,7 +108,7 @@ type Image
|
||||
Panic.catch JException (Java_Codecs.write path self.opencv_mat int_flags) _->
|
||||
Error.throw (File_Error.IO_Error (File.new path) 'Failed to write to the file')
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
|
||||
The image data type.
|
||||
|
||||
@ -120,9 +120,7 @@ type Image
|
||||
Pixel values are normalized in a range [0.0 .. 1.0].
|
||||
Value opencv_mat
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Return the number of image rows.
|
||||
## Return the number of image rows.
|
||||
|
||||
> Example
|
||||
Get the number of rows from an image.
|
||||
@ -133,9 +131,7 @@ type Image
|
||||
rows : Integer
|
||||
rows self = self.opencv_mat.rows
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Return the number of image columns.
|
||||
## Return the number of image columns.
|
||||
|
||||
> Example
|
||||
Get the number of columns from an image.
|
||||
@ -146,9 +142,7 @@ type Image
|
||||
columns : Integer
|
||||
columns self = self.opencv_mat.cols
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Return the number of image channels.
|
||||
## Return the number of image channels.
|
||||
|
||||
> Example
|
||||
Get the number of channels from an image.
|
||||
@ -159,9 +153,7 @@ type Image
|
||||
channels : Integer
|
||||
channels self = self.opencv_mat.channels
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Get the pixel value indexed by row and column.
|
||||
## Get the pixel value indexed by row and column.
|
||||
|
||||
Arguments:
|
||||
- row: the row index.
|
||||
@ -180,9 +172,7 @@ type Image
|
||||
arr = Java_Image.get self.opencv_mat row column
|
||||
Vector.from_polyglot_array arr
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Calculates the per-element sum of an image and a scalar or a matrix.
|
||||
## Calculates the per-element sum of an image and a scalar or a matrix.
|
||||
|
||||
Arguments:
|
||||
- value: A value can be a number, a vector of numbers, or a matrix. The
|
||||
@ -231,9 +221,7 @@ type Image
|
||||
+ : (Number | Vector | Matrix) -> Image ! Matrix_Error
|
||||
+ self value = Panic.recover Any (core_op self.opencv_mat value (Java_Image.add _ _ _)) . catch Any core_op_handler
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Calculates the per-element difference between an image and a scalar or a matrix.
|
||||
## Calculates the per-element difference between an image and a scalar or a matrix.
|
||||
|
||||
Arguments:
|
||||
- value: A value can be a number, a vector of numbers, or a matrix. The
|
||||
@ -282,9 +270,7 @@ type Image
|
||||
- : (Number | Vector | Matrix) -> Image ! Matrix_Error
|
||||
- self value = Panic.recover Any (core_op self.opencv_mat value (Java_Image.subtract _ _ _)) . catch Any core_op_handler
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Calculates the per-element product of an image and a scalar or a matrix.
|
||||
## Calculates the per-element product of an image and a scalar or a matrix.
|
||||
|
||||
Arguments:
|
||||
- value: A value can be a number, a vector of numbers, or a matrix. The
|
||||
@ -333,9 +319,7 @@ type Image
|
||||
* : (Number | Vector | Matrix) -> Image ! Matrix_Error
|
||||
* self value = Panic.recover Any (core_op self.opencv_mat value (Java_Image.multiply _ _ _)) . catch Any core_op_handler
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Performs per-element division of an image and a scalar or a matrix.
|
||||
## Performs per-element division of an image and a scalar or a matrix.
|
||||
|
||||
Arguments:
|
||||
- value: A value can be a number, a vector of numbers, or a matrix. The
|
||||
@ -384,9 +368,7 @@ type Image
|
||||
/ : (Number | Vector | Matrix) -> Image ! Matrix_Error
|
||||
/ self value = Panic.recover Any (core_op self.opencv_mat value (Java_Image.divide _ _ _)) . catch Any core_op_handler
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Convert the image to a vector.
|
||||
## Convert the image to a vector.
|
||||
|
||||
> Example
|
||||
Convert an image to a vector.
|
||||
@ -399,8 +381,7 @@ type Image
|
||||
arr = Java_Image.to_vector self.opencv_mat
|
||||
Vector.from_polyglot_array arr
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Convert the image to a JS_Object.
|
||||
|
||||
> Example
|
||||
@ -414,9 +395,7 @@ type Image
|
||||
base64 = Java_Image.to_base64 self.opencv_mat
|
||||
JS_Object.from_pairs [["mediaType", "image/png"], ["base64", base64]]
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Convert the image to a Matrix.
|
||||
## Convert the image to a Matrix.
|
||||
|
||||
> Example
|
||||
Convert an image to a matrix.
|
||||
@ -427,9 +406,7 @@ type Image
|
||||
to_matrix : Matrix
|
||||
to_matrix self = Matrix.from_vector self.to_vector self.rows self.channels
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Create a histogram for the specified channel of the image.
|
||||
## Create a histogram for the specified channel of the image.
|
||||
|
||||
Arguments:
|
||||
- channel: the channel number.
|
||||
@ -480,10 +457,14 @@ core_op_handler error =
|
||||
|
||||
## PRIVATE
|
||||
type Image_Comparator
|
||||
## PRIVATE
|
||||
compare : Image -> Image -> Ordering
|
||||
compare x y =
|
||||
if Java_Image.is_equals x.opencv_mat y.opencv_mat then Ordering.Equal else
|
||||
Nothing
|
||||
|
||||
## PRIVATE
|
||||
hash : Image -> Integer
|
||||
hash x = x.opencv_mat.hashCode
|
||||
|
||||
Comparable.from (_:Image) = Image_Comparator
|
||||
|
@ -11,7 +11,6 @@ polyglot java import org.opencv.core.Scalar
|
||||
|
||||
## UNSTABLE
|
||||
type Matrix
|
||||
|
||||
## PRIVATE
|
||||
|
||||
The matrix data type.
|
||||
@ -99,9 +98,7 @@ type Matrix
|
||||
from_vector values rows=1 channels=1 =
|
||||
Matrix.Value (Java_Matrix.from_vector values.to_array channels rows)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Return the number of matrix rows.
|
||||
## Return the number of matrix rows.
|
||||
|
||||
> Example
|
||||
Get the number of rows in this matrix.
|
||||
@ -112,9 +109,7 @@ type Matrix
|
||||
rows : Integer
|
||||
rows self = self.opencv_mat.rows
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Return the number of matrix columns.
|
||||
## Return the number of matrix columns.
|
||||
|
||||
> Example
|
||||
Get the number of columns in this matrix.
|
||||
@ -136,9 +131,7 @@ type Matrix
|
||||
channels : Integer
|
||||
channels self = self.opencv_mat.channels
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Get the matrix value at the specified row and column.
|
||||
## Get the matrix value at the specified row and column.
|
||||
|
||||
Arguments:
|
||||
- row: the row index.
|
||||
@ -157,9 +150,7 @@ type Matrix
|
||||
arr = Java_Matrix.get self.opencv_mat row column
|
||||
Vector.from_polyglot_array arr
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Reshape the matrix specifying new number of rows and channels.
|
||||
## Reshape the matrix specifying new number of rows and channels.
|
||||
|
||||
Arguments:
|
||||
- rows: the new number of rows.
|
||||
@ -177,9 +168,7 @@ type Matrix
|
||||
Nothing -> Matrix.Value (self.opencv_mat.reshape self.channels rows)
|
||||
_ -> Matrix.Value (self.opencv_mat.reshape channels rows)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Calculates the per-element sum of two matrices or a matrix and a scalar.
|
||||
## Calculates the per-element sum of two matrices or a matrix and a scalar.
|
||||
|
||||
Arguments:
|
||||
- value: A value can be a number, a vector of numbers, or a matrix. The
|
||||
@ -215,9 +204,7 @@ type Matrix
|
||||
+ : (Number | Vector | Matrix) -> Matrix ! Matrix_Error
|
||||
+ self value = Panic.recover Any (core_op self.opencv_mat value (Java_Matrix.add _ _ _)) . catch core_op_handler
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Calculates the per-element difference of two matrices or of a matrix and
|
||||
## Calculates the per-element difference of two matrices or of a matrix and
|
||||
a scalar.
|
||||
|
||||
Arguments:
|
||||
@ -254,9 +241,7 @@ type Matrix
|
||||
- : (Number | Vector | Matrix) -> Matrix ! Matrix_Error
|
||||
- self value = Panic.recover Any (core_op self.opencv_mat value (Java_Matrix.subtract _ _ _)) . catch core_op_handler
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Calculates the per-element product of two matrices or a matrix and a
|
||||
## Calculates the per-element product of two matrices or a matrix and a
|
||||
scalar.
|
||||
|
||||
Arguments:
|
||||
@ -298,9 +283,7 @@ type Matrix
|
||||
* : (Number | Vector | Matrix) -> Matrix ! Matrix_Error
|
||||
* self value = Panic.recover Any (core_op self.opencv_mat value (Java_Matrix.multiply _ _ _)) . catch core_op_handler
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Performs per-element division of two matrices or a matrix and a scalar.
|
||||
## Performs per-element division of two matrices or a matrix and a scalar.
|
||||
|
||||
Arguments:
|
||||
- value: A value can be a number, a vector of numbers, or a matrix. The
|
||||
@ -336,9 +319,7 @@ type Matrix
|
||||
/ : (Number | Vector | Matrix) -> Matrix ! Matrix_Error
|
||||
/ self value = Panic.recover Any (core_op self.opencv_mat value (Java_Matrix.divide _ _ _)) . catch core_op_handler
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Normalize the matrix into a range of [min_value .. max_value] so that the
|
||||
## Normalize the matrix into a range of [min_value .. max_value] so that the
|
||||
minimum value of the matrix becomes `min_value` and the maximum value of
|
||||
the matrix becomes `max_value`.
|
||||
|
||||
@ -370,9 +351,7 @@ type Matrix
|
||||
normalize self min_value=0.0 max_value=1.0 =
|
||||
Matrix.Value (Java_Matrix.normalize self.opencv_mat min_value max_value)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Convert this matrix to an image.
|
||||
## Convert this matrix to an image.
|
||||
|
||||
> Example
|
||||
Convert a matrix to an image.
|
||||
@ -383,9 +362,7 @@ type Matrix
|
||||
to_image : Image
|
||||
to_image self = Image (Image.from_vector self.normalize.to_vector self.rows self.channels)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Get the elements of this matrix as a vector.
|
||||
## Get the elements of this matrix as a vector.
|
||||
|
||||
> Example
|
||||
Convert a matrix to a vector.
|
||||
@ -398,8 +375,7 @@ type Matrix
|
||||
arr = Java_Matrix.to_vector self.opencv_mat
|
||||
Vector.from_polyglot_array arr
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Convert this matrix to a JS_Object.
|
||||
|
||||
> Example
|
||||
@ -412,7 +388,6 @@ type Matrix
|
||||
to_js_object self = self.opencv_mat.to_text
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Apply a core matrix operation.
|
||||
|
||||
Arguments:
|
||||
@ -433,7 +408,6 @@ core_op mat value function =
|
||||
Matrix.Value result
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Handles errors in `core_op`.
|
||||
|
||||
Arguments:
|
||||
@ -445,10 +419,14 @@ core_op_handler error =
|
||||
|
||||
## PRIVATE
|
||||
type Matrix_Comparator
|
||||
## PRIVATE
|
||||
compare : Matrix -> Matrix -> Ordering
|
||||
compare x y =
|
||||
if Java_Matrix.is_equals x.opencv_mat y.opencv_mat then Ordering.Equal else
|
||||
Nothing
|
||||
|
||||
## PRIVATE
|
||||
hash : Matrix -> Number
|
||||
hash x = x.opencv_mat.hashCode
|
||||
|
||||
Comparable.from (_:Matrix) = Matrix_Comparator
|
||||
|
@ -1,10 +1,8 @@
|
||||
from Standard.Base import all
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
type Matrix_Error
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Indicates that a matrix has been accessed with an illegal index.
|
||||
|
||||
Arguments:
|
||||
@ -13,14 +11,12 @@ type Matrix_Error
|
||||
- index: The requested index in the matrix.
|
||||
Index_Out_Of_Bounds rows columns index
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
An error indicating that an operation has failed due to a mismatch of
|
||||
matrix dimensions.
|
||||
Dimensions_Not_Equal
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Pretty-prints a matrix error to be readable by the users.
|
||||
to_display_text : Text
|
||||
to_display_text self = case self of
|
||||
|
@ -12,19 +12,22 @@ type Image_File_Format
|
||||
## File_Format to read Image files
|
||||
For_File
|
||||
|
||||
## If the File_Format supports reading from the file, return a configured instance.
|
||||
## PRIVATE
|
||||
If the File_Format supports reading from the file, return a configured instance.
|
||||
for_file : File -> Image_File_Format | Nothing
|
||||
for_file file =
|
||||
extension = file.extension
|
||||
if supported.contains extension then Image_File_Format.For_File else Nothing
|
||||
|
||||
## If the File_Format supports reading from the web response, return a configured instance.
|
||||
## PRIVATE
|
||||
If the File_Format supports reading from the web response, return a configured instance.
|
||||
for_web : Text -> URI -> Image_File_Format | Nothing
|
||||
for_web _ _ =
|
||||
## Currently not loading Image files automatically. This should be supported later.
|
||||
Nothing
|
||||
|
||||
## Implements the `File.read` for this `File_Format`
|
||||
## PRIVATE
|
||||
Implements the `File.read` for this `File_Format`
|
||||
read : File -> Problem_Behavior -> Any
|
||||
read self file on_problems =
|
||||
_ = [on_problems]
|
||||
|
@ -14,6 +14,7 @@ component-groups:
|
||||
exports:
|
||||
- Standard.Table.Data.Table.Table.new
|
||||
- Standard.Table.Data.Table.Table.from_rows
|
||||
- Standard.Table.Data.Table.Table.from_objects
|
||||
- Standard.Table.Data.Column.Column.from_vector
|
||||
- Standard.Base.Select:
|
||||
exports:
|
||||
|
@ -50,7 +50,9 @@ type Column
|
||||
Illegal_Argument.handle_java_exception <|
|
||||
Column.Value (Java_Column.new name storage)
|
||||
|
||||
## Creates a new column given a name and a vector of elements repeated over and over.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a new column given a name and a vector of elements repeated over and over.
|
||||
|
||||
Arguments:
|
||||
- name: The name of the column to create.
|
||||
@ -69,7 +71,9 @@ type Column
|
||||
- java_column: The internal representation of the column.
|
||||
Value java_column
|
||||
|
||||
## Returns a text containing an ASCII-art table displaying this data.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns a text containing an ASCII-art table displaying this data.
|
||||
|
||||
Arguments:
|
||||
- show_rows: the number of initial rows that should be displayed.
|
||||
@ -98,7 +102,9 @@ type Column
|
||||
missing = '\n\u2026 and ' + (num_rows - display_rows).to_text + ' hidden rows.'
|
||||
table + missing
|
||||
|
||||
## TEXT_ONLY
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
TEXT_ONLY
|
||||
|
||||
Prints an ASCII-art table with this data to the standard output.
|
||||
|
||||
@ -912,7 +918,7 @@ type Column
|
||||
|
||||
Applies only to columns that hold the `Date` or `Date_Time` types.
|
||||
Returns a column of `Integer` type.
|
||||
year : Column -> Column ! Invalid_Value_Type
|
||||
year : Column ! Invalid_Value_Type
|
||||
year self = Value_Type.expect_has_date self.value_type related_column=self.name <|
|
||||
simple_unary_op self "year"
|
||||
|
||||
@ -921,7 +927,7 @@ type Column
|
||||
|
||||
Applies only to columns that hold the `Date` or `Date_Time` types.
|
||||
Returns a column of `Integer` type.
|
||||
month : Column -> Column ! Invalid_Value_Type
|
||||
month : Column ! Invalid_Value_Type
|
||||
month self = Value_Type.expect_has_date self.value_type related_column=self.name <|
|
||||
simple_unary_op self "month"
|
||||
|
||||
@ -930,7 +936,7 @@ type Column
|
||||
|
||||
Applies only to columns that hold the `Date` or `Date_Time` types.
|
||||
Returns a column of `Integer` type.
|
||||
day : Column -> Column ! Invalid_Value_Type
|
||||
day : Column ! Invalid_Value_Type
|
||||
day self = Value_Type.expect_has_date self.value_type related_column=self.name <|
|
||||
simple_unary_op self "day"
|
||||
|
||||
@ -1206,8 +1212,7 @@ type Column
|
||||
storage_type = self.java_column.getStorage.getType
|
||||
Storage.to_value_type storage_type
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Converts this column to JS_Object representation.
|
||||
|
||||
> Example
|
||||
@ -1320,9 +1325,7 @@ type Column
|
||||
limit = Math.max (Math.min (end - offset) (length - offset)) 0
|
||||
Column.Value (self.java_column.slice offset limit)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns the first element in the column, if it exists.
|
||||
## Returns the first element in the column, if it exists.
|
||||
|
||||
If the column is empty, this method will return a dataflow error
|
||||
containing an `Index_Out_Of_Bounds`.
|
||||
@ -1336,9 +1339,7 @@ type Column
|
||||
first : Any ! Index_Out_Of_Bounds
|
||||
first self = self.at 0
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns the last element in the column, if it exists.
|
||||
## Returns the last element in the column, if it exists.
|
||||
|
||||
If the column is empty, this method will return a dataflow error
|
||||
containing an `Index_Out_Of_Bounds`.
|
||||
@ -1352,9 +1353,7 @@ type Column
|
||||
last : Any ! Index_Out_Of_Bounds
|
||||
last self = self.at (self.length - 1)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns a column containing the values of `self` column with their order
|
||||
## Returns a column containing the values of `self` column with their order
|
||||
reversed.
|
||||
|
||||
> Example
|
||||
@ -1368,9 +1367,7 @@ type Column
|
||||
mask = OrderBuilder.buildReversedMask self.length
|
||||
Column.Value (self.java_column.applyMask mask)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns a column of numbers, in which every entry denotes how many times
|
||||
## Returns a column of numbers, in which every entry denotes how many times
|
||||
the value at the given position occured before.
|
||||
|
||||
> Example
|
||||
@ -1382,7 +1379,8 @@ type Column
|
||||
duplicate_count : Column
|
||||
duplicate_count self = Column.Value self.java_column.duplicateCount
|
||||
|
||||
## Provides a simplified text representation for display in the REPL and errors.
|
||||
## PRIVATE
|
||||
Provides a simplified text representation for display in the REPL and errors.
|
||||
to_text : Text
|
||||
to_text self = "(In-Memory Column "+self.name.to_text+")"
|
||||
|
||||
|
@ -61,7 +61,9 @@ type Data_Formatter
|
||||
- false_values: Values representing False.
|
||||
Value trim_values:Boolean=True allow_leading_zeros:Boolean=False decimal_point:Text='.' thousand_separator:Text='' allow_exponential_notation:Boolean=False datetime_formats:(Vector Text)=["ENSO_ZONED_DATE_TIME"] date_formats:(Vector Text)=["ISO_LOCAL_DATE"] time_formats:(Vector Text)=["ISO_LOCAL_TIME"] datetime_locale:Locale=Locale.default true_values:(Vector Text)=["True","true","TRUE"] false_values:(Vector Text)=["False","false","FALSE"]
|
||||
|
||||
## Parse a Text into a value.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Parse a Text into a value.
|
||||
|
||||
Arguments:
|
||||
- text: Text value to parse.
|
||||
@ -79,7 +81,9 @@ type Data_Formatter
|
||||
problems = Vector.from_polyglot_array result.problems . map (Parse_Values_Helper.translate_parsing_problem datatype)
|
||||
on_problems.attach_problems_after result.value problems
|
||||
|
||||
## Format a value into a Text.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Format a value into a Text.
|
||||
|
||||
Arguments:
|
||||
- value: Value to format.
|
||||
|
@ -5,7 +5,9 @@ polyglot java import java.lang.IllegalArgumentException
|
||||
polyglot java import java.lang.UnsupportedOperationException
|
||||
|
||||
type Expression
|
||||
## Evaluates an expression and returns the result
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Evaluates an expression and returns the result
|
||||
|
||||
Arguments:
|
||||
- expression: the expression to evaluate
|
||||
@ -29,15 +31,21 @@ type Expression
|
||||
ExpressionVisitorImpl.evaluate expression get_column make_constant module_name type_name var_args_functions.to_array
|
||||
|
||||
type Expression_Error
|
||||
## The expression supplied could not be parsed due to a syntax error.
|
||||
## PRIVATE
|
||||
The expression supplied could not be parsed due to a syntax error.
|
||||
Syntax_Error message:Text line:Integer column:Integer
|
||||
|
||||
## Expression error when a function could not be found on the target type.
|
||||
## PRIVATE
|
||||
Expression error when a function could not be found on the target type.
|
||||
Unsupported_Operation name:Text
|
||||
|
||||
## Expression error when the number of arguments for a function is incorrect.
|
||||
## PRIVATE
|
||||
Expression error when the number of arguments for a function is incorrect.
|
||||
Argument_Mismatch message:Text
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self = case self of
|
||||
Expression_Error.Syntax_Error _ _ _ -> "Expression.Syntax_Error: " + self.message + " (line " + self.line.to_text + ", column " + self.column.to_text + ")."
|
||||
|
@ -35,6 +35,7 @@ type Row
|
||||
to_vector : Vector
|
||||
to_vector self = Vector.from_polyglot_array (Array_Proxy.from_proxy_object self)
|
||||
|
||||
## Converts this row into a JS_Object.
|
||||
## PRIVATE
|
||||
Converts this row into a JS_Object.
|
||||
to_js_object : Vector
|
||||
to_js_object self = self.to_vector.to_js_object
|
||||
|
@ -116,7 +116,9 @@ type Table
|
||||
- java_table: The internal java representation of the table.
|
||||
Value java_table
|
||||
|
||||
## Returns a text containing an ASCII-art table displaying this data.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Returns a text containing an ASCII-art table displaying this data.
|
||||
|
||||
Arguments:
|
||||
- show_rows: the number of initial rows that should be displayed.
|
||||
@ -145,7 +147,9 @@ type Table
|
||||
missing = '\n\u2026 and ' + (num_rows - display_rows).to_text + ' hidden rows.'
|
||||
table + missing
|
||||
|
||||
## Prints an ASCII-art table with this data to the standard output.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Prints an ASCII-art table with this data to the standard output.
|
||||
|
||||
Arguments:
|
||||
- show_rows: the number of initial rows that should be displayed.
|
||||
@ -161,7 +165,8 @@ type Table
|
||||
IO.println (self.display show_rows format_terminal=True)
|
||||
IO.println ''
|
||||
|
||||
## Converts this table into a JS_Object.
|
||||
## PRIVATE
|
||||
Converts this table into a JS_Object.
|
||||
|
||||
> Example
|
||||
Convert a table to a corresponding JavaScript JS_Object representation.
|
||||
@ -1706,9 +1711,7 @@ type Table
|
||||
limit = Math.max (Math.min (end - offset) (length - offset)) 0
|
||||
Table.Value (self.java_table.slice offset limit)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
Returns a table containing the rows of `self` table with their order
|
||||
## Returns a table containing the rows of `self` table with their order
|
||||
reversed.
|
||||
|
||||
> Example
|
||||
|
@ -11,7 +11,7 @@ import project.Data.Type.Value_Type.Bits
|
||||
for integers it will return 64-bit integers even if the value could fit in a
|
||||
smaller one; and for Text values variable-length text will be preferred over
|
||||
fixed-length.
|
||||
most_specific_value_type : Any -> Value_Type
|
||||
most_specific_value_type : Any -> Boolean -> Value_Type
|
||||
most_specific_value_type value use_smallest=False =
|
||||
## TODO implement the `use_smallest` logic
|
||||
_ = use_smallest
|
||||
|
@ -29,12 +29,19 @@ type Bits
|
||||
64 -> Bits.Bits_64
|
||||
_ : Integer -> Error.throw (Illegal_Argument.Error "Invalid number of bits for a float or integer type.")
|
||||
|
||||
## Provides the text representation of the bit-size.
|
||||
## PRIVATE
|
||||
Provides the text representation of the bit-size.
|
||||
to_text : Text
|
||||
to_text self = self.to_bits.to_text + " bits"
|
||||
|
||||
## PRIVATE
|
||||
type Bits_Comparator
|
||||
## PRIVATE
|
||||
compare : Bits -> Bits -> Ordering
|
||||
compare x y = Comparable.from x.to_bits . compare x.to_bits y.to_bits
|
||||
|
||||
## PRIVATE
|
||||
hash : Bits -> Integer
|
||||
hash x = Comparable.from x.to_bits . hash x.to_bits
|
||||
|
||||
Comparable.from (_:Bits) = Bits_Comparator
|
||||
@ -179,8 +186,8 @@ type Value_Type
|
||||
Value_Type.Date_Time _ -> True
|
||||
_ -> False
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Checks if the provided value type is a textual type (with any settings)
|
||||
and runs the following action or reports a type error.
|
||||
expect_text : Value_Type -> Any -> Text -> Any ! Invalid_Value_Type
|
||||
@ -188,8 +195,8 @@ type Value_Type
|
||||
if Value_Type.is_text value_type then action else
|
||||
Error.throw (Invalid_Value_Type.Error Value_Type.Char value_type related_column)
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Checks if the provided value type is a boolean type and runs the
|
||||
following action or reports a type error.
|
||||
expect_boolean : Value_Type -> Any -> Any ! Invalid_Value_Type
|
||||
@ -197,15 +204,16 @@ type Value_Type
|
||||
Value_Type.Boolean -> action
|
||||
_ -> Error.throw (Invalid_Value_Type.Error Value_Type.Boolean value_type)
|
||||
|
||||
## ADVANCED
|
||||
UNSTABLE
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Checks if the provided value type is a `Date` or `Date_Time`.
|
||||
expect_has_date : Value_Type -> Any -> Text -> Any ! Invalid_Value_Type
|
||||
expect_has_date value_type ~action related_column=Nothing = case value_type.has_date of
|
||||
True -> action
|
||||
False -> Error.throw (Invalid_Value_Type.Error "Date or Date_Time" value_type related_column)
|
||||
|
||||
## Provides a text representation of the `Value_Type` meant for
|
||||
## PRIVATE
|
||||
Provides a text representation of the `Value_Type` meant for
|
||||
displaying to the user.
|
||||
to_display_text : Text
|
||||
to_display_text self = case self of
|
||||
|
@ -51,7 +51,9 @@ type Delimited_Format
|
||||
defaults to `Nothing` which means that comments are disabled.
|
||||
Delimited (delimiter:Text) (encoding:Encoding=Encoding.utf_8) (skip_rows:Integer=0) (row_limit:Integer|Nothing=Nothing) (quote_style:Quote_Style=Quote_Style.With_Quotes) (headers:Boolean|Infer=Infer) (value_formatter:Data_Formatter|Nothing=Data_Formatter.Value) (keep_invalid_rows:Boolean=True) (line_endings:Line_Ending_Style=Infer) (comment_character:Text|Nothing=Nothing)
|
||||
|
||||
## If the File_Format supports reading from the file, return a configured instance.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
If the File_Format supports reading from the file, return a configured instance.
|
||||
for_file : File -> Delimited_Format | Nothing
|
||||
for_file file =
|
||||
case file.extension of
|
||||
@ -60,7 +62,9 @@ type Delimited_Format
|
||||
".tsv" -> Delimited_Format.Delimited '\t'
|
||||
_ -> Nothing
|
||||
|
||||
## If the File_Format supports reading from the web response, return a configured instance.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
If the File_Format supports reading from the web response, return a configured instance.
|
||||
for_web : Text -> URI -> Delimited_Format | Nothing
|
||||
for_web content_type _ =
|
||||
parts = content_type.split ";" . map .trim
|
||||
@ -75,7 +79,9 @@ type Delimited_Format
|
||||
"text/tab-separated-values" -> Delimited_Format.Delimited '\t' encoding
|
||||
_ -> Nothing
|
||||
|
||||
## Implements the `File.read` for this `File_Format`
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Implements the `File.read` for this `File_Format`
|
||||
read : File -> Problem_Behavior -> Any
|
||||
read self file on_problems =
|
||||
Delimited_Reader.read_file self file on_problems
|
||||
@ -87,7 +93,9 @@ type Delimited_Format
|
||||
text = Text.from_bytes response.body.bytes self.encoding
|
||||
Delimited_Reader.read_text text self Report_Warning
|
||||
|
||||
## Implements the `Table.write` for this `File_Format`.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Implements the `Table.write` for this `File_Format`.
|
||||
write_table : File -> Table -> Existing_File_Behavior -> Match_Columns -> Problem_Behavior -> File
|
||||
write_table self file table on_existing_file match_columns on_problems =
|
||||
r = Delimited_Writer.write_file table self file on_existing_file match_columns on_problems
|
||||
|
@ -83,6 +83,7 @@ type No_Output_Columns
|
||||
## Indicates that one column has been matched by multiple selectors, resulting
|
||||
in ambiguous new names.
|
||||
type Ambiguous_Column_Rename
|
||||
## PRIVATE
|
||||
Error (column_name : Text) (new_names : Vector Text)
|
||||
|
||||
## PRIVATE
|
||||
@ -95,14 +96,21 @@ type Ambiguous_Column_Rename
|
||||
## Indicates that no input columns were selected for the operation, so the
|
||||
operation will cause no effect.
|
||||
type No_Input_Columns_Selected
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"No input columns have been selected for the operation."
|
||||
|
||||
## Indicates that an aggregation calculation could not be completed.
|
||||
type Invalid_Aggregation
|
||||
## PRIVATE
|
||||
Error (column:Text) (rows:[Integer]) (message:Text)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"The "+self.column+" could not be calculated at "+self.rows.short_display_text+": "+self.message
|
||||
@ -110,8 +118,12 @@ type Invalid_Aggregation
|
||||
## Indicates that some operation relies on equality on floating-point values,
|
||||
which is not recommended.
|
||||
type Floating_Point_Equality
|
||||
## PRIVATE
|
||||
Error (location:Text)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"Relying on equality of floating-point numbers is not recommended (within "+self.location+")."
|
||||
@ -119,16 +131,24 @@ type Floating_Point_Equality
|
||||
## Indicates that a text value with a delimiter was included in a concatenation
|
||||
without any quote character
|
||||
type Unquoted_Delimiter
|
||||
## PRIVATE
|
||||
Error (column:Text) (rows:[Integer])
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"The "+self.column+" at rows "+self.rows.short_display_text+" contains the delimiter and there is no specified quote character."
|
||||
|
||||
## Warning when additional warnings occurred.
|
||||
type Additional_Warnings
|
||||
## PRIVATE
|
||||
Error (count:Integer)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"There were "+self.count.to_text+" additional issues."
|
||||
@ -139,8 +159,12 @@ type Additional_Warnings
|
||||
Only the first 10 rows are reported, any additional ones are aggregated into
|
||||
a single instance of `Additional_Invalid_Rows`.
|
||||
type Invalid_Row
|
||||
## PRIVATE
|
||||
Error (source_file_line_number : Integer) (index : Integer | Nothing) (row : [Text]) (expected_columns : Integer)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
table_loc = case self.index of
|
||||
@ -154,8 +178,12 @@ type Invalid_Row
|
||||
|
||||
## Indicates how many additional `Invalid_Row` warnings have been suppressed.
|
||||
type Additional_Invalid_Rows
|
||||
## PRIVATE
|
||||
Error (count : Integer)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"There were "+self.count.to_text+" additional invalid rows."
|
||||
@ -163,8 +191,12 @@ type Additional_Invalid_Rows
|
||||
## Indicates that a quote inside of a delimited file cell has been opened but
|
||||
never closed.
|
||||
type Mismatched_Quote
|
||||
## PRIVATE
|
||||
Error (cell_text : Text)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
max_length = 50
|
||||
@ -173,27 +205,35 @@ type Mismatched_Quote
|
||||
|
||||
## Indicates an unexpected parser error.
|
||||
type Parser_Error
|
||||
## PRIVATE
|
||||
Error cause
|
||||
|
||||
## Indicates that quoting was disabled for a `Delimited` file, but some cells
|
||||
contained characters that do need quoting which may cause the output file to
|
||||
be corrupted.
|
||||
type Unquoted_Characters_In_Output
|
||||
## PRIVATE
|
||||
Warning (column : Text) (rows : [Integer])
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the unquoted characters error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
altered_rows = self.rows.map ix->
|
||||
if ix == -1 then "the header" else ix
|
||||
"The "+self.column+" at rows "+altered_rows.short_display_text+" contains characters that need quoting, but quoting is disabled. The generated file may be corrupted."
|
||||
|
||||
## PRIVATE
|
||||
to_text : Text
|
||||
to_text self = "Unquoted_Characters_In_Output.Warning "+self.column.pretty+" "+self.rows.to_text
|
||||
|
||||
## Indicates that a specified location was not valid.
|
||||
type Invalid_Location
|
||||
## PRIVATE
|
||||
Error (location:Text)
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the invalid location error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"The location '"+self.location+"' is not valid."
|
||||
@ -207,8 +247,11 @@ type Invalid_Location
|
||||
- cells: Contents of the cells that did not match the expected datatype
|
||||
format.
|
||||
type Invalid_Format
|
||||
## PRIVATE
|
||||
Error column:(Text|Nothing) (datatype:(Integer|Number|Date|Time|Time_Of_Day|Boolean)) (cells:[Text])
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the invalid format error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
self.cells.length+" cells in column "+self.column+" had invalid format for datatype "+self.datatype.to_text+"."
|
||||
@ -221,14 +264,18 @@ type Invalid_Format
|
||||
- datatype: The expected datatype.
|
||||
- cells: Contents of the cells that contained leading zeros.
|
||||
type Leading_Zeros
|
||||
## PRIVATE
|
||||
Error column:(Text|Nothing) (datatype:(Integer|Number|Date|Time|Time_Of_Day|Boolean)) (cells:[Text])
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the leading zeros error.
|
||||
to_display_text : Text
|
||||
to_display_text self = "Leading zeros in column "+self.column+" with datatype "+self.datatype.to_text+"."
|
||||
|
||||
## Indicates that an empty file was encountered, so no data could be loaded.
|
||||
type Empty_File_Error
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the empty file error.
|
||||
to_display_text : Text
|
||||
to_display_text = "It is not allowed to create a Table with no columns, so an empty file could not have been loaded."
|
||||
|
||||
@ -238,7 +285,8 @@ type Empty_File_Error
|
||||
|
||||
## Indicates that an empty sheet was encountered, so no data could be loaded.
|
||||
type Empty_Sheet_Error
|
||||
|
||||
## PRIVATE
|
||||
Pretty print the empty sheet error.
|
||||
to_display_text : Text
|
||||
to_display_text = "It is not allowed to create a Table with no columns, so an empty sheet could not have been loaded."
|
||||
|
||||
@ -246,51 +294,60 @@ type Empty_Sheet_Error
|
||||
handle_java_exception =
|
||||
Panic.catch EmptySheetException handler=(_ -> Error.throw Empty_Sheet_Error)
|
||||
|
||||
## Indicates that multiple `Column_Type_Selector` match the same column.
|
||||
|
||||
If all matching selectors indicate the same type, the warning is reported but
|
||||
a parse is attempted anyway. If mixed types are requested, the column is not
|
||||
parsed due to ambiguity.
|
||||
type Duplicate_Type_Selector
|
||||
Error column:Text ambiguous:Boolean
|
||||
|
||||
to_display_text : Text
|
||||
to_display_text self = "Duplicate type selector for column " + self.column + "."
|
||||
|
||||
## Indicates that the column was already present in the table.
|
||||
type Existing_Column
|
||||
## PRIVATE
|
||||
Error column_name
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self = "The column '" + self.column_name + "' already exists, but `Set_Mode.Add` was selected."
|
||||
|
||||
## Indicates that the column was not present in the table.
|
||||
type Missing_Column
|
||||
## PRIVATE
|
||||
Error column_name
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self = "The column '" + self.column_name + "' was not found, but `Set_Mode.Update` was selected."
|
||||
|
||||
## Indicates that the target range contains existing data and the user did not
|
||||
specify to overwrite.
|
||||
type Existing_Data
|
||||
## PRIVATE
|
||||
Error message
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self = "Existing data found: " + self.message
|
||||
|
||||
## Indicates that the specified range is not large enough to fit the data.
|
||||
type Range_Exceeded
|
||||
## PRIVATE
|
||||
Error message
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self = "Range exceeded: " + self.message
|
||||
|
||||
## Indicates that the existing table has a different number of columns to the
|
||||
new table.
|
||||
type Column_Count_Mismatch
|
||||
## PRIVATE
|
||||
Error expected actual
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"Expected " + self.expected.to_text + " columns, got " + self.actual.to_text + "."
|
||||
@ -305,8 +362,12 @@ type Column_Count_Mismatch
|
||||
## Indicates that the existing table has a different set of column names to the
|
||||
new table.
|
||||
type Column_Name_Mismatch
|
||||
## PRIVATE
|
||||
Error missing extras message
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self = self.message
|
||||
|
||||
@ -324,6 +385,7 @@ type Column_Name_Mismatch
|
||||
Arguments:
|
||||
- column_name: The name of the column that doesn't exist.
|
||||
type No_Such_Column
|
||||
## PRIVATE
|
||||
Error column_name
|
||||
|
||||
## PRIVATE
|
||||
@ -344,6 +406,7 @@ type No_Index_Set_Error
|
||||
to_display_text self = "The table does not have an index set."
|
||||
|
||||
type Invalid_Value_Type
|
||||
## PRIVATE
|
||||
Error expected actual related_column=Nothing
|
||||
|
||||
## PRIVATE
|
||||
@ -363,6 +426,7 @@ type Invalid_Value_Type
|
||||
|
||||
An error representing an invalid JSON format for conversion.
|
||||
type Invalid_JSON_Format
|
||||
## PRIVATE
|
||||
Error input message
|
||||
|
||||
## PRIVATE
|
||||
@ -373,8 +437,7 @@ type Invalid_JSON_Format
|
||||
"The input " + self.input.to_text + " had an invalid format due to: " + self.message.to_text + "."
|
||||
|
||||
type Column_Type_Mismatch
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
An error indicating a mismatch of column types of merged columns.
|
||||
Error (column_name : Text) (expected_type : Text) (got_type : Text)
|
||||
|
||||
@ -386,8 +449,7 @@ type Column_Type_Mismatch
|
||||
"The column ["+self.column_name+"] expects type "+self.expected_type+" but one of the provided tables had type "+self.got_type+" which is not compatible with it."
|
||||
|
||||
type No_Common_Type
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
An error indicating that no common type could be found for the merged
|
||||
columns.
|
||||
Error (column_name : Text)
|
||||
@ -400,60 +462,86 @@ type No_Common_Type
|
||||
"No common type could have been found for the columns corresponding to ["+self.column_name+"]. If you want to allow mixed types, please retype the columns to the `Mixed` before the concatenation (note however that most Database backends do not support `Mixed` types, so it may work only for the in-memory backend)."
|
||||
|
||||
type Unmatched_Columns
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
|
||||
An error indicating that some columns were not present in all of the
|
||||
merged tables.
|
||||
Error (column_names : Vector Text)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"The following columns were not present in some of the provided tables: " + (self.column_names.map (n -> "["+n+"]") . join ", ") + ". The missing values have been filled with `Nothing`."
|
||||
|
||||
type Cross_Join_Row_Limit_Exceeded
|
||||
## Indicates that a `cross_join` has been attempted where the right table
|
||||
## PRIVATE
|
||||
Indicates that a `cross_join` has been attempted where the right table
|
||||
has more rows than allowed by the limit.
|
||||
Error (limit : Integer) (existing_rows : Integer)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"The cross join operation exceeded the maximum number of rows allowed. The limit is "+self.limit.to_text+" and the number of rows in the right table was "+self.existing_rows.to_text+". The limit may be turned off by setting the `right_row_limit` option to `Nothing`."
|
||||
|
||||
type Row_Count_Mismatch
|
||||
## Indicates that the row counts of zipped tables do not match.
|
||||
## PRIVATE
|
||||
Indicates that the row counts of zipped tables do not match.
|
||||
Error (left_rows : Integer) (right_rows : Integer)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"The number of rows in the left table ("+self.left_rows.to_text+") does not match the number of rows in the right table ("+self.right_rows.to_text+")."
|
||||
|
||||
type Invalid_Aggregate_Column
|
||||
## Indicates that a provided name is not found within available columns nor
|
||||
## PRIVATE
|
||||
Indicates that a provided name is not found within available columns nor
|
||||
represents a valid expression.
|
||||
Error (name : Text) (expression_error : Expression_Error | No_Such_Column | Nothing)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"The name ["+self.name+"] is not a valid column name nor expression."
|
||||
|
||||
type Inexact_Type_Coercion
|
||||
## Indicates that the requested `Value_Type` is not available in the given
|
||||
## PRIVATE
|
||||
Indicates that the requested `Value_Type` is not available in the given
|
||||
backend, so it was replaced by its closest available type.
|
||||
Warning (requested_type : Value_Type) (actual_type : Value_Type)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"The requested type ["+self.requested_type.to_text+"] is not available in the given backend, so it was replaced by its closest available type ["+self.actual_type.to_text+"]."
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_text : Text
|
||||
to_text self =
|
||||
"Inexact_Type_Coercion.Warning (requested_type = " + self.requested_type.to_text + ") (actual_type = " + self.actual_type.to_text + ")"
|
||||
|
||||
type Invalid_Value_For_Type
|
||||
## Indicates that a column construction/transformation failed because the
|
||||
## PRIVATE
|
||||
Indicates that a column construction/transformation failed because the
|
||||
provided value is not valid for the requested column type.
|
||||
Error (value : Any) (value_type : Value_Type)
|
||||
|
||||
## PRIVATE
|
||||
|
||||
Create a human-readable version of the error.
|
||||
to_display_text : Text
|
||||
to_display_text self =
|
||||
"The value ["+self.value.to_text+"] is not valid for the column type ["+self.value_type.to_text+"]."
|
||||
|
@ -45,20 +45,26 @@ type Excel_Format
|
||||
`Excel_Section.Workbook`.
|
||||
Excel (section:Excel_Section=Excel_Section.Workbook) (headers:(Boolean|Infer)=Infer) (xls_format:(Boolean|Infer)=Infer) (default_sheet:Text="EnsoSheet")
|
||||
|
||||
## If the File_Format supports reading from the file, return a configured instance.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
If the File_Format supports reading from the file, return a configured instance.
|
||||
for_file : File -> Excel_Format | Nothing
|
||||
for_file file =
|
||||
is_xls = should_treat_as_xls_format Infer file
|
||||
if is_xls.is_error then Nothing else
|
||||
Excel_Format.Excel xls_format=is_xls
|
||||
|
||||
## If the File_Format supports reading from the web response, return a configured instance.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
If the File_Format supports reading from the web response, return a configured instance.
|
||||
for_web : Text -> URI -> Excel_Format | Nothing
|
||||
for_web _ _ =
|
||||
## Currently not loading Excel files automatically as these need to be loaded as a connection.
|
||||
Nothing
|
||||
|
||||
## Implements the `File.read` for this `File_Format`
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Implements the `File.read` for this `File_Format`
|
||||
read : File -> Problem_Behavior -> Any
|
||||
read self file on_problems =
|
||||
format = should_treat_as_xls_format self.xls_format file
|
||||
@ -66,7 +72,9 @@ type Excel_Format
|
||||
Excel_Section.Workbook -> Excel_Workbook.new file format self.headers
|
||||
_ -> Excel_Reader.read_file file self.section self.headers on_problems format
|
||||
|
||||
## Implements the `Table.write` for this `File_Format`.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Implements the `Table.write` for this `File_Format`.
|
||||
|
||||
Depending on the `section` will control where to write.
|
||||
- If `Excel_Section.Workbook` (the default), the `table` will be written
|
||||
|
@ -16,7 +16,8 @@ excel_2007_column_limit = 16384
|
||||
excel_2007_row_limit = 1048576
|
||||
|
||||
type Excel_Range
|
||||
## Specifies a range within an Excel Workbook.
|
||||
## PRIVATE
|
||||
Specifies a range within an Excel Workbook.
|
||||
Value java_range:Java_Range
|
||||
|
||||
## Gets the name of the sheet.
|
||||
@ -55,11 +56,14 @@ type Excel_Range
|
||||
address : Text
|
||||
address self = self.java_range.getAddress
|
||||
|
||||
## Displays the Excel_Range.
|
||||
## PRIVATE
|
||||
Displays the Excel_Range.
|
||||
to_text : Text
|
||||
to_text self = "Excel_Range " + self.address
|
||||
|
||||
## Validates if a column index (1-based) is within the valid range for
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Validates if a column index (1-based) is within the valid range for
|
||||
Excel.
|
||||
|
||||
Arguments:
|
||||
@ -68,7 +72,9 @@ type Excel_Range
|
||||
is_valid_column column =
|
||||
(column > 0) && (column <= excel_2007_column_limit)
|
||||
|
||||
## Validates if a row index (1-based) is within the valid range for Excel.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Validates if a row index (1-based) is within the valid range for Excel.
|
||||
|
||||
Arguments:
|
||||
- row: 1-based index to check.
|
||||
@ -76,7 +82,9 @@ type Excel_Range
|
||||
is_valid_row row =
|
||||
(row > 0) && (row <= excel_2007_row_limit)
|
||||
|
||||
## Given a column name, parses to the index (1-based) or return index
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Given a column name, parses to the index (1-based) or return index
|
||||
unchanged.
|
||||
column_index : (Text|Integer) -> Integer
|
||||
column_index column = case column of
|
||||
|
@ -5,25 +5,32 @@ import project.Internal.Vector_Builder.Vector_Builder
|
||||
|
||||
from project.Errors import Missing_Input_Columns, Column_Indexes_Out_Of_Range, Duplicate_Output_Column_Names, Invalid_Output_Column_Names, Invalid_Aggregate_Column
|
||||
|
||||
## PRIVATE
|
||||
type Problem_Builder
|
||||
## PRIVATE
|
||||
Value types_to_always_throw oob_indices missing_input_columns other
|
||||
|
||||
## PRIVATE
|
||||
report_oob_indices self indices =
|
||||
append_to_ref self.oob_indices indices
|
||||
|
||||
## PRIVATE
|
||||
report_missing_input_columns self columns =
|
||||
append_to_ref self.missing_input_columns columns
|
||||
|
||||
## PRIVATE
|
||||
report_unique_name_strategy self unique_name_strategy =
|
||||
if unique_name_strategy.invalid_names.not_empty then
|
||||
self.report_other_warning (Invalid_Output_Column_Names.Error unique_name_strategy.invalid_names)
|
||||
if unique_name_strategy.renames.not_empty then
|
||||
self.report_other_warning (Duplicate_Output_Column_Names.Error unique_name_strategy.renames)
|
||||
|
||||
## PRIVATE
|
||||
report_other_warning self warning =
|
||||
self.other.append warning
|
||||
|
||||
## Returns a vector containing all reported problems, aggregated.
|
||||
## PRIVATE
|
||||
Returns a vector containing all reported problems, aggregated.
|
||||
build_problemset : Vector
|
||||
build_problemset self =
|
||||
problems = Vector.new_builder
|
||||
@ -38,7 +45,8 @@ type Problem_Builder
|
||||
|
||||
problems.to_vector
|
||||
|
||||
## Attaches gathered warnings to the result.
|
||||
## PRIVATE
|
||||
Attaches gathered warnings to the result.
|
||||
Any errors from the `result` take precedence over the ones owned by this
|
||||
builder.
|
||||
attach_problems_after : Problem_Behavior -> Any -> Any
|
||||
@ -48,7 +56,8 @@ type Problem_Builder
|
||||
problems ->
|
||||
problem_behavior.attach_problems_after result problems
|
||||
|
||||
## Attaches gathered warnings to the result of the provided computation.
|
||||
## PRIVATE
|
||||
Attaches gathered warnings to the result of the provided computation.
|
||||
If in `Report_Error` mode and there are any problems gathered, the first
|
||||
one will be returned as error without even running the computation.
|
||||
attach_problems_before : Problem_Behavior -> Any -> Any
|
||||
|
@ -3,6 +3,7 @@ from Standard.Base import all
|
||||
from project.Data.Table import Table
|
||||
from project.Data.Row import Row
|
||||
|
||||
## PRIVATE
|
||||
type Rows_View
|
||||
## PRIVATE
|
||||
Value (table:Table)
|
||||
|
@ -10,7 +10,9 @@ type Unique_Name_Strategy
|
||||
- deduplicator: Name deduplicator
|
||||
Value deduplicator
|
||||
|
||||
## Creates a new Unique_Name_Strategy instance.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Creates a new Unique_Name_Strategy instance.
|
||||
|
||||
This is a mutable data structure, that allows for creating a collection
|
||||
of columns names and making them unique. It will track any duplicates or
|
||||
@ -26,7 +28,9 @@ type Unique_Name_Strategy
|
||||
new : Unique_Name_Strategy
|
||||
new = Unique_Name_Strategy.Value NameDeduplicator.new
|
||||
|
||||
## Changes names from the second list so that they do not clash with names
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Changes names from the second list so that they do not clash with names
|
||||
from the first list and with each other.
|
||||
|
||||
It returns a new list where each new name corresponds to a name from the
|
||||
@ -61,7 +65,9 @@ type Unique_Name_Strategy
|
||||
Vector.from_polyglot_array <|
|
||||
self.deduplicator.combineWithPrefix first second second_prefix
|
||||
|
||||
## Vector of any duplicates renamed.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Vector of any duplicates renamed.
|
||||
|
||||
Note that this vector will not contain renames where just the
|
||||
second_prefix was added.
|
||||
@ -69,12 +75,15 @@ type Unique_Name_Strategy
|
||||
renames self = Vector.from_polyglot_array self.deduplicator.getDuplicatedNames
|
||||
|
||||
|
||||
## Vector of any invalid names.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Vector of any invalid names.
|
||||
invalid_names : Vector
|
||||
invalid_names self = Vector.from_polyglot_array self.deduplicator.getInvalidNames
|
||||
|
||||
|
||||
## Takes a value and converts to a valid (but not necessarily unique) name.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Takes a value and converts to a valid (but not necessarily unique) name.
|
||||
|
||||
Arguments:
|
||||
- name: The column name to make valid.
|
||||
@ -91,8 +100,9 @@ type Unique_Name_Strategy
|
||||
Nothing -> self.make_valid_name ""
|
||||
_ -> self.make_valid_name input.to_text
|
||||
|
||||
|
||||
## Takes a name and gets a unique version.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Takes a name and gets a unique version.
|
||||
|
||||
Arguments:
|
||||
- name: The column name to make unique.
|
||||
@ -104,21 +114,27 @@ type Unique_Name_Strategy
|
||||
make_unique : Text -> Text
|
||||
make_unique self name = self.deduplicator.makeUnique name
|
||||
|
||||
## Tells if the given name has not yet been encountered.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Tells if the given name has not yet been encountered.
|
||||
|
||||
It does not use up the name - it needs to be marked with `mark_used` if
|
||||
needed.
|
||||
is_unique : Text -> Boolean
|
||||
is_unique self name = self.deduplicator.isUnique name
|
||||
|
||||
## Takes a list of names and gets a list of unique versions.
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Takes a list of names and gets a list of unique versions.
|
||||
|
||||
Arguments:
|
||||
- names: The column names to make unique.
|
||||
make_all_unique : Vector Text -> Vector Text
|
||||
make_all_unique self names = names.map self.make_unique
|
||||
|
||||
## Takes a list of names and marks them as used, so that any further names
|
||||
## PRIVATE
|
||||
ADVANCED
|
||||
Takes a list of names and marks them as used, so that any further names
|
||||
clashing with those will have a prefix added.
|
||||
mark_used : Vector Text -> Nothing
|
||||
mark_used self names = names.each (self.deduplicator.markUsed _)
|
||||
|
@ -9,16 +9,12 @@ import project.Id.Id
|
||||
from project.Text import get_lazy_visualisation_text_window
|
||||
import project.Table as Table_Visualisation
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
Specifies that the builtin JSON visualization should be used for any type,
|
||||
unless specified otherwise.
|
||||
Any.default_visualization self = Id.json
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
Returns a Text used to display this value in the IDE.
|
||||
|
||||
The particular representation is left unspecified and subject to change in
|
||||
@ -71,8 +67,7 @@ Any.map_valid self f = f self
|
||||
Any.catch_ : Any -> Any
|
||||
Any.catch_ self ~val = self.catch Any (_-> val)
|
||||
|
||||
## UNSTABLE
|
||||
|
||||
## PRIVATE
|
||||
Returns a display representation of the dataflow error on which it is called.
|
||||
|
||||
> Example
|
||||
@ -127,15 +122,14 @@ recover_errors ~body =
|
||||
result.catch Any err->
|
||||
JS_Object.from_pairs [["error", err.to_display_text]] . to_text
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## PRIVATE
|
||||
|
||||
Guides the visualization system to display the most suitable graphical
|
||||
representation for this table.
|
||||
Vector.default_visualization : Id
|
||||
Vector.default_visualization self = Id.table
|
||||
|
||||
## UNSTABLE
|
||||
## PRIVATE
|
||||
|
||||
Transform the vector into text for displaying as part of its default
|
||||
visualization.
|
||||
@ -155,16 +149,14 @@ render_vector object depth=0 max_depth=5 max_length=100 =
|
||||
_ : JS_Object -> render object depth max_depth max_length
|
||||
_ -> object.to_default_visualization_data
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## PRIVATE
|
||||
|
||||
Guides the visualization system to display the most suitable graphical
|
||||
representation for this table.
|
||||
Array.default_visualization : Id
|
||||
Array.default_visualization self = Id.table
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## PRIVATE
|
||||
|
||||
Returns a Text used to display this value in the IDE.
|
||||
|
||||
@ -193,8 +185,7 @@ Table.lookup_ignore_case self name =
|
||||
self.columns.find if_missing=(Error.throw Nothing) <| col->
|
||||
col.name.equals_ignore_case name
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## PRIVATE
|
||||
|
||||
Guides the visualization system to display the most suitable graphical
|
||||
representation for this table.
|
||||
@ -205,8 +196,7 @@ Table.default_visualization self =
|
||||
if cols.contains "x" && cols.contains "y" then Id.scatter_plot else
|
||||
Id.table
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## PRIVATE
|
||||
|
||||
Returns a Text used to display this table in the IDE by default.
|
||||
|
||||
@ -222,8 +212,7 @@ Table.to_default_visualization_data self =
|
||||
JS_Object.from_pairs [['name', name], ['data', items]]
|
||||
JS_Object.from_pairs [row_count, ['columns', cols]] . to_text
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## PRIVATE
|
||||
|
||||
Guides the visualization system to display the most suitable graphical
|
||||
representation for this Column.
|
||||
@ -246,8 +235,7 @@ make_lazy_visualisation_data text text_window_position text_window_size chunk_si
|
||||
if text.length < min_length_for_laziness then text else
|
||||
get_lazy_visualisation_text_window text text_window_position text_window_size chunk_size
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## PRIVATE
|
||||
Returns the data requested to render a lazy view of the default visualisation.
|
||||
Any.to_lazy_visualization_data : Vector Integer -> Vector Integer -> Integer -> Text
|
||||
Any.to_lazy_visualization_data self text_window_position text_window_size chunk_size =
|
||||
@ -255,15 +243,13 @@ Any.to_lazy_visualization_data self text_window_position text_window_size chunk_
|
||||
https://www.pivotaltracker.com/story/show/184061302
|
||||
"" + make_lazy_visualisation_data self.to_default_visualization_data text_window_position text_window_size chunk_size
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## PRIVATE
|
||||
Returns the data requested to render a lazy view of the default visualisation.
|
||||
Text.to_default_visualization_data : Text
|
||||
Text.to_default_visualization_data self =
|
||||
self.to_lazy_visualization_data [0,0] [10,10] 20
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## PRIVATE
|
||||
Returns the data requested to render a lazy view of the default visualisation.
|
||||
Text.to_lazy_visualization_data : Vector Integer -> Vector Integer -> Integer -> Text
|
||||
Text.to_lazy_visualization_data self text_window_position text_window_size chunk_size =
|
||||
@ -273,9 +259,7 @@ Text.to_lazy_visualization_data self text_window_position text_window_size chunk
|
||||
https://www.pivotaltracker.com/story/show/184061302
|
||||
"" + get_lazy_visualisation_text_window self text_window_position text_window_size chunk_size
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
Shows a JSON serialization of a truncated version of this column, for the
|
||||
benefit of visualization in the IDE.
|
||||
Column.to_default_visualization_data : Text
|
||||
@ -286,17 +270,13 @@ Column.to_default_visualization_data self =
|
||||
data = ['data', self.to_vector.take (First max_data)]
|
||||
JS_Object.from_pairs [size, name, data] . to_text
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
Guides the visualization system to display the most suitable graphical
|
||||
representation for this Row.
|
||||
Row.default_visualization : Id
|
||||
Row.default_visualization self = Id.table
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
|
||||
## PRIVATE
|
||||
Returns a Text used to display this table in the IDE by default.
|
||||
|
||||
Returns a JSON object containing useful metadata and previews of column
|
||||
@ -305,8 +285,7 @@ Row.to_default_visualization_data : Text
|
||||
Row.to_default_visualization_data self =
|
||||
self.to_vector.to_default_visualization_data
|
||||
|
||||
## UNSTABLE
|
||||
ADVANCED
|
||||
## PRIVATE
|
||||
Returns the data requested to render a lazy view of the default visualisation.
|
||||
Table.to_lazy_visualization_data : Vector Integer -> Vector Integer -> Vector Integer -> Integer -> Text
|
||||
Table.to_lazy_visualization_data self table_cell_position text_window_position text_window_size chunk_size =
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user