Skip to content
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

Do not filter implicit args in internal to core translation #1728

Merged
merged 2 commits into from
Jan 16, 2023

Conversation

paulcadman
Copy link
Collaborator

@paulcadman paulcadman commented Jan 16, 2023

The internal to core translation was removing implicit arguments from function definitions and applications. This is incorrect as the implicit bindings are required when translating the following (in csuc, the binding of the implicit argument is required in an application on the rhs):

Num : Type;
Num := {A : Type} → (A → A) → A → A;

csuc : Num → Num;
csuc n {_} f := f ∘ n {_} f;

Apart from removing this filter from function and application translation, this required the following changes:

ConstructorInfo:
The _constructorArgsNum field must include the number of type parameters of its inductive type.

PatternConstructorApp:
The pattern arguments must include wildcards for the implicit type parameters passed to the constructor.

BuiltinIf:
The BuiltinIf expression is passed an implicit type argument that must be removed when translating to Core if.

LitString:
A literal string is a function with an implcit type argument. So this must be a translated to a lambda where the type argument is ignored.

@paulcadman paulcadman added this to the 0.2.9 milestone Jan 16, 2023
@paulcadman paulcadman self-assigned this Jan 16, 2023
@janmasrovira janmasrovira self-requested a review January 16, 2023 09:04
Base automatically changed from lambda-index-fix to main January 16, 2023 11:13
Apart from removing this filter from function and application
translation, this required the following changes:

ConstructorInfo:
The _constructorArgsNum field must include the number of type parameters
of its inductive type.

PatternConstructorApp:
The pattern arguments must include wildcards for the implicit type
parameters passed to the constructor.

BuiltinIf:
The BuiltinIf expression is passed an implicit type argument that must
be removed when translating to Core if.

LitString:
A literal string is a function with an implcit type argument. So this
must be a translated to a lambda where the type argument is ignored.
janmasrovira
janmasrovira previously approved these changes Jan 16, 2023
src/Juvix/Compiler/Core/Translation/FromInternal.hs Outdated Show resolved Hide resolved
@paulcadman paulcadman merged commit ff748b9 into main Jan 16, 2023
@paulcadman paulcadman deleted the implicit-args-fix branch January 16, 2023 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The translation from Internal to Core doesn't work with type synonyms
3 participants