enso-org / enso

Hybrid visual and textual functional programming.
https://ensoanalytics.com
Apache License 2.0
7.36k stars 324 forks source link

Design: Improve presentation of `Data.list` and integrate it with `Data.read_many` #11312

Open GregoryTravis opened 4 days ago

GregoryTravis commented 4 days ago

We want Data.list to be usable as:

all at the same time.

Possible solutions:

GregoryTravis commented 1 day ago

Addressing this problem more generally, as @jdunkerley puts it: "but its the question of whether everything is a table (Alteryx) or we are a programming language".

We want Data.list to return a Vector of File objects, but also possibly have a richer presentation than the default Vector display, as a special case for input to read_many.

Currently, adding a new visualization is a lot of work, and requires front-end work. We could also allow alternative visualizations in pure Enso, by providing conversions from a more basic type (Vector File) to a more specific one (Table). This would be a more run-time alternative to our current from / to conversions. I don't think this requires engine support, but possibly some GUI work to inspect the available conversions and call them where needed. (Also, possibly to give the user a choice of how to display something.)

type Can_Convert
    ## Arguments
       - value: the underlying value
       - default_type: the default value to display in the GUI
       - other_types: additional conversions that could be applied before display in the GUI
    Value value default_type other_types

    # If the target type is included in `default_type` or `other_type`, perform a `from` conversion
    convert_if_supported self type = ...

# Converts a vector of File to a Table, including additional columns for file metadata (size, last modified time, etc)
vector_file_to_file_table (vec : Vector File) -> Table

vec = Data.list "data/"
Can_Convert.Value vec Vector [[Table, vector_file_to_file_table]]
# Define conversions for any type that might be used as a target type in `Can_Convert`
Vector.from (that : Can_Convert) = that.convert_if_supported Vector
Table.from (that : Can_Convert) = that.convert_if_supported Vector
radeusgd commented 19 hours ago

Currently, adding a new visualization is a lot of work, and requires front-end work.

Could we make it possible to 'inherit' the Table visualization and just override its defaultPreprocessor? This preprocessing function can be used to convert the Vector into a suitable Table.