From 56688ec1e7af144e2533d74f4b23f9208d858b59 Mon Sep 17 00:00:00 2001 From: James Dunkerley Date: Tue, 27 Jun 2023 19:18:15 +0100 Subject: [PATCH] Minor fixes. (#7122) Mostly stuff to tidy up the static methods in the CB. - Remove default pattern from `parse_to_table` (caused IDE to freeze). - Rename any `_` arguments to what they are. - Merge `Date.now` into `Date.today` - Merge the Interval constructors into a single constructor. - Hide various methods. --- .../lib/Standard/Base/0.0.0-dev/src/Any.enso | 9 ++- .../Base/0.0.0-dev/src/Data/Array.enso | 8 ++- .../0.0.0-dev/src/Data/Index_Sub_Range.enso | 8 +-- .../Base/0.0.0-dev/src/Data/Interval.enso | 69 +++++++++++-------- .../Base/0.0.0-dev/src/Data/Json.enso | 7 +- .../Standard/Base/0.0.0-dev/src/Data/Map.enso | 10 ++- .../Base/0.0.0-dev/src/Data/Noise.enso | 7 +- .../Base/0.0.0-dev/src/Data/Ordering.enso | 8 ++- .../src/Data/Ordering/Natural_Order.enso | 4 +- .../Ordering/Vector_Lexicographic_Order.enso | 4 +- .../Base/0.0.0-dev/src/Data/Range.enso | 4 +- .../Standard/Base/0.0.0-dev/src/Data/Set.enso | 8 ++- .../Base/0.0.0-dev/src/Data/Statistics.enso | 31 +++++++-- .../src/Data/Text/Regex/Pattern.enso | 2 +- .../Base/0.0.0-dev/src/Data/Time/Date.enso | 27 +++----- .../0.0.0-dev/src/Data/Time/Date_Range.enso | 2 +- .../Base/0.0.0-dev/src/Data/Vector.enso | 16 +++-- .../Standard/Base/0.0.0-dev/src/Error.enso | 4 +- .../Standard/Base/0.0.0-dev/src/Function.enso | 7 +- .../lib/Standard/Base/0.0.0-dev/src/Main.enso | 2 + .../lib/Standard/Base/0.0.0-dev/src/Math.enso | 6 +- .../Base/0.0.0-dev/src/Meta/Enso_Project.enso | 4 +- .../Base/0.0.0-dev/src/Network/HTTP.enso | 9 +-- .../Base/0.0.0-dev/src/Network/HTTP/Form.enso | 12 +++- .../Base/0.0.0-dev/src/Network/Proxy.enso | 22 +++--- .../Standard/Base/0.0.0-dev/src/Panic.enso | 9 ++- .../Standard/Base/0.0.0-dev/src/Random.enso | 6 +- .../0.0.0-dev/src/System/File_Format.enso | 24 +++++-- .../Base/0.0.0-dev/src/System/Platform.enso | 4 +- .../Standard/Base/0.0.0-dev/src/Warning.enso | 19 +++-- .../src/Connection/SQLite_Format.enso | 3 +- .../src/Internal/SQL_Type_Mapping.enso | 3 +- .../src/Internal/SQLite/SQLite_Dialect.enso | 3 +- .../Internal/SQLite/SQLite_Type_Mapping.enso | 3 +- .../0.0.0-dev/src/Image_File_Format.enso | 3 +- .../0.0.0-dev/src/Data_Science/Numbers.enso | 4 +- .../Table/0.0.0-dev/src/Data/Column.enso | 6 +- .../Table/0.0.0-dev/src/Data/Table.enso | 10 +-- .../0.0.0-dev/src/Data/Table_Conversions.enso | 2 +- .../src/Data/Type/Value_Type_Helpers.enso | 6 +- .../src/Delimited/Delimited_Format.enso | 3 +- .../0.0.0-dev/src/Excel/Excel_Format.enso | 3 +- .../0.0.0-dev/src/Excel/Excel_Workbook.enso | 4 +- .../0.0.0-dev/src/Internal/Excel_Writer.enso | 3 +- .../src/Internal/Multi_Value_Key.enso | 4 +- .../Test/0.0.0-dev/src/Extensions.enso | 24 +++++-- .../Visualization/0.0.0-dev/src/AI.enso | 1 + .../Visualization/0.0.0-dev/src/Helpers.enso | 3 +- .../Visualization/0.0.0-dev/src/Table.enso | 6 +- .../0.0.0-dev/src/Table/Visualization.enso | 3 +- .../Visualization/0.0.0-dev/src/Text.enso | 10 +-- .../interpreter/runtime/data/EnsoDate.java | 2 +- .../interpreter/test/ValuesGenerator.java | 2 +- .../Test_Serializer_FQN/src/Main.enso | 2 +- .../Types/SQLite_Type_Mapping_Spec.enso | 2 +- test/Tests/src/Data/Interval_Spec.enso | 59 ++++++++-------- test/Tests/src/Data/Noise/Generator_Spec.enso | 5 +- test/Tests/src/Data/Noise_Spec.enso | 2 +- test/Tests/src/Data/Polyglot_Spec.enso | 2 +- test/Tests/src/Semantic/Meta_Spec.enso | 6 +- 60 files changed, 329 insertions(+), 212 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso index 65c9f1e2c2..1b8801a5c5 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso @@ -1,5 +1,4 @@ import project.Data.Pair.Pair -from project.Data.Range.Extensions import all import project.Data.Text.Text import project.Data.Vector.Vector import project.Error.Error @@ -13,6 +12,8 @@ import project.Warning.Warning from project.Data.Boolean import Boolean, True, False from project.Data.Ordering import all +from project.Data.Range.Extensions import all +from project.Function import const ## Any is the universal top-type, with all other types being subsumed by it. @@ -264,7 +265,8 @@ type Any "Hello".if_nothing "" if_nothing : Any -> Any - if_nothing self ~_ = self + if_nothing self ~other = + const self other ## Executes the provided handler on an error, or returns the value unchanged. @@ -317,7 +319,8 @@ type Any error = my_map.at "x" error.map_error (_ -> Example_Error_Type "x is missing") map_error : (Error -> Error) -> Any - map_error self _ = self + map_error self ~f = + const self f ## Checks if `self` is an error. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso index 6135fe2b7a..89d3f20327 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso @@ -25,7 +25,9 @@ from project.Data.Index_Sub_Range import Index_Sub_Range ## The type of primitive mutable arrays. @Builtin_Type type Array - ## Creates an array with length 0. + ## PRIVATE + ADVANCED + Creates an array with length 0. > Example Create an empty array. @@ -34,7 +36,9 @@ type Array empty : Array empty = @Builtin_Method "Array.empty" - ## Creates a new array of length size, with all elements uninitialized. + ## PRIVATE + ADVANCED + Creates a new array of length size, with all elements uninitialized. Arguments: - size: The size of the array to create. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Index_Sub_Range.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Index_Sub_Range.enso index 6e203996b6..1aa78dc3ef 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Index_Sub_Range.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Index_Sub_Range.enso @@ -1,7 +1,6 @@ import project.Any.Any import project.Data.Numbers.Integer import project.Data.Range.Range -from project.Data.Range.Extensions import all import project.Data.Text.Text import project.Data.Vector.Vector import project.Errors.Common.Index_Out_Of_Bounds @@ -16,6 +15,7 @@ import project.Random import project.Runtime.Ref.Ref from project.Data.Boolean import Boolean, True, False +from project.Data.Range.Extensions import all import project.Metadata.Widget from project.Metadata.Widget import Single_Choice @@ -111,7 +111,7 @@ resolve_ranges ranges length = if step <= 0 then Panic.throw (Illegal_Argument.Error "Range step must be positive.") else if (start < 0) || (end < 0) then Panic.throw (Illegal_Argument.Error "Range start and end must not be negative.") else if start >= length then Panic.throw (Index_Out_Of_Bounds.Error start length) else - actual_end = Math.min end length + actual_end = end.min length if actual_end < start then start.up_to start . with_step step else start.up_to actual_end . with_step step ranges.map trim @@ -164,7 +164,7 @@ sort_and_merge_ranges ranges = sorted.drop 1 . each range-> current = current_ref.get case range.start <= current.end of - True -> current_ref.put (current.start.up_to (Math.max current.end range.end)) + True -> current_ref.put (current.start.up_to (current.end.max range.end)) False -> builder.append current current_ref.put range @@ -200,7 +200,7 @@ take_helper : Integer -> (Integer -> Any) -> (Integer -> Integer -> Any) -> (Vec take_helper length at single_slice slice_ranges range = case range of count : Integer -> take_helper length at single_slice slice_ranges (Index_Sub_Range.First count) _ : Range -> take_helper length at single_slice slice_ranges (Index_Sub_Range.By_Index range) - Index_Sub_Range.First count -> single_slice 0 (Math.min length count) + Index_Sub_Range.First count -> single_slice 0 (length.min count) Index_Sub_Range.Last count -> single_slice length-count length Index_Sub_Range.While predicate -> end = 0.up_to length . find i-> (predicate (at i)).not diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Interval.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Interval.enso index 7416a4224a..e60a707643 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Interval.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Interval.enso @@ -34,51 +34,62 @@ type Bound example_bound_exclusive = Bound.Exclusive 2. Exclusive n +type Interval_Type + ## Both the start and end bounds are included. + Inclusive + + ## The start bound is included, but the end bound is excluded. + Start_Exclusive + + ## The start bound is excluded, but the end bound is included. + End_Exclusive + + ## Both the start and end bounds are excluded. + Exclusive + ## A type representing an interval over real numbers. type Interval - ## Creates an interval that excludes both its bounds. + ## Creates an interval. + + Arguments: + - start: The start of the interval. (Included by default) + - end: The end of the interval. (Excluded by default) + - interval_type: The type of interval to create. (End_Exclusive by default) > Example Create the bounds-exclusive range from 0.1 to 0.5. - import Standard.Base.Data.Interval - - example_exclusive = Interval.exclusive 0.1 0.5 - exclusive : Number -> Number -> Interval - exclusive start end = Interval.Between (Bound.Exclusive start) (Bound.Exclusive end) - - ## Creates an interval that excludes its lower bound. + import Standard.Base.Data.Interval.Interval + import Standard.Base.Data.Interval.Interval_Type + example_exclusive = Interval.new 0.1 0.5 Interval_Type.Exclusive > Example Create the start-exclusive range from 1 to 5. - import Standard.Base.Data.Interval - - example_start_exclusive = Interval.start_exclusive 1 5 - start_exclusive : Number -> Number -> Interval - start_exclusive start end = Interval.Between (Bound.Exclusive start) (Bound.Inclusive end) - - ## Creates an interval that excludes its upper bound. + import Standard.Base.Data.Interval.Interval + import Standard.Base.Data.Interval.Interval_Type + example_start_exclusive = Interval.new 1 5 Interval_Type.Start_Exclusive > Example Create the end-exclusive range from 1 to 5. - import Standard.Base.Data.Interval - - example_end_exclusive = Interval.end_exclusive 1 5 - end_exclusive : Number -> Number -> Interval - end_exclusive start end = Interval.Between (Bound.Inclusive start) (Bound.Exclusive end) - - ## Creates an interval that includes both of its bounds. + import Standard.Base.Data.Interval.Interval + import Standard.Base.Data.Interval.Interval_Type + example_end_exclusive = Interval.new 1 5 Interval_Type.End_Exclusive > Example Create the inclusive range from 0 to 0. - import Standard.Base.Data.Interval + import Standard.Base.Data.Interval.Interval + import Standard.Base.Data.Interval.Interval_Type - example_inclusive = Interval.inclusive 0 0 - inclusive : Number -> Number -> Interval - inclusive start end = Interval.Between (Bound.Inclusive start) (Bound.Inclusive end) + example_inclusive = Interval.new 0 0 Interval_Type.Inclusive + new : Number -> Number -> Interval_Type -> Interval + new start end interval_type=Interval_Type.End_Exclusive = case interval_type of + Interval_Type.Inclusive -> Interval.Between (Bound.Inclusive start) (Bound.Inclusive end) + Interval_Type.Start_Exclusive -> Interval.Between (Bound.Exclusive start) (Bound.Inclusive end) + Interval_Type.End_Exclusive -> Interval.Between (Bound.Inclusive start) (Bound.Exclusive end) + Interval_Type.Exclusive -> Interval.Between (Bound.Exclusive start) (Bound.Exclusive end) ## PRIVATE @@ -99,7 +110,7 @@ type Interval import Standard.Base.Data.Interval - example_contains = (Interval.inclusive 0.1 1) . contains 0.33 + example_contains = (Interval.new 0.1 1 include_end=True) . contains 0.33 contains : Number -> Boolean contains self that = if self.start.n > self.end.n then False else case self.start of @@ -117,7 +128,7 @@ type Interval import Standard.Base.Data.Interval - example_is_empty = Interval.inclusive 0 0 . is_empty + example_is_empty = Interval.new 0 0 include_start=False . is_empty is_empty : Boolean is_empty self = case self.start of Bound.Exclusive s -> case self.end of @@ -134,7 +145,7 @@ type Interval import Standard.Base.Data.Interval - example_not_empty = Interval.inclusive 0 0.001 . not_empty + example_not_empty = Interval.new 0 0.001 . not_empty not_empty : Boolean not_empty self = self.is_empty.not diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso index b76d8cde44..2ce207b492 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso @@ -48,12 +48,15 @@ type Json parsed = json_parse json make_enso parsed - ## Serialize an Object to JSON + ## PRIVATE + ADVANCED + Serialize an Object to JSON. stringify : (JS_Object | Boolean | Number | Nothing | Text | Vector) -> Text stringify object = json_stringify (make_javascript object.to_js_object) - ## Convert a Vector of Keys and Values to JSON. + ## PRIVATE + Convert a Vector of Keys and Values to JSON. Keys must be `Text` values. from_pairs : Vector -> Text from_pairs pairs = diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Map.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Map.enso index f735965121..0ba2defa39 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Map.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Map.enso @@ -32,11 +32,15 @@ from project.Data.Boolean import Boolean, True, False treated as a Map. @Builtin_Type type Map key value - ## Returns an empty map. + ## PRIVATE + ADVANCED + Returns an empty map. empty : Map empty = @Builtin_Method "Map.empty" - ## Returns a single-element map with the given key and value. + ## PRIVATE + ADVANCED + Returns a single-element map with the given key and value. A Call to `Map.singleton key value` is the same as a call to `Map.empty.insert key value`. @@ -284,7 +288,7 @@ type Map key value import Standard.Base.Data.Map.Map import Standard.Examples - example_fold = Examples.map.fold 0 (l -> r -> Math.max l r.length) + example_fold = Examples.map.fold 0 (l -> r -> l.max r.length) fold : Any -> (Any -> Any -> Any) -> Any fold self init function = self.values.fold init function diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Noise.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Noise.enso index ea76fd74ef..c8c591e613 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Noise.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Noise.enso @@ -1,8 +1,7 @@ import project.Any.Any -import project.Data.Interval.Bound import project.Data.Interval.Interval +import project.Data.Interval.Interval_Type import project.Data.Numbers.Number -import project.Errors.Unimplemented.Unimplemented polyglot java import java.lang.Long polyglot java import java.util.Random @@ -24,7 +23,7 @@ type Deterministic_Random from Standard.Base.Data.Noise.Generator import Deterministic_Random - example_det_random = Deterministic_Random.step 1 (Interval.inclusive 0 1) + example_det_random = Deterministic_Random.step 1 (Interval.new 0 1 Interval_Type.Inclusive) step : Number -> Interval -> Number step self input interval = max_long = Long.MAX_VALUE @@ -53,5 +52,5 @@ type Deterministic_Random Deterministically perturb the input number 1. 1.noise Number.noise : Interval -> Deterministic_Random -> Any -Number.noise self (interval = Interval.exclusive 0 1) gen=Deterministic_Random = +Number.noise self (interval = Interval.new 0 1 Interval_Type.Exclusive) gen=Deterministic_Random = gen.step self interval diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso index ad624850b1..81b72f949e 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso @@ -161,7 +161,9 @@ type Ordering ## A representation that the first value orders as greater than the second. Greater - ## Compares to values and returns an Ordering + ## PRIVATE + ADVANCED + Compares values and returns an Ordering. compare : Any -> Any -> Ordering ! Incomparable_Values compare x y = if x < y then Ordering.Less else @@ -190,7 +192,9 @@ type Ordering Ordering.Equal -> other Ordering.Greater -> Ordering.Greater - ## Converts a sign-based representation of ordering to Enso's native ordering. + ## PRIVATE + ADVANCED + Converts a sign-based representation of ordering to Enso's native ordering. Arguments: - sign: The number representing the relative ordering of two entities. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso index cb116aefce..0fdddeac2d 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Natural_Order.enso @@ -9,7 +9,9 @@ from project.Data.Boolean import True, False polyglot java import org.enso.base.Text_Utils polyglot java import com.ibm.icu.text.BreakIterator -## Compares two text values according to the natural dictionary ordering. +## PRIVATE + ADVANCED + Compares two text values according to the natural dictionary ordering. > Example Compare two texts according to the natural dictionary ordering. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Vector_Lexicographic_Order.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Vector_Lexicographic_Order.enso index e6f0ab63b2..900e63d11d 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Vector_Lexicographic_Order.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering/Vector_Lexicographic_Order.enso @@ -4,7 +4,9 @@ import project.Data.Vector.Vector from project.Data.Boolean import True, False -## Compares two Vectors according to the lexicographic ordering. +## PRIVATE + ADVANCED + Compares two Vectors according to the lexicographic ordering. Arguments: - vector1: The first vector to compare. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Range.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Range.enso index 0d04341f77..d80de6f9b4 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Range.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Range.enso @@ -14,7 +14,9 @@ from project.Data.Boolean import Boolean, True, False ## Represents a right-exclusive range of integer values. type Range - ## Create a representation of a right-exclusive range of integer values. + ## PRIVATE + ADVANCED + Create a representation of a right-exclusive range of integer values. Arguments: - start: The left boundary of the range. Its value is included. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Set.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Set.enso index 4e33e119e3..adf4d3fac8 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Set.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Set.enso @@ -18,7 +18,9 @@ type Set ## PRIVATE Value (underlying_map : Map Any Nothing) - ## Constructs a new set from a vector. + ## PRIVATE + ADVANCED + Constructs a new set from a vector. Arguments: - vector: the vector of elements to add to the set. @@ -34,7 +36,9 @@ type Set map = Map.from_vector pairs error_on_duplicates=error_on_duplicates Set.Value map - ## Constructs an empty set. + ## PRIVATE + ADVANCED + Constructs an empty set. empty : Set empty = Set.Value Map.empty diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Statistics.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Statistics.enso index f9f721db11..66b3a730e7 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Statistics.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Statistics.enso @@ -139,7 +139,8 @@ type Statistic Statistic.Kurtosis -> 4 _ -> Nothing - ## Compute a single statistic on a vector like object. + ## PRIVATE + Compute a single statistic on a vector like object. Arguments: - data: Vector like object which has a `to_array` method. @@ -148,7 +149,8 @@ type Statistic compute data statistic=Statistic.Count = Statistic.compute_bulk data [statistic] . first - ## Compute a set of statistics on a vector like object. + ## PRIVATE + Compute a set of statistics on a vector like object. Arguments: - data: Vector like object which has a `to_array` method. @@ -180,7 +182,8 @@ type Statistic Statistic.R_Squared series -> calculate_correlation_statistics data series . rSquared _ -> moments.compute (to_moment_statistic statistic) - ## Compute a running statistics on a vector like object. + ## PRIVATE + Compute a running statistics on a vector like object. Arguments: - data: Vector like object which has a `to_array` method. @@ -189,7 +192,8 @@ type Statistic running data statistic=Statistic.Sum = Statistic.running_bulk data [statistic] . map .first - ## Compute a set running statistics on a vector like object. + ## PRIVATE + Compute a set running statistics on a vector like object. Arguments: - data: Vector like object which has a `to_array` method. @@ -264,7 +268,8 @@ type Statistic output.to_vector - ## Assigns a rank to each value of data, dealing with equal values according to the method. + ## PRIVATE + Assigns a rank to each value of data, dealing with equal values according to the method. Arguments: - data: Input data to rank. @@ -337,6 +342,22 @@ Vector.running : Statistic -> Vector Any Vector.running self statistic=Statistic.Count = Statistic.running self statistic +## Compute a set running statistics on the vector. + + Arguments: + - statistics: Set of statistics to calculate. +Vector.running_bulk : Vector Statistic -> Vector Any +Vector.running_bulk self statistics=[Statistic.Count, Statistic.Sum] = + Statistic.running_bulk self statistics + +## Assigns a rank to each value of data, dealing with equal values according to the method. + + Arguments: + - method: Method used to deal with equal values. +Vector.rank_data : Rank_Method -> Vector +Vector.rank_data self method=Rank_Method.Average = + Statistic.rank_data self method + ## PRIVATE compute_fold counter current value = if is_valid value . not then current else diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Regex/Pattern.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Regex/Pattern.enso index f50f0884e7..b6630e24fa 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Regex/Pattern.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Regex/Pattern.enso @@ -366,7 +366,7 @@ type Match_Iterator filler_span = (Utf_16_Span.Value filler_range self.input) match = Match.Value self.pattern regex_result self.input ## Handle edge case where match is 0 length - next_cursor = Math.max (self.cursor + 1) (match.utf_16_end 0) + next_cursor = (self.cursor + 1).max (match.utf_16_end 0) next_iterator = Match_Iterator.Value self.pattern self.input next_cursor Match_Iterator_Value.Next filler_span match next_iterator diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso index cbc09eaca5..d178a852a5 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso @@ -5,7 +5,6 @@ import project.Data.Numbers.Integer import project.Data.Ordering.Ordering import project.Data.Ordering.Comparable import project.Data.Text.Text -from project.Data.Text.Extensions import all import project.Data.Time.Date_Period.Date_Period import project.Data.Time.Date_Range.Date_Range import project.Data.Time.Date_Time.Date_Time @@ -26,6 +25,7 @@ import project.Nothing.Nothing import project.Panic.Panic from project.Data.Boolean import Boolean, True, False +from project.Data.Text.Extensions import all from project.Data.Time.Date_Time import ensure_in_epoch from project.Widget_Helpers import make_date_format_selector @@ -61,16 +61,7 @@ new_builtin year month day = @Builtin_Method "Date.new_builtin" offset or timezone. @Builtin_Type type Date - ## Obtains the current date from the system clock in the system timezone. - - > Example - Get the current date. - - example_now = Date.now - now : Date - now = @Builtin_Method "Date.now" - - ## ALIAS Current Date + ## ALIAS Current Date, now Obtains the current date from the system clock in the system timezone. @@ -79,7 +70,7 @@ type Date example_today = Date.today today : Date - today = Date.now + today = @Builtin_Method "Date.today" ## Constructs a new Date from a year, month, and day. @@ -192,7 +183,7 @@ type Date from Standard.Base import Date - example_year = Date.now.year + example_year = Date.today.year year : Integer year self = @Builtin_Method "Date.year" @@ -201,7 +192,7 @@ type Date > Example Get the current month. - example_month = Date.now.month + example_month = Date.today.month month : Integer month self = @Builtin_Method "Date.month" @@ -212,7 +203,7 @@ type Date from Standard.Base import Date - example_day = Date.now.day + example_day = Date.today.day day : Integer day self = @Builtin_Method "Date.day" @@ -641,7 +632,7 @@ type Date > Example Convert the current date to a JS_Object. - example_to_json = Date.now.to_js_object + example_to_json = Date.today.to_js_object to_js_object : JS_Object to_js_object self = type_pair = ["type", "Date"] @@ -722,9 +713,9 @@ week_days_between start end = _ -> days_between False -> # We count the days in the first week up until Friday - the weekend is not counted. - first_week_days = Math.max 0 (Time_Utils.days_between start (start_of_first_full_week - (Period.new days=2))) + first_week_days = (Time_Utils.days_between start (start_of_first_full_week - (Period.new days=2))).max 0 # We count the days in the last week, not including the weekend. - last_week_days = Math.min (Time_Utils.days_between start_of_last_week end) 5 + last_week_days = (Time_Utils.days_between start_of_last_week end).min 5 full_weeks_between * 5 + first_week_days + last_week_days ## PRIVATE diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Range.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Range.enso index ec8ccf2d33..45f7d52e57 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Range.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Range.enso @@ -38,7 +38,7 @@ type Date_Range decreasing range, flip the start and the end or use `down_to`, but keeping the positive step. new : Date -> Date -> Date_Period|Period -> Date_Range - new start=Date.now end=Date.now step=Date_Period.Day = + new start=Date.today end=Date.today step=Date_Period.Day = increasing = start <= end Date_Range.new_internal start end increasing step diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso index 36d7209ab5..7050359a13 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Vector.enso @@ -6,7 +6,6 @@ import project.Data.Map.Map import project.Data.Numbers.Integer import project.Data.Pair.Pair import project.Data.Range.Range -from project.Data.Range.Extensions import all import project.Data.Text.Text import project.Data.Sort_Direction.Sort_Direction import project.Errors.Common.Incomparable_Values @@ -25,7 +24,7 @@ import project.Panic.Panic import project.Random import project.Warning.Warning -import project.IO +from project.Data.Range.Extensions import all ## We have to import also conversion methods, therefore, we import all from the Ordering module @@ -51,7 +50,9 @@ polyglot java import org.enso.base.Array_Builder @Builtin_Type type Vector a - ## Creates a new vector of the given length, initializing elements using + ## PRIVATE + ADVANCED + Creates a new vector of the given length, initializing elements using the provided constructor function. Arguments: @@ -98,7 +99,8 @@ type Vector a arr : Array -> Vector.from_polyglot_array arr single_element -> [single_element] - ## Creates a new vector of the given length, filling the elements with + ## ALIAS repeat + Creates a new vector of the given length, filling the elements with the provided constant. Arguments: @@ -116,7 +118,9 @@ type Vector a fill length item = Vector.new length _->item - ## Creates a new vector builder instance. + ## PRIVATE + ADVANCED + Creates a new vector builder instance. A vector builder is a mutable data structure, that allows for gathering a number of elements and then converting them into a vector. This is @@ -807,7 +811,7 @@ type Vector a [1, 2, 3].zip [4, 5, 6] == [[1, 4], [2, 5], [3, 6]] zip : Vector Any -> (Any -> Any -> Any) -> Vector Any zip self that function=[_,_] = - len = Math.min self.length that.length + len = self.length.min that.length Vector.new len i-> function (self.at i) (that.at i) ## Extend `self` vector to the length of `n` appending elements `elem` to diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Error.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Error.enso index 092fe32fd0..f6d817b974 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Error.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Error.enso @@ -6,6 +6,7 @@ import project.Panic.Panic import project.Runtime.Stack_Trace_Element from project.Data.Boolean import Boolean, True, False +from project.Function import const ## A type representing dataflow errors. @@ -156,4 +157,5 @@ type Error file.write "foo" . if_not_error file if_not_error : Any -> Any - if_not_error self ~_ = self + if_not_error self ~other = + const self other diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Function.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Function.enso index ed84fff3dd..a1e8757340 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Function.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Function.enso @@ -1,5 +1,6 @@ import project.Any.Any import project.Data.Vector.Vector +import project.Nothing.Nothing ## A function is any type that represents a not-yet evaluated computation. @@ -78,7 +79,6 @@ identity x = x flip : (Any -> Any -> Any) -> (Any -> Any -> Any) flip f = (x -> y -> f y x) - ## Creates a function which drops its input and returns the provided value instead. The expression const a is the same as \_ -> a. @@ -88,7 +88,10 @@ flip f = (x -> y -> f y x) > Example IO.println <| [1, 2, 3].map (Function.const 7) # Prints '[7, 7, 7]' const : Any -> Any -> Any -const x _ = x +const x ~f = + black_hole ~_ = Nothing + black_hole f + x ## Converts a single-argument function accepting a pair of elements into a multi-argument one. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso index dee2da9f19..db43dcb6e1 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso @@ -77,6 +77,7 @@ import project.Data.Filter_Condition.Filter_Condition import project.Data.Index_Sub_Range.Index_Sub_Range import project.Data.Interval.Bound import project.Data.Interval.Interval +import project.Data.Interval.Interval_Type import project.Data.Json.Json import project.Data.Json.JS_Object import project.Data.Locale.Locale @@ -130,6 +131,7 @@ export project.Data.Filter_Condition.Filter_Condition export project.Data.Index_Sub_Range.Index_Sub_Range export project.Data.Interval.Bound export project.Data.Interval.Interval +export project.Data.Interval.Interval_Type export project.Data.Json.Json export project.Data.Json.JS_Object export project.Data.Locale.Locale diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Math.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Math.enso index 29ca15da35..0d02aff23f 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Math.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Math.enso @@ -24,7 +24,8 @@ pi = 3.1415926535897932385 e : Decimal e = 2.718281828459045235360 -## ALIAS Minimum +## PRIVATE + ADVANCED Returns the smaller value of `a` and `b`. @@ -44,7 +45,8 @@ e = 2.718281828459045235360 min : Number -> Number -> Number min a b = if a <= b then a else b -## ALIAS Maximum +## PRIVATE + ADVANCED Returns the larger value of `a` and `b`. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Meta/Enso_Project.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Meta/Enso_Project.enso index cee10b92b3..d30aeac541 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Meta/Enso_Project.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Meta/Enso_Project.enso @@ -8,7 +8,9 @@ from project.Errors.Common import Module_Not_In_Package_Error ## Functionality for inspecting the current project. @Builtin_Type type Project_Description - ## Returns the Enso project description for the given module. If no module is + ## PRIVATE + ADVANCED + Returns the Enso project description for the given module. If no module is given, returns the description of the project that the engine was executed with, i.e., the project that contains the `main` method, or throws `Module_Not_In_Package_Error` if there is no such project, e.g., when diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP.enso index 9c3fd4df96..183109700f 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP.enso @@ -30,7 +30,8 @@ polyglot java import java.net.ProxySelector polyglot java import org.enso.base.Http_Utils type HTTP - ## Create a new instance of the HTTP client. + ## ADVANCED + Create a new instance of the HTTP client. Arguments: - timeout: The length of time the client will wait for responses. @@ -54,13 +55,13 @@ type HTTP import Standard.Base.Network.Proxy.Proxy example_new = - HTTP.new (timeout = (Duration.new seconds=30)) (proxy = Proxy.new "example.com" 8080) + HTTP.new (timeout = (Duration.new seconds=30)) (proxy = Proxy.Address "example.com" 8080) new : Duration -> Boolean -> Proxy -> HTTP_Version -> 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 - + ## PRIVATE + ADVANCED Send the Get request and return the body. Arguments: diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP/Form.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP/Form.enso index 8f34cb7a06..e019a881d2 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP/Form.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP/Form.enso @@ -5,7 +5,9 @@ import project.Data.Vector.Vector ## The HTTP form containing a vector of parts. type Form - ## Create a text field of a Form. + ## PRIVATE + ADVANCED + Create a text field of a Form. Arguments: - key: The key for the field in the form. @@ -20,7 +22,9 @@ type Form text_field : Text -> Text -> Part text_field key val = Part.Value key (Part_Value.Text val) - ## Create a file field of a Form. + ## PRIVATE + ADVANCED + Create a file field of a Form. Arguments: - key: The key for the field in the form. @@ -35,7 +39,9 @@ type Form file_field : Text -> Text -> Part file_field key file = Part.Value key (Part_Value.File file) - ## Create Form data from Parts. + ## PRIVATE + ADVANCED + Create Form data from Parts. Arguments: - parts: A vector of parts to make up the form. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Network/Proxy.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Network/Proxy.enso index 3280478f3b..7ce5e6e470 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Network/Proxy.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Network/Proxy.enso @@ -3,7 +3,13 @@ import project.Data.Text.Text ## Proxy settings. type Proxy - ## Create new proxy settings from a host and port. + ## The proxy is disabled. + None + + ## Use the system proxy settings. + System + + ## Use the provided proxy server. Arguments: - host: The host address for the proxy. @@ -14,15 +20,5 @@ type Proxy import Standard.Base.Network.Proxy.Proxy - example_new = Proxy.new "localhost" 80800 - new : Text -> Integer -> Proxy - new host port=80 = Proxy.Address host port - - ## The proxy is disabled. - None - - ## Use the system proxy settings. - System - - ## Use the provided proxy server. - Address proxy_host proxy_port + example_new = Proxy.Address "localhost" 80800 + Address proxy_host:Text proxy_port:Integer=80 diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Panic.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Panic.enso index 1f277d1a49..7615ecf4ff 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Panic.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Panic.enso @@ -54,7 +54,8 @@ type Panic primitive_get_attached_stack_trace : Throwable -> Array primitive_get_attached_stack_trace throwable = @Builtin_Method "Panic.primitive_get_attached_stack_trace" - ## ADVANCED + ## PRIVATE + ADVANCED Returns the attached stack trace of the given throwable. Can be used to get an Enso friendly stack trace from native Java exceptions. @@ -87,7 +88,8 @@ type Panic rethrow : (Any ! Any) -> Any rethrow value = value.catch Any Panic.throw - ## Executes the provided action and if a panic matching the provided type was + ## ADVANCED + Executes the provided action and if a panic matching the provided type was thrown, calls the provided callback. If action executes successfully, the result of `Panic.catch` is the result of @@ -152,7 +154,8 @@ type Panic finalizer result - ## Executes the provided action and converts a possible panic matching any of + ## ADVANCED + Executes the provided action and converts a possible panic matching any of the provided types into a dataflow Error. If action executes successfully, the result of `Panic.recover` is the result diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Random.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Random.enso index 9a9ad8994f..86b61c3741 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Random.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Random.enso @@ -68,7 +68,8 @@ type Random_Number_Generator to_display_text : Text to_display_text self = "Random_Number_Generator" -## Returns a new vector containing a random sample of the input vector, without +## PRIVATE + Returns a new vector containing a random sample of the input vector, without replacement. If the amount of elements to select is larger than the input vector size, it @@ -78,7 +79,8 @@ sample vector k rng = new_array = Random_Utils.sample vector.to_array k rng.java_random Vector.from_polyglot_array new_array -## Returns `k` indices sampled from the range [0, n-1] without replacement. +## PRIVATE + Returns `k` indices sampled from the range [0, n-1] without replacement. If `k >= n`, it will return a random permutation of the indices. random_indices : Integer -> Integer -> Random_Number_Generator -> Vector Integer diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/System/File_Format.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/System/File_Format.enso index e61a482723..d8c7584d8e 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/System/File_Format.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/System/File_Format.enso @@ -73,7 +73,9 @@ type Auto_Detect get_format f-> f.for_web content_type uri type File_Format - ## Gets all the currently available file formats. + ## PRIVATE + ADVANCED + Gets all the currently available file formats. The available file formats are ones provided by libraries which are imported within the current project. Importing an new library may cause @@ -84,7 +86,9 @@ type File_Format ## PRIVATE Implements the `File.read` for this `File_Format` read : File -> Problem_Behavior -> Any - read _ _ = Unimplemented.throw "This is an interface only." + read self file on_problems = + _ = [file, on_problems] + Unimplemented.throw "This is an interface only." ## PRIVATE Create the constructor code for a File_Format type. @@ -129,7 +133,8 @@ type Plain_Text_Format ## 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 _ = + for_web content_type uri = + _ = [uri] parts = content_type.split ";" . map .trim case parts.first of "text/plain" -> @@ -170,12 +175,15 @@ type Bytes 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 + for_web content_type uri = + _ = [content_type, uri] + Nothing ## PRIVATE Implements the `File.read` for this `File_Format` read : File -> Problem_Behavior -> Any - read self file _ = + read self file on_problems = + _ = [on_problems] file.read_bytes type JSON_Format @@ -196,7 +204,8 @@ type JSON_Format ## PRIVATE If the File_Format supports reading from the web response, return a configured instance. for_web : Text -> URI -> JSON_Format | Nothing - for_web content_type _ = + for_web content_type uri = + _ = [uri] first = content_type.split ';' . first . trim case first of "application/json" -> JSON_Format @@ -205,7 +214,8 @@ type JSON_Format ## PRIVATE Implements the `File.read` for this `File_Format` read : File -> Problem_Behavior -> Any - read self file _ = + read self file on_problems = + _ = [on_problems] text = file.read_text Json.parse text . catch Invalid_JSON error-> Error.throw (File_Error.Corrupted_Format file error.to_display_text error) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/System/Platform.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/System/Platform.enso index cbdba7b4b5..1d7350adf8 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/System/Platform.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/System/Platform.enso @@ -27,7 +27,9 @@ type OS os : OS os = from_text System.os -## Check if the operating system is UNIX. +## PRIVATE + ADVANCED + Check if the operating system is UNIX. is_unix : Boolean is_unix = @Builtin_Method "System.is_unix" diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Warning.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Warning.enso index 8032057a08..667698efe8 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Warning.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Warning.enso @@ -26,13 +26,16 @@ type Warning origin = Runtime.get_stack_trace attach_with_stacktrace value warning (origin.drop (Index_Sub_Range.First 1)) - ## ADVANCED + ## PRIVATE + ADVANCED Are any warnings attached to the value? has_warnings : Any -> Any -> Boolean has_warnings value warning_type=Any = Warning.get_all value . any (w-> w.value.is_a warning_type) - ## Remove the warnings (either all or of a specified type) attached to the value. + ## PRIVATE + ADVANCED + Remove the warnings (either all or of a specified type) attached to the value. Arguments: - warning_type: The type to remove if attached to the value. Defaults to all warnings. @@ -50,13 +53,15 @@ type Warning first = warnings.find (w-> w.value.is_a warning_type) if_missing=Nothing if first.is_nothing then self else Error.throw first.value - ## ADVANCED + ## PRIVATE + 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) - ## ADVANCED + ## PRIVATE + ADVANCED Returns `True` if the maximal number of reported warnings for a value has been reached, `False` otherwise. limit_reached : Any -> Boolean limit_reached value = @Builtin_Method "Warning.limit_reached" @@ -73,7 +78,8 @@ type Warning set : Any -> Vector Warning -> Any set value warnings = set_array value warnings.to_array - ## ADVANCED + ## PRIVATE + ADVANCED Returns the provided value with any warnings removed from it. Arguments: @@ -166,7 +172,8 @@ type Warning original dataflow error as-is, to preserve its stacktrace. Nothing -> mapped_warnings_or_error - ## ADVANCED + ## PRIVATE + 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. diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/SQLite_Format.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/SQLite_Format.enso index 3bd0f90864..a3bea690cf 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/SQLite_Format.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/SQLite_Format.enso @@ -29,8 +29,9 @@ type SQLite_Format ## PRIVATE If the File_Format supports reading from the web response, return a configured instance. for_web : Text -> URI -> SQLite_Format | Nothing - for_web _ _ = + for_web content_type uri = ## Currently not loading SQLite files automatically. + _ = [content_type, uri] Nothing ## PRIVATE diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQL_Type_Mapping.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQL_Type_Mapping.enso index 560c1a63cd..746bae5691 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQL_Type_Mapping.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQL_Type_Mapping.enso @@ -35,7 +35,8 @@ type SQL_Type_Mapping _ = sql_type Unimplemented.throw "This is an interface only." - ## Converts an SQL_Type to a Text representation compatible with the related + ## PRIVATE + Converts an SQL_Type to a Text representation compatible with the related SQL dialect that can be used in SQL expressions like CAST or column definitions. sql_type_to_text : SQL_Type -> Text diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso index 6ac22bbd2b..8a6b9e0eda 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso @@ -144,7 +144,8 @@ type SQLite_Dialect ## PRIVATE make_cast : Internal_Column -> SQL_Type -> (SQL_Expression -> SQL_Type_Reference) -> Internal_Column - make_cast self column target_type _ = + make_cast self column target_type infer_result_type_from_database_callback = + _ = [infer_result_type_from_database_callback] mapping = self.get_type_mapping target_value_type = mapping.sql_type_to_value_type target_type custom_cast = make_custom_cast column target_value_type mapping diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Type_Mapping.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Type_Mapping.enso index 902db7fd61..7e2a8640c1 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Type_Mapping.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Type_Mapping.enso @@ -94,7 +94,8 @@ type SQLite_Type_Mapping Database to tell the expected types, because it has been found to be unreliable in more complex expressions. infer_return_type : (SQL_Expression -> SQL_Type_Reference) -> Text -> Vector -> SQL_Expression -> SQL_Type_Reference - infer_return_type _ op_name arguments _ = + infer_return_type infer_from_database_callback op_name arguments expression = + _ = [infer_from_database_callback, expression] handler = operations_map.get op_name (_ -> Error.throw (Illegal_State.Error "Impossible: Unknown operation "+op_name+". This is a bug in the Database library.")) sql_type = handler arguments SQL_Type_Reference.from_constant sql_type diff --git a/distribution/lib/Standard/Image/0.0.0-dev/src/Image_File_Format.enso b/distribution/lib/Standard/Image/0.0.0-dev/src/Image_File_Format.enso index 80acec43a2..b239c4c3ed 100644 --- a/distribution/lib/Standard/Image/0.0.0-dev/src/Image_File_Format.enso +++ b/distribution/lib/Standard/Image/0.0.0-dev/src/Image_File_Format.enso @@ -27,8 +27,9 @@ type Image_File_Format ## 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 _ _ = + for_web content_type uri = ## Currently not loading Image files automatically. This should be supported later. + _ = [content_type, uri] Nothing ## PRIVATE diff --git a/distribution/lib/Standard/Searcher/0.0.0-dev/src/Data_Science/Numbers.enso b/distribution/lib/Standard/Searcher/0.0.0-dev/src/Data_Science/Numbers.enso index fde633b252..f841b295b8 100644 --- a/distribution/lib/Standard/Searcher/0.0.0-dev/src/Data_Science/Numbers.enso +++ b/distribution/lib/Standard/Searcher/0.0.0-dev/src/Data_Science/Numbers.enso @@ -12,12 +12,12 @@ > Example Calculate the smallest number out of 1 and 2. - Math.min 1 2 + 1.min 2 > Example Calculate the largest number out of 1 and 2. - Math.max 1 2 + 1.max 2 > Example Calculate the sine of 2. diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Column.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Column.enso index a17a61e450..f6877b0b51 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Column.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Column.enso @@ -98,7 +98,7 @@ type Column col_name = normalize_string_for_display java_col.getName storage = java_col.getStorage num_rows = java_col.getSize - display_rows = Math.min num_rows show_rows + display_rows = num_rows.min show_rows items = Vector.new display_rows num-> row = if storage.isNa num then "Nothing" else get_item_string storage num @@ -1751,8 +1751,8 @@ type Column slice : Integer -> Integer -> Column slice self start end = length = self.length - offset = Math.max (Math.min start length) 0 - limit = Math.max (Math.min (end - offset) (length - offset)) 0 + offset = (start.min length).max 0 + limit = ((end - offset).min (length - offset)).max 0 Column.Value (self.java_column.slice offset limit) ## Returns the first element in the column, if it exists. diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso index cbff9be0e2..80ce89d131 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso @@ -147,7 +147,7 @@ type Table col_names = ([index.getName] + cols.map .getName) . map normalize_string_for_display col_vals = cols.map .getStorage num_rows = self.row_count - display_rows = Math.min num_rows show_rows + display_rows = num_rows.min show_rows rows = Vector.new display_rows row_num-> cols = col_vals.map col-> if col.isNa row_num then "Nothing" else get_item_string col row_num @@ -1909,8 +1909,8 @@ type Table slice : Integer -> Integer -> Table slice self start end = length = self.row_count - offset = Math.max (Math.min start length) 0 - limit = Math.max (Math.min (end - offset) (length - offset)) 0 + offset = (start.min length).max 0 + limit = ((end - offset).min (length - offset)).max 0 Table.Value (self.java_table.slice offset limit) ## Returns a table containing the rows of `self` table with their order @@ -2058,8 +2058,8 @@ ansi_bold enabled txt = print_table : Vector Text -> (Vector (Vector Text)) -> Integer -> Boolean -> Text print_table header rows indices_count format_term = content_lengths = Vector.new header.length i-> - max_row = 0.up_to rows.length . fold 0 a-> j-> Math.max a (rows.at j . at i . characters . length) - Math.max max_row (header.at i . characters . length) + max_row = 0.up_to rows.length . fold 0 a-> j-> a.max (rows.at j . at i . characters . length) + max_row.max (header.at i . characters . length) header_line = header.zip content_lengths pad . map (ansi_bold format_term) . join ' | ' divider = content_lengths . map (l -> "-".repeat l+2) . join '+' row_lines = rows.map r-> diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table_Conversions.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table_Conversions.enso index 1a968c6864..62116c5f70 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table_Conversions.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table_Conversions.enso @@ -114,7 +114,7 @@ Table.from_objects value fields=Nothing = will be named `Column ` where `N` is the number of the marked group. (Group 0 is not included.) Text.parse_to_table : Text -> Case_Sensitivity -> Boolean -> Problem_Behavior -> Table ! Type_Error | Regex_Syntax_Error | Illegal_Argument -Text.parse_to_table self pattern="." case_sensitivity=Case_Sensitivity.Sensitive parse_values=True on_problems=Report_Warning = +Text.parse_to_table self pattern case_sensitivity=Case_Sensitivity.Sensitive parse_values=True on_problems=Report_Warning = Parse_To_Table.parse_text_to_table self pattern case_sensitivity parse_values on_problems ## PRIVATE diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Type/Value_Type_Helpers.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Type/Value_Type_Helpers.enso index 99b7e12694..3d189a66b8 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Type/Value_Type_Helpers.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Type/Value_Type_Helpers.enso @@ -13,14 +13,14 @@ reconcile_types current new = case current of Value_Type.Mixed -> Value_Type.Mixed Value_Type.Integer size -> case new of Value_Type.Integer new_size -> - Value_Type.Integer (Math.max size new_size) + Value_Type.Integer (max_size size new_size) Value_Type.Byte -> Value_Type.Integer size # If we unify integers with floats, we select the default Float 64 regardless of the input sizes. Value_Type.Float _ -> Value_Type.Float _ -> Value_Type.Mixed Value_Type.Float size -> case new of Value_Type.Float new_size -> - Value_Type.Float (Math.max size new_size) + Value_Type.Float (max_size size new_size) # If we unify integers with floats, we select the default Float 64 regardless of the input sizes. Value_Type.Integer _ -> Value_Type.Float Value_Type.Byte -> Value_Type.Float @@ -55,7 +55,7 @@ reconcile_types current new = case current of returned. max_size a b = if a.is_nothing || b.is_nothing then Nothing else - Math.max a b + if a < b then b else a ## PRIVATE Finds the most specific value type that will fit all the provided types. diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Delimited/Delimited_Format.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Delimited/Delimited_Format.enso index c5d994d97c..89c633a15e 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Delimited/Delimited_Format.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Delimited/Delimited_Format.enso @@ -75,7 +75,8 @@ type Delimited_Format 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 _ = + for_web content_type uri = + _ = [uri] parts = content_type.split ";" . map .trim charset_part = parts.find if_missing=Nothing (x-> x.starts_with "charset=") diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Excel/Excel_Format.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Excel/Excel_Format.enso index 4d7c6adc44..5498b16792 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Excel/Excel_Format.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Excel/Excel_Format.enso @@ -63,7 +63,8 @@ type Excel_Format ADVANCED If the File_Format supports reading from the web response, return a configured instance. for_web : Text -> URI -> Excel_Format | Nothing - for_web _ _ = + for_web content_type uri = + _ = [content_type, uri] ## Currently not loading Excel files automatically as these need to be loaded as a connection. Nothing diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Excel/Excel_Workbook.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Excel/Excel_Workbook.enso index 38fc2eeba5..f2fe91ed52 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Excel/Excel_Workbook.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Excel/Excel_Workbook.enso @@ -15,7 +15,9 @@ polyglot java import org.enso.table.read.ExcelReader polyglot java import org.apache.poi.ss.usermodel.Workbook type Excel_Workbook - ## Load a File as a connection to an Excel workbook. + ## PRIVATE + ADVANCED + Load a File as a connection to an Excel workbook. Arguments: - file: The file to load. diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Excel_Writer.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Excel_Writer.enso index 27e72e0bb2..ebbd48919f 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Excel_Writer.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Excel_Writer.enso @@ -33,7 +33,8 @@ make_java_existing_data_mode on_existing_file match_columns = case on_existing_f Arguments: write_file : File -> Table -> Existing_File_Behavior -> Excel_Section -> (Boolean|Infer) -> Match_Columns -> Problem_Behavior -> Boolean -> File -write_file file table on_existing_file section headers match_columns _ xls_format=False = +write_file file table on_existing_file section headers match_columns on_problems xls_format=False = + _ = [on_problems] workbook = if file.exists.not then ExcelWriter.createWorkbook xls_format else Excel_Reader.handle_reader file stream->(ExcelReader.getWorkbook stream xls_format) diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Multi_Value_Key.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Multi_Value_Key.enso index 55b8e84ac0..39251ba66e 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Multi_Value_Key.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Multi_Value_Key.enso @@ -87,6 +87,8 @@ type Ordered_Multi_Value_Key_Comparator go 0 ## PRIVATE - hash _ = Error.throw (Illegal_State.new "Ordered_Multi_Value_Key is not intended for usage in unordered collections.") + hash x = + _ = [x] + Error.throw (Illegal_State.new "Ordered_Multi_Value_Key is not intended for usage in unordered collections.") Comparable.from (_:Ordered_Multi_Value_Key) = Ordered_Multi_Value_Key_Comparator diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso index 1e5fe448ea..2ec804be92 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Extensions.enso @@ -105,7 +105,8 @@ Any.should_equal_type self that frames_to_skip=0 = case (self.is_same_object_as Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_equal_type self _ frames_to_skip=0 = +Error.should_equal_type self that frames_to_skip=0 = + _ = [that] Test.fail_match_on_unexpected_error self 1+frames_to_skip ## Asserts that `self` value is not equal to the expected value. @@ -131,7 +132,8 @@ Any.should_not_equal self that frames_to_skip=0 = case self != that of Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_not_equal self _ frames_to_skip=0 = +Error.should_not_equal self that frames_to_skip=0 = + _ = [that] Test.fail_match_on_unexpected_error self 1+frames_to_skip ## Asserts that `self` value is not equal to the expected type value. @@ -157,7 +159,8 @@ Any.should_not_equal_type self that frames_to_skip=0 = case (self.is_same_object Test.fail msg ## Added so that dataflow errors are not silently lost. -Error.should_not_equal_type self _ frames_to_skip=0 = +Error.should_not_equal_type self that frames_to_skip=0 = + _ = [that] Test.fail_match_on_unexpected_error self 1+frames_to_skip ## Asserts that `self` value is a Text value and starts with `that`. @@ -198,7 +201,9 @@ Any.should_start_with self that frames_to_skip=0 = case self of example_should_start_with = "Hello World!" . should_start_with "Hello" Error.should_start_with : Any -> Integer -> Test_Result -Error.should_start_with self _ frames_to_skip=0 = Test.fail_match_on_unexpected_error self 1+frames_to_skip +Error.should_start_with self that frames_to_skip=0 = + _ = [that] + Test.fail_match_on_unexpected_error self 1+frames_to_skip ## Asserts that `self` value is equal to the expected value. @@ -213,7 +218,9 @@ Error.should_start_with self _ frames_to_skip=0 = Test.fail_match_on_unexpected_ example_should_equal = Examples.add_1_to 1 . should_equal 2 Error.should_equal : Any -> Integer -> Test_Result -Error.should_equal self _ frames_to_skip=0 = Test.fail_match_on_unexpected_error self 1+frames_to_skip +Error.should_equal self that frames_to_skip=0 = + _ = [that] + Test.fail_match_on_unexpected_error self 1+frames_to_skip ## Asserts that `self` is within `epsilon` from `that`. @@ -456,7 +463,9 @@ Any.should_contain_the_same_elements_as self that frames_to_skip=0 = example_should_equal = [1, 2] . should_contain_the_same_elements_as [2, 1] Error.should_contain_the_same_elements_as : Any -> Integer -> Test_Result -Error.should_contain_the_same_elements_as self _ frames_to_skip=0 = Test.fail_match_on_unexpected_error self 1+frames_to_skip +Error.should_contain_the_same_elements_as self that frames_to_skip=0 = + _ = [that] + Test.fail_match_on_unexpected_error self 1+frames_to_skip ## Asserts that `self` value contains an element. @@ -504,7 +513,8 @@ Any.should_contain self element frames_to_skip=0 = example_should_equal = "foobar".should_contain "foo" Error.should_contain : Any -> Integer -> Test_Result -Error.should_contain self _ frames_to_skip=0 = +Error.should_contain self element frames_to_skip=0 = + _ = [element] Test.fail_match_on_unexpected_error self 1+frames_to_skip ## Asserts that `self` value does not contain an element. diff --git a/distribution/lib/Standard/Visualization/0.0.0-dev/src/AI.enso b/distribution/lib/Standard/Visualization/0.0.0-dev/src/AI.enso index 7c6617e640..37e7e8c52a 100644 --- a/distribution/lib/Standard/Visualization/0.0.0-dev/src/AI.enso +++ b/distribution/lib/Standard/Visualization/0.0.0-dev/src/AI.enso @@ -1,6 +1,7 @@ from Standard.Base import all import Standard.Table.Data.Table.Table +## PRIVATE goal_placeholder = "__$$GOAL$$__" ## PRIVATE diff --git a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Helpers.enso b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Helpers.enso index b8f8d91cf5..e1badf4905 100644 --- a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Helpers.enso +++ b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Helpers.enso @@ -102,7 +102,8 @@ Error.is_valid self = self.is_error.not - _: a function that will be used to generate return value from a non-error `self` value. Error.map_valid : Any -> Any -Error.map_valid self _ = self +Error.map_valid self f = + const self f ## PRIVATE diff --git a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table.enso b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table.enso index 1744eb84bc..8a1f8e914c 100644 --- a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table.enso +++ b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table.enso @@ -98,7 +98,7 @@ compute_vertical_indices table start_row end_row start_line lines_to_get = initial_offset = agg.get 1 result_indices = agg.get 2 lines_in_row = (get_row_height table row_ix) - initial_offset - lines_to_process = Math.min lines_in_row lines_left_to_process + lines_to_process = lines_in_row.min lines_left_to_process start_line = initial_offset end_line = start_line + lines_to_process line_indices = start_line.up_to end_line . to_vector @@ -125,7 +125,7 @@ get_chunks_for_row table row_ix line_ix initial_chunk_offset column_range chunk_ column = table.get column_ix chunks_in_this_column = (((get_column_width column) / chunk_size).ceil) - chunk_offset chunks_left = chunks_to_get - processed_chunks_previously - chunks_to_process = Math.min chunks_in_this_column chunks_left + chunks_to_process = chunks_in_this_column.min chunks_left cell_text = column.at row_ix . to_text text_line = cell_text.lines.get line_ix get_chunk_by_index = get_chunk_from_line text_line chunk_size @@ -142,7 +142,7 @@ get_chunks_for_row table row_ix line_ix initial_chunk_offset column_range chunk_ Return the max value in the given vector. max : Vector Integer -> Integer max vector = - vector.fold 0 (l -> r -> Math.max l r) + vector.fold 0 (l -> r -> l.max r) ## PRIVATE Return the longest line in the given text. diff --git a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso index c8583a4642..12cab0bf9e 100644 --- a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso +++ b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso @@ -54,7 +54,8 @@ prepare_visualization y max_rows=1000 = result.to_text -## Column Limit +## PRIVATE + Column Limit max_columns = 250 ## PRIVATE diff --git a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Text.enso b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Text.enso index a8e2e33e96..ee35dc8086 100644 --- a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Text.enso +++ b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Text.enso @@ -23,16 +23,16 @@ type Message get_lazy_visualization_text_window text pos size chunk_width = get_text_chunk = get_item_from text chunk_width lines = text.lines.length - pos_x = Math.max pos.first 0 - pos_y = Math.max pos.second 0 + pos_x = pos.first.max 0 + pos_y = pos.second.max 0 size_x = size.first size_y = size.second x_range = pos_x.up_to (pos_x + size_x) - y_range = pos_y.up_to (Math.min (pos_y + size_y) lines) + y_range = pos_y.up_to ((pos_y + size_y).min lines) coordinates = x_range.map (x -> y_range.map (y -> [x,y])) . flatten chunks = coordinates.map (ix -> [ix, (get_text_chunk ix)]) active_lines = y_range.map text.lines.at - max_line_length = (active_lines.map (line -> line.length)).fold 0 (l -> r -> Math.max l r) + max_line_length = (active_lines.map (line -> line.length)).fold 0 (l -> r -> l.max r) make_grid_visualization_response chunks lines max_line_length ## PRIVATE @@ -56,7 +56,7 @@ get_item_from text chunk_size index = get_chunk_from_line text chunk_size ix = upper_bound = text.length start = ix * chunk_size - end = Math.min (start + chunk_size) upper_bound + end = (start + chunk_size).min upper_bound range = start.up_to end if start > text.length then Nothing else slice_text text [range] diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoDate.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoDate.java index 3eed339ab5..9b981ea340 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoDate.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoDate.java @@ -28,7 +28,7 @@ public final class EnsoDate implements TruffleObject { @Builtin.Method(description = "Return current Date", autoRegister = false) @CompilerDirectives.TruffleBoundary - public static EnsoDate now() { + public static EnsoDate today() { return new EnsoDate(LocalDate.now()); } diff --git a/engine/runtime/src/test/java/org/enso/interpreter/test/ValuesGenerator.java b/engine/runtime/src/test/java/org/enso/interpreter/test/ValuesGenerator.java index 1a8d4c536d..1b4476eba1 100644 --- a/engine/runtime/src/test/java/org/enso/interpreter/test/ValuesGenerator.java +++ b/engine/runtime/src/test/java/org/enso/interpreter/test/ValuesGenerator.java @@ -400,7 +400,7 @@ class ValuesGenerator { public List timesAndDates() { var collect = new ArrayList(); if (languages.contains(Language.ENSO)) { - collect.add(v(null, "import Standard.Base.Data.Time.Date.Date", "Date.now").type()); + collect.add(v(null, "import Standard.Base.Data.Time.Date.Date", "Date.today").type()); collect.add(v(null, "import Standard.Base.Data.Time.Date.Date", "Date.new 1999 3 23").type()); collect.add(v(null, "import Standard.Base.Data.Time.Date_Time.Date_Time", "Date_Time.now").type()); collect.add(v(null, "import Standard.Base.Data.Time.Date_Time.Date_Time", "Date_Time.parse '2021-01-01T00:30:12.7102[UTC]'").type()); diff --git a/engine/runtime/src/test/resources/Test_Serializer_FQN/src/Main.enso b/engine/runtime/src/test/resources/Test_Serializer_FQN/src/Main.enso index 3c62c064aa..a0398369a9 100644 --- a/engine/runtime/src/test/resources/Test_Serializer_FQN/src/Main.enso +++ b/engine/runtime/src/test/resources/Test_Serializer_FQN/src/Main.enso @@ -1,4 +1,4 @@ import Standard.Base main = - Standard.Base.Data.Time.Date.Date.now + Standard.Base.Data.Time.Date.Date.today 1 diff --git a/test/Table_Tests/src/Database/Types/SQLite_Type_Mapping_Spec.enso b/test/Table_Tests/src/Database/Types/SQLite_Type_Mapping_Spec.enso index 1c59c100c8..e5dd68550a 100644 --- a/test/Table_Tests/src/Database/Types/SQLite_Type_Mapping_Spec.enso +++ b/test/Table_Tests/src/Database/Types/SQLite_Type_Mapping_Spec.enso @@ -105,7 +105,7 @@ spec = t.at "d" . value_type . should_equal Value_Type.Char Test.specify "does not support creating tables with date/time values" <| - t = Table.new [["a", [Date.now]], ["b", [Time_Of_Day.now]], ["c", [Date_Time.now]]] + t = Table.new [["a", [Date.today]], ["b", [Time_Of_Day.now]], ["c", [Date_Time.now]]] r1 = t.select_into_database_table connection table_name=(Name_Generator.random_name "date-time-table") temporary=True r1.should_fail_with Unsupported_Database_Operation diff --git a/test/Tests/src/Data/Interval_Spec.enso b/test/Tests/src/Data/Interval_Spec.enso index 5c0978268d..1e7dc2d4f0 100644 --- a/test/Tests/src/Data/Interval_Spec.enso +++ b/test/Tests/src/Data/Interval_Spec.enso @@ -21,25 +21,26 @@ spec = (exclusive_1 == exclusive_1) . should_be_true (exclusive_1 == exclusive_2) . should_be_false (inclusive_1 == exclusive_1) . should_be_false + Test.group "Interval" <| Test.specify "should allow constructing exclusive intervals" <| - interval = Interval.exclusive 1 5 + interval = Interval.new 1 5 Interval_Type.Exclusive interval.start . should_equal (Bound.Exclusive 1) interval.end . should_equal (Bound.Exclusive 5) Test.specify "should allow constructing start-exclusive intervals" <| - interval = Interval.start_exclusive 1 5 + interval = Interval.new 1 5 Interval_Type.Start_Exclusive interval.start . should_equal (Bound.Exclusive 1) interval.end . should_equal (Bound.Inclusive 5) Test.specify "should allow constructing end-exclusive intervals" <| - interval = Interval.end_exclusive 1 5 + interval = Interval.new 1 5 interval.start . should_equal (Bound.Inclusive 1) interval.end . should_equal (Bound.Exclusive 5) Test.specify "should allow constructing inclusive intervals" <| - interval = Interval.inclusive 1 5 + interval = Interval.new 1 5 Interval_Type.Inclusive interval.start . should_equal (Bound.Inclusive 1) interval.end . should_equal (Bound.Inclusive 5) Test.specify "should allow checking if an interval contains a value of the contained type" <| - interval = Interval.end_exclusive 1 10 + interval = Interval.new 1 10 interval.contains 0 . should_be_false interval.contains 1 . should_be_true interval.contains 5.5 . should_be_true @@ -47,59 +48,59 @@ spec = interval.contains 10 . should_be_false interval.contains 10 . should_be_false - interval_2 = Interval.end_exclusive 0 0 + interval_2 = Interval.new 0 0 interval_2.contains -1 . should_be_false interval_2.contains 0 . should_be_false interval_2.contains 1 . should_be_false - interval_3 = Interval.end_exclusive 0 1 + interval_3 = Interval.new 0 1 interval_3.contains -1 . should_be_false interval_3.contains 0 . should_be_true interval_3.contains 0.5 . should_be_true interval_3.contains 0.99999999 . should_be_true interval_3.contains 1 . should_be_false - interval_4 = Interval.inclusive 0 0 + interval_4 = Interval.new 0 0 Interval_Type.Inclusive interval_4.contains -1 . should_be_false interval_4.contains 0 . should_be_true interval_4.contains 0.00001 . should_be_false interval_4.contains 1 . should_be_false - interval_5 = Interval.exclusive 0 0 + interval_5 = Interval.new 0 0 Interval_Type.Exclusive interval_5.contains -1 . should_be_false interval_5.contains 0 . should_be_false interval_5.contains 1 . should_be_false - interval_6 = Interval.start_exclusive 0 0 + interval_6 = Interval.new 0 0 Interval_Type.Start_Exclusive interval_6.contains -1 . should_be_false interval_6.contains 0 . should_be_false interval_6.contains 1 . should_be_false - interval_7 = Interval.start_exclusive 0.123 0.124 + interval_7 = Interval.new 0.123 0.124 Interval_Type.Start_Exclusive interval_7.contains 0.123 . should_be_false interval_7.contains 0.1235 . should_be_true interval_7.contains 0.124 . should_be_true interval_7.contains 1 . should_be_false - (Interval.inclusive 0.1 1) . contains 0.33 . should_be_true + (Interval.new 0.1 1 Interval_Type.Inclusive) . contains 0.33 . should_be_true Test.specify "can be checked for emptiness" <| - Interval.exclusive 0 0 . is_empty . should_be_true - Interval.exclusive 1 10 . is_empty . should_be_false - Interval.start_exclusive 0 0 . is_empty . should_be_true - Interval.start_exclusive 1 1.1 . is_empty . should_be_false - Interval.end_exclusive 0 0 . is_empty . should_be_true - Interval.end_exclusive 1 10 . is_empty . should_be_false - Interval.inclusive 0 0 . is_empty . should_be_false - Interval.inclusive 0.1 0 . is_empty . should_be_true + Interval.new 0 0 Interval_Type.Exclusive . is_empty . should_be_true + Interval.new 1 10 Interval_Type.Exclusive . is_empty . should_be_false + Interval.new 0 0 Interval_Type.Start_Exclusive . is_empty . should_be_true + Interval.new 1 1.1 Interval_Type.Start_Exclusive . is_empty . should_be_false + Interval.new 0 0 Interval_Type.End_Exclusive . is_empty . should_be_true + Interval.new 1 10 Interval_Type.End_Exclusive . is_empty . should_be_false + Interval.new 0 0 Interval_Type.Inclusive . is_empty . should_be_false + Interval.new 0.1 0 Interval_Type.Inclusive . is_empty . should_be_true Test.specify "can be checked for non-emptiness" <| - Interval.exclusive 0 0 . not_empty . should_be_false - Interval.inclusive 0 0.001 . not_empty . should_be_true - Interval.exclusive 1 10 . not_empty . should_be_true - Interval.start_exclusive 0 0 . not_empty . should_be_false - Interval.start_exclusive 1 1.1 . not_empty . should_be_true - Interval.end_exclusive 0 0 . not_empty . should_be_false - Interval.end_exclusive 1 10 . not_empty . should_be_true - Interval.inclusive 0 0 . not_empty . should_be_true - Interval.inclusive 10 0 . not_empty . should_be_false + Interval.new 0 0 Interval_Type.Exclusive . not_empty . should_be_false + Interval.new 0 0.001 Interval_Type.Inclusive . not_empty . should_be_true + Interval.new 1 10 Interval_Type.Exclusive . not_empty . should_be_true + Interval.new 0 0 Interval_Type.Start_Exclusive . not_empty . should_be_false + Interval.new 1 1.1 Interval_Type.Start_Exclusive . not_empty . should_be_true + Interval.new 0 0 Interval_Type.End_Exclusive . not_empty . should_be_false + Interval.new 1 10 Interval_Type.End_Exclusive . not_empty . should_be_true + Interval.new 0 0 Interval_Type.Inclusive . not_empty . should_be_true + Interval.new 10 0 Interval_Type.Inclusive . not_empty . should_be_false main = Test_Suite.run_main spec diff --git a/test/Tests/src/Data/Noise/Generator_Spec.enso b/test/Tests/src/Data/Noise/Generator_Spec.enso index 708d1c4cc0..ba2a639547 100644 --- a/test/Tests/src/Data/Noise/Generator_Spec.enso +++ b/test/Tests/src/Data/Noise/Generator_Spec.enso @@ -1,5 +1,4 @@ from Standard.Base import all -import Standard.Base.Errors.Unimplemented.Unimplemented import Standard.Base.Data.Noise.Deterministic_Random @@ -10,11 +9,11 @@ spec = Test.group "Deterministic Random Noise Generator" <| gen = Deterministic_Random Test.specify "should always return the same output for the same input" <| - interval = Interval.inclusive 0 1 + interval = Interval.new 0 1 Interval_Type.Inclusive values = Vector.fill 10000 1 . map (gen.step _ interval) values.all (== values.at 0) . should_be_true Test.specify "should always produce values within the specified interval" <| - interval = Interval.inclusive -100 100 + interval = Interval.new -100 100 Interval_Type.Inclusive values = 1.up_to 10000 . to_vector . map (gen.step _ interval) values.all (v -> (v >= -100) && (v <= 100)) . should_be_true diff --git a/test/Tests/src/Data/Noise_Spec.enso b/test/Tests/src/Data/Noise_Spec.enso index 65664cd4e4..ccafacfc57 100644 --- a/test/Tests/src/Data/Noise_Spec.enso +++ b/test/Tests/src/Data/Noise_Spec.enso @@ -14,7 +14,7 @@ spec = Test.group "Noise" <| result = 1.noise (gen=My_Generator) result-result . should_equal 0 Test.specify "should allow the user to specify the interval" <| - interval = Interval.inclusive -250 250 + interval = Interval.new -250 250 Interval_Type.Inclusive values = 1.up_to 10001 . to_vector . map (_.noise interval) values.all (v -> (v >= -250) && (v <= 250)) . should_be_true diff --git a/test/Tests/src/Data/Polyglot_Spec.enso b/test/Tests/src/Data/Polyglot_Spec.enso index 4db1cdd426..753856e221 100644 --- a/test/Tests/src/Data/Polyglot_Spec.enso +++ b/test/Tests/src/Data/Polyglot_Spec.enso @@ -13,7 +13,7 @@ polyglot java import org.enso.base_test_helpers.IntHolder spec = Test.group "Polyglot" <| Test.specify "should be able to invoke a polyglot method by name and pass arguments" <| poly_date = LocalDate.now - date = Date.now.to_date_time + date = Date.today.to_date_time Polyglot.invoke poly_date "atStartOfDay" [] . should_equal date Polyglot.invoke poly_date "atStartOfDay" [].to_array . should_equal date diff --git a/test/Tests/src/Semantic/Meta_Spec.enso b/test/Tests/src/Semantic/Meta_Spec.enso index 0e0be36c39..2853f7eb2e 100644 --- a/test/Tests/src/Semantic/Meta_Spec.enso +++ b/test/Tests/src/Semantic/Meta_Spec.enso @@ -127,7 +127,7 @@ spec = Meta.is_a err Error . should_be_true Meta.is_a err Text . should_be_false - Meta.is_a Date.now Date . should_be_true + Meta.is_a Date.today Date . should_be_true Meta.is_a Date_Time.now Date_Time . should_be_true Meta.is_a Date_Time.now Date . should_be_false Meta.is_a Time_Of_Day.now Time_Of_Day . should_be_true @@ -182,8 +182,8 @@ spec = Meta.type_of True . should_equal_type Boolean Meta.type_of False . should_not_equal_type Any - (Meta.type_of Date.now) . should_equal_type Date - (Meta.type_of Date.now) . should_not_equal_type Date_Time + (Meta.type_of Date.today) . should_equal_type Date + (Meta.type_of Date.today) . should_not_equal_type Date_Time (Meta.type_of Date_Time.now) . should_equal_type Date_Time (Meta.type_of Date_Time.now) . should_not_equal_type Date (Meta.type_of Time_Of_Day.now) . should_equal_type Time_Of_Day