Better UX for "types with multiple roles" in the IDE #11366
Replies: 10 comments 27 replies
-
|
just throwing ideas out there to start the conversation:
|
Beta Was this translation helpful? Give feedback.
-
|
Giving an approximate library developer / end user spec:
|
Beta Was this translation helpful? Give feedback.
-
|
One of the (not yet properly formulated) use-cases is related to the interoperability between
If there is a |
Beta Was this translation helpful? Give feedback.
-
|
Thank you all for your comments. To demonstrate the desired state, let's consider following Enso module and its behavior in the IDE: from Standard.Base import all
import Standard.Visualization
type R
private V a:Text i:Integer
as_text self = self
as_both self = self
as_int self = self
Text.from (that:R) = that.a
Integer.from (that:R) = that.i
main =
n = R.V "Hi" 3
t1 = n.as_text
b2 = n.as_both
i3 = n.as_intfirst of all, there are some obvious problems in the current IDE:
but at the end I managed to negotiate and settle with the IDE on: from Standard.Base import all
import Standard.Visualization
type R
private V a:Text i:Integer
as_text self = self:Text
as_int_text self =
r = (self : Integer & Text)
r
as_text_int self =
r = (self : Text & Integer)
r
as_int self = self:Integer
Text.from (that:R) = that.a
Integer.from (that:R) = that.i
main =
n = R.V "Hi" 3
t1 = n.as_text
b2 = n.as_int_text
i3 = n.as_int
node1 = n.as_text_intwith that code we can see that however |
Beta Was this translation helpful? Give feedback.
-
June 2025 Reality Check
Value Cast to Three Intersection Types
Narrow Typed Checked Value
GUI State
|
Beta Was this translation helpful? Give feedback.
-
|
Adding an explicit cast to 'unhide' the |
Beta Was this translation helpful? Give feedback.
-
IDE (not user) to Search for ConversionsI've just tried to type mul into component browser for That's a bad UX. There is multiply on I really wish the specification
is implemented one day! @jdunkerley, @AdRiley, @farmaazon |
Beta Was this translation helpful? Give feedback.
-
|
Originally the description of this discussion talked about type classes. However over time it turns out the main focus is on intersection types. Thus I am removing the original text from the discussion description... |
Beta Was this translation helpful? Give feedback.
-
Conversion Checks for Arguments@jdunkerley would like the following to work: from Standard.Base import all
from Standard.Table import all
import Standard.Visualization
main =
file1 = Table.new [["A", [1]]]
column1 = file1.at 'A'
table1 = file1.take (..First column1)right now it fails with but it is important from the business perspective for this code to work when designed visually in the IDE. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.










Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
TL;DR
The solution to the below listed use-cases is going to be built around values with intersection types and conversions. Such multi values are already present in the Enso runtime and it is just needed to expose them to the IDE properly. With proper information about intersection types of a value at hand and with already provided database of from conversions, the IDE shall be capable to handle all the use-cases.
Seeing All Conversion is possible as they are all listed in the suggestion DB. Preferred Conversions are those that are re-exported via library
Main- e.g. those that get imported byfrom Standard.Xyz import all- those are automatically offered to the user by exposing methods on the target types directly in the component browser (of course with some level of Auto-Domination) - more complicated conversions need to be explicitly imported before being used - IDE has to insert appropriateimportstatement when user selects (either as argument ofAny.tomethod or by other means) such a conversion.Treat
ColumnorVectoras aTableis possible because there will be preferred conversions offering such simple metamorphosis. Treat single columnTableas aColumnwill be handled at creation time by creating multi value representing both types at once - e.g. table as well as column. IDE uses the list of all types participating in value's intersection type to compose list of suitable methods to be displayed in the component browser.Remaining tasks
(multi_value : Table) : Columnto succeed #11482Todo: IDE Support
Any.toconversion targets. #10571Use-Cases
Treat
ColumnorVectoras aTableThere is a simple conversion from a
ColumntoTableand there is a simple conversions of aVectorto (unnamed)Column. Can the IDE's component browser display methods of aTablewhen one is working withColumnorVectorobject?Treat single column
Tableas aColumnWhen there is a
Tableobject with a singleColumnit makes sense to treat it as both: as aTableand as (the single)Column. Can the IDE's component browser display methods of aTableandColumnin such a case? Can we prevent methods from aColumnto be displayed in the component browser, when a table has zero or more than one column?Possible solution: described here.
Preferred Conversions
Currently there is one type class adhering to the blueprint:
Comparable. A lot of classes is convertible to Comparable. However it may not be wise to showComparablemethods to the user as theComparable.fromconversion may not be that important.We need a way to specify which conversions should be included by default and to control what (methods from possible conversions) appears in the component browser.
Auto-Domination
The functions from the type classes that a value can be converted to should appear in the component browser in the normal way. When the instance has a method already with the same name that dominates (and only instance one should be shown).
Seeing All Conversion
By default the component browser shows only preferred conversion (see above). However there should be a way to see all the possible conversions.
Possible solution: there is method
Any.toavailable on every object. When selected, the drop down widget shall offer all the conversions. However probably sorted by preference.Displaying Conversions
The IDE should identify to the user that a conversion (e.g. a cast like
op1 : Table) may be needed to invoke certain method. The IDE should identify to the user that a conversion is taking place in the code graph - either explicitly or implicitly. There should be a way to analyze/navigate to the actual conversion that's taken a place.Beta Was this translation helpful? Give feedback.
All reactions