-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement conversions (#180312665) #3227
Conversation
start wip branch for conversion methods for collaborating with marcin add conversions to MethodDispatchLibrary (wip) start MethodDispatchLibrary implementations conversions for atoms and functions Implement a bunch of missing conversion lookups final bug fixes for merged methoddispatchlibrary implementations UnresolvedConversion.resolveFor progress on invokeConversion start extracting constructors (still not working) fix a bug add some initial conversion tests fix a bug in qualified name resolution, test conversions accross modules implement error reporting, discover a ton of ignored errors... start fixing errors that we exposed in the standard library fix remaining standard lib type errors not caused by the inability to parse type signatures for operators TODO: fix type signatures for operators. all of them are broken fix type signature parsing for operators test cases for meta & polyglot play nice with polyglot start pretending unresolved conversions are unresolved symbols treat UnresolvedConversons as UnresolvedSymbols in enso user land
RELEASES.md
Outdated
## Interpreter/Runtime | ||
|
||
- Added support for overloaded conversions. This allows the `from` method to | ||
be implemented with several overloads. ([#3227](https://github.com/enso-org/enso/pull/3227)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, we are aiming to have a single changelog and currently the one to use is at app/gui/CHANGELOG.md
. cc: @mwu-tow please correct me if I'm wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to put this in the right place. I was just reacting to a red checkmark in the build process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, app/gui/CHANGELOG.md
is the location currently enforced by the CI. It'll be moved to the repository root,
@ekmett please update the docs. I don't see that the new syntax of conversion functions is described anywhere (presumably it should go to the |
Also, do you plan to support the complex types? i.e. the case type Maybe
type Some value
type Nothing
Maybe.from (that : Any) = Some that |
The direction you gave in your @wdanilo and @kustosz want to make "proper" sum types, but that starts to expose all sorts of infelicities in the type system (or lack thereof as the case may be). With those in hand, we'd be able to define the other direction where you have
Doing that today will fail because the maybe Atom is never constructed. You should be able to use
as a workaround for the lack of first class sum types today. Having conversions adds a lot of pressure to make those things real. |
Moreover, thinking about this example has made me realize that we probably have a bug in the current code for methods desugaring. Thing is, in
Will desugar to:
A glance at the code tells me this is actually the case.
|
Ugh. It is even worse than I feared. |
There are some failing tests in the last CI run: https://github.com/enso-org/enso/runs/4819644988?check_suite_focus=true You can use
|
The errors for |
…sts that aren't ExpressionUpdates vs. ExecutionUpdate behavioral changes
Builtins module produces syntax errors, which messes up the expected messages in runtime tests. I guess, since the Builtins module is synthetic, we can ignore errors and warnings that it is producing. I'll push a comment to this branch that filters out unwanted diagnostic messages. |
No no no, it is quite important for Builtins to still compile. I'm going to fix it instead :) |
@kustosz feel free to revert my commit then |
Do we have any remaining blockers? |
Pull Request Description
Data analysts should be provided with a unified way to convert between data structures (
from
method)Important Notes
This was slightly harder than expected.
Implemented a notion of an
UnresolvedConversion
.This allows the user to write
In addition to handling atoms and atom constructors properly we also handle Text (both foreign and domestic), functions, arrays and all the other built-in types of the language.
The format of a conversion is required to be
the name of the first parameter must be
that
or_
, and all other arguments must be defaulted.Overloading is used to resolve the dispatch of the
from
method.Overloads resolve from the most specific type of
that
to the least.An incidental issue had to be fixed along the way:
All type level errors were being swallowed by the compiler. Notably, operator methods could not be typed, but the error for this was being swallowed silently by the compiler.
UnresolvedConversion
s are exposed to users like any otherUnresolvedSymbol
s in theMeta
API. The user should see no difference (other than the dynamic overloading behavior).Extension conversions can be defined in imported modules just like extension methods.
Documentation should be supplied as we update the standard library to use this feature.
Checklist
Please include the following checklist in your PR: