Skip to content

Commit

Permalink
Apply ICONs and other tweaks. (#9552)
Browse files Browse the repository at this point in the history
Lots of ICONs...
  • Loading branch information
jdunkerley authored Mar 26, 2024
1 parent fb0559e commit 7098c5e
Show file tree
Hide file tree
Showing 85 changed files with 702 additions and 281 deletions.
4 changes: 3 additions & 1 deletion distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3.enso
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ polyglot java import software.amazon.awssdk.services.s3.model.PutObjectRequest
polyglot java import software.amazon.awssdk.services.s3.model.S3Exception
polyglot java import software.amazon.awssdk.services.s3.S3Client

## Gets the list of the S3 bucket names.
## ICON data_input
Gets the list of the S3 bucket names.

Arguments:
- credentials: AWS credentials. If not provided, the default credentials will
Expand All @@ -39,6 +40,7 @@ list_buckets credentials:AWS_Credential=AWS_Credential.Default = handle_s3_error
buckets.map b->b.name

## GROUP Standard.Base.Input
ICON data_input
Gets the list of the items inside a bucket.

Arguments:
Expand Down
18 changes: 14 additions & 4 deletions distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type S3_File
is_directory self = self.s3_path.is_directory

## GROUP Standard.Base.Metadata
ICON metadata
Checks if this is a regular file.
is_regular_file : Boolean
is_regular_file self = self.is_directory.not
Expand Down Expand Up @@ -179,19 +180,22 @@ type S3_File
read_text self (encoding=Encoding.utf_8) (on_problems=Problem_Behavior.Report_Warning) =
self.read (Plain_Text encoding) on_problems

## Deletes the object.
## ICON data_output
Deletes the object.
delete : Nothing
delete self = if self.is_directory then Error.throw (S3_Error.Error "Deleting S3 folders is currently not implemented." self.uri) else
if self.exists.not then Error.throw (File_Error.Not_Found self) else
self.delete_if_exists

## Deletes the file if it had existed.
## ICON data_output
Deletes the file if it had existed.
delete_if_exists : Nothing
delete_if_exists self = if self.is_directory then Error.throw (S3_Error.Error "Deleting S3 folders is currently not implemented." self.uri) else
Context.Output.if_enabled disabled_message="Deleting an S3_File is forbidden as the Output context is disabled." panic=False <|
translate_file_errors self <| S3.delete_object self.s3_path.bucket self.s3_path.key self.credentials . if_not_error Nothing

## Copies the file to the specified destination.
## ICON data_output
Copies the file to the specified destination.

Arguments:
- destination: the destination to move the file to.
Expand All @@ -209,7 +213,8 @@ type S3_File
translate_file_errors self <| S3.copy_object self.s3_path.bucket self.s3_path.key destination_path.bucket destination_path.key self.credentials . if_not_error <| s3_destination
_ -> generic_copy self destination.file replace_existing

## Moves the file to the specified destination.
## ICON data_output
Moves the file to the specified destination.

! S3 Move is a Copy and Delete

Expand Down Expand Up @@ -270,6 +275,7 @@ type S3_File
S3_File.Value (self.s3_path.join vec_as_texts) self.credentials

## GROUP Standard.Base.Metadata
ICON metadata
Resolves the parent of this file.
parent : S3_File | Nothing
parent self =
Expand All @@ -278,11 +284,13 @@ type S3_File
S3_File.Value parent_path self.credentials

## GROUP Standard.Base.Metadata
ICON metadata
Checks if `self` is a descendant of `other`.
is_descendant_of : S3_File -> Boolean
is_descendant_of self other = self.s3_path.is_descendant_of other.s3_path

## GROUP Standard.Base.Metadata
ICON metadata
Returns the path of this file.
path : Text
path self = self.s3_path.to_text
Expand All @@ -301,12 +309,14 @@ type S3_File
find_extension_from_name self.name

## GROUP Standard.Base.Metadata
ICON metadata
Gets the creation time of a file.
creation_time : Date_Time ! File_Error
creation_time self =
Error.throw (S3_Error.Error "Creation time is not available for S3 files, consider using `last_modified_time` instead." self.uri)

## GROUP Standard.Base.Metadata
ICON metadata
Gets the last modified time of a file.
last_modified_time : Date_Time ! File_Error
last_modified_time self =
Expand Down
4 changes: 4 additions & 0 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type Any
to self target_type = target_type.from self ...

## GROUP Conversions
ICON text
Generic conversion of an arbitrary Enso value to a corresponding textual
representation.

Expand Down Expand Up @@ -307,6 +308,7 @@ type Any
is_nothing self = False

## GROUP Logical
ICON operators
If `self` is Nothing then returns `other`.

> Example
Expand All @@ -318,6 +320,7 @@ type Any
const self other

## GROUP Logical
ICON operators
If `self` is Nothing then returns Nothing, otherwise returns the result
of running the provided `action`.

Expand Down Expand Up @@ -467,6 +470,7 @@ type Any
|> self ~function = function self

## GROUP Errors
ICON metadata
Checks if any warnings (either all or of a specified type) are attached to the value.

Arguments:
Expand Down
2 changes: 1 addition & 1 deletion distribution/lib/Standard/Base/0.0.0-dev/src/Data.enso
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ post (uri:(URI | Text)) (body:Request_Body=Request_Body.Empty) (method:HTTP_Meth
Data_Read_Helpers.decode_http_response_following_data_links response (Data_Read_Helpers.handle_legacy_format "post" "response_format" response_format)

## GROUP Input
ICON data_download
ICON select_column
Fetches from the provided URI and if successful writes to the file. Returns
an error if the status code does not represent a successful response.

Expand Down
10 changes: 6 additions & 4 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ type Array
sort self (order = Sort_Direction.Ascending) on=Nothing by=Nothing on_incomparable=Problem_Behavior.Ignore =
Array_Like_Helpers.sort self order on by on_incomparable

## ALIAS first, last, sample, slice, top, head, tail, limit
## ALIAS first, head, last, limit, sample, slice, tail, top
GROUP Selections
ICON select_row
Creates a new `Vector` with only the specified range of elements from the
Expand Down Expand Up @@ -181,7 +181,7 @@ type Array
Array_Like_Helpers.drop self range

## GROUP Calculations
ICON add_row
ICON row_add
Inserts the given item into the array at the given index.

Arguments:
Expand All @@ -202,7 +202,7 @@ type Array
Array_Like_Helpers.insert self at item

## GROUP Selections
ICON select_column
ICON table_clean
Removes the item at the given index from the array.

Arguments:
Expand Down Expand Up @@ -380,7 +380,8 @@ type Array
map self function on_problems=Problem_Behavior.Report_Error =
Array_Like_Helpers.map self function on_problems

## Applies a function to each element of the array, returning the `Vector`
## ICON dataframes_union
Applies a function to each element of the array, returning the `Vector`
that contains all results concatenated.

Arguments:
Expand Down Expand Up @@ -586,6 +587,7 @@ type Array
Array_Like_Helpers.partition_with_index self predicate

## GROUP Selections
ICON dataframe_map_row
Swaps the rows and columns of a matrix represented by an array of arrays.

! Error Conditions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type Boolean
not self = @Builtin_Method "Boolean.not"

## GROUP Logical
ICON operators
The if-then-else control flow operator that executes one of two branches
based on a conditional.

Expand All @@ -84,6 +85,7 @@ type Boolean
if_then_else self ~on_true ~on_false = @Builtin_Method "Boolean.if_then_else"

## GROUP Logical
ICON operators
The if-then control flow operator that executes a branch if the condition
is true, and otherwise returns Nothing.

Expand Down
41 changes: 24 additions & 17 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data/Decimal.enso
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import project.Nothing.Nothing
import project.Panic.Panic
import project.Warning.Warning
from project.Data.Boolean import Boolean, False, True
from project.Data.Numbers import Integer, Float, Number, Number_Parse_Error
from project.Data.Numbers import Float, Integer, Number, Number_Parse_Error
from project.Data.Numeric.Internal.Decimal_Internal import Decimal_Comparator
from project.Data.Ordering import Comparable, Ordering
from project.Errors.Common import Loss_Of_Numeric_Precision
Expand Down Expand Up @@ -79,9 +79,11 @@ polyglot java import org.enso.base.numeric.Decimal_Utils
`Arithmetic_Error` will be thrown. In this case, the solution is to specify
an explicit precision using a `Math_Context`.
type Decimal
## PRIVATE
Value (big_decimal : BigDecimal)

## Construct a `Decimal` from a string or integer.
## ICON number_input
Construct a `Decimal` from a string or integer.

Arguments:
- x: The `Text`, `Integer`, or `Float` to construct a `Decimal` from.
Expand All @@ -106,15 +108,16 @@ type Decimal
Create a `Decimal` from a string.

c = Decimal.new "12.345"
new : Text | Integer | Float -> Math_Context -> Decimal ! Arithmetic_Error | Number_Parse_Error
new (x : Text | Integer | Float) (mc : Math_Context | Nothing = Nothing) -> Decimal | Number_Parse_Error =
new : Text | Integer | Float -> Math_Context | Nothing -> Decimal ! Arithmetic_Error | Number_Parse_Error
new (x : Text | Integer | Float) (mc : Math_Context | Nothing = Nothing) -> Decimal ! Arithmetic_Error | Number_Parse_Error =
handle_java_exception <|
case x of
_ : Text -> Decimal.parse x mc
_ : Integer -> Decimal.from_integer x mc
_ : Float -> Decimal.from_float x mc

## GROUP conversions
ICON convert
Construct a `Decimal` from a `Text`.

Arguments:
Expand All @@ -139,14 +142,15 @@ type Decimal
Create a `Decimal` from a string.

d = Decimal.parse "12.345"
parse : Text -> Math_Context -> Decimal ! Arithmetic_Error | Number_Parse_Error
parse (s : Text) (mc : Math_Context | Nothing = Nothing) -> Decimal | Number_Parse_Error =
parse : Text -> Math_Context | Nothing -> Decimal ! Arithmetic_Error | Number_Parse_Error
parse (s : Text) (mc : Math_Context | Nothing = Nothing) -> Decimal ! Arithmetic_Error | Number_Parse_Error =
handle_java_exception <| handle_number_format_exception <|
case mc of
_ : Math_Context -> Decimal.Value <| handle_precision_loss s <| Decimal_Utils.fromString s mc.math_context
_ : Nothing -> Decimal.Value (Decimal_Utils.fromString s)

## GROUP conversions
ICON convert
Construct a `Decimal` from an `Integer`.

Arguments:
Expand All @@ -165,14 +169,15 @@ type Decimal
Create a `Decimal` from an integer.

d = Decimal.from_integer 12
from_integer : Integer -> Math_Context -> Decimal ! Arithmetic_Error
from_integer : Integer -> Math_Context | Nothing -> Decimal ! Arithmetic_Error
from_integer (i : Integer) (mc : Math_Context | Nothing = Nothing) -> Decimal ! Arithmetic_Error =
handle_java_exception <|
case mc of
_ : Math_Context -> Decimal.Value <| handle_precision_loss i <| Decimal_Utils.fromInteger i mc.math_context
_ : Nothing -> Decimal.Value (Decimal_Utils.fromInteger i)

## GROUP conversions
ICON convert
Construct a `Decimal` from a `Float`.

Arguments:
Expand All @@ -199,8 +204,8 @@ type Decimal
Create a `Decimal` from a float.

d = Decimal.from_integer 12.345
from_float : Float -> Math_Context -> Decimal ! Arithmetic_Error ! Illegal_Argument
from_float (f : Float) (mc : Math_Context | Nothing = Nothing) -> Decimal ! Arithmetic_Error ! Illegal_Argument =
from_float : Float -> Math_Context | Nothing -> Decimal ! Arithmetic_Error | Illegal_Argument
from_float (f : Float) (mc : Math_Context | Nothing = Nothing) -> Decimal ! Arithmetic_Error | Illegal_Argument =
is_exceptional = f.is_nan || f.is_infinite
if is_exceptional then Error.throw (Illegal_Argument.Error "Cannot convert "+f.to_text+" to a Decimal") else
handle_java_exception <| attach_loss_of_numeric_precision f <|
Expand Down Expand Up @@ -306,7 +311,7 @@ type Decimal
b = Decimal.new "20.33"
a.add b (Math_Context.new 3)
# => Decimal.new 30.5
add : Decimal -> Decimal -> Math_Context | Nothing -> Decimal ! Arithmetic_Error
add : Decimal -> Math_Context | Nothing -> Decimal ! Arithmetic_Error
add self (that : Decimal) (math_context : Math_Context | Nothing = Nothing) -> Decimal ! Arithmetic_Error =
handle_java_exception <|
case math_context of
Expand All @@ -331,7 +336,7 @@ type Decimal
b = Decimal.new "20.33"
c = a + b
# => Decimal.new 30.55
+ : Decimal -> Decimal -> Decimal
+ : Decimal -> Decimal
+ self (that : Decimal) = self.add that

## ALIAS minus
Expand Down Expand Up @@ -364,7 +369,7 @@ type Decimal
b = Decimal.new "10.22"
c = a.subtract b (Math_Context.new 3)
# => Decimal.new 10.1
subtract : Decimal -> Decimal -> Math_Context | Nothing -> Decimal ! Arithmetic_Error
subtract : Decimal -> Math_Context | Nothing -> Decimal ! Arithmetic_Error
subtract self (that : Decimal) (math_context : Math_Context | Nothing = Nothing) -> Decimal ! Arithmetic_Error =
handle_java_exception <|
case math_context of
Expand All @@ -390,7 +395,7 @@ type Decimal
b = Decimal.new "10.22"
c = a - b
# => Decimal.new 10.11
- : Decimal -> Decimal -> Decimal
- : Decimal -> Decimal
- self (that : Decimal) = self.subtract that

## ALIAS times
Expand Down Expand Up @@ -423,7 +428,7 @@ type Decimal
b = Decimal.new "20.33"
c = a.multiply b (Math_Context.new 4)
# => Decimal.new 207.8
multiply : Decimal -> Decimal -> Math_Context | Nothing -> Decimal ! Arithmetic_Error
multiply : Decimal -> Math_Context | Nothing -> Decimal ! Arithmetic_Error
multiply self (that : Decimal) (math_context : Math_Context | Nothing = Nothing) -> Decimal ! Arithmetic_Error =
handle_java_exception <|
case math_context of
Expand All @@ -448,7 +453,7 @@ type Decimal
b = Decimal.new "20.33"
c = a * b
# => Decimal.new 207.7726
* : Decimal -> Decimal -> Decimal
* : Decimal -> Decimal
* self (that : Decimal) = self.multiply that

## GROUP Operators
Expand Down Expand Up @@ -486,7 +491,7 @@ type Decimal
b = Decimal.new "23.34"
c = a.divide b (Math_Context.new 3)
# => Decimal.new 45.7
divide : Decimal -> Decimal -> Math_Context | Nothing -> Decimal | Arithmetic_Error
divide : Decimal -> Math_Context | Nothing -> Decimal ! Arithmetic_Error
divide self (that : Decimal) (math_context : Math_Context | Nothing = Nothing) -> Decimal ! Arithmetic_Error =
handle_java_exception <|
case math_context of
Expand All @@ -511,10 +516,11 @@ type Decimal
b = Decimal.new "23.34"
c = a / b
# => Decimal.new 45.67
/ : Decimal -> Decimal -> Decimal
/ : Decimal -> Decimal
/ self (that : Decimal) = self.divide that

## GROUP Operators
ICON operators
Compute the negation of this.

> Example
Expand Down Expand Up @@ -567,6 +573,7 @@ attach_loss_of_numeric_precision : Float -> Any -> Any
attach_loss_of_numeric_precision f value =
Warning.attach (Loss_Of_Numeric_Precision.Warning f f) value

## PRIVATE
handle_java_exception ~action =
Panic.catch ArithmeticException action caught_panic->
Error.throw (Arithmetic_Error.Error caught_panic.payload.getMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ type Filter_Condition
will likely be faster than using the vector directly.
Is_In values:Vector|Any action:Filter_Action=Filter_Action.Keep

## Converts a `Filter_Condition` condition into a predicate taking an
## ICON convert
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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Interval_Type
## A type representing an interval over real numbers.
type Interval
## GROUP DateTime
ICON date_and_time
Creates an interval.

Arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ from project.Metadata.Widget import Single_Choice
type Json
## ALIAS from text
GROUP Conversions
ICON convert

Parse a Text value into a `JS_Object` or an Enso primitive value (like
`Text`, `Number`, `Boolean`, `Nothing`), or a `Vector` of values.
Expand Down
Loading

0 comments on commit 7098c5e

Please sign in to comment.