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

Use implicit parameters in primitives and opentype format #449

Merged
merged 3 commits into from
Jan 15, 2023

Conversation

brendanzab
Copy link
Member

@brendanzab brendanzab commented Jan 11, 2023

This uses implicit parameters to clean up some functions in the opentype format description, and updates the primitives to make use of implicit parameters.

Comment on lines -19 to +24
} =
fun num_tables table_records table_id => array16_find num_tables (Repr table_record) (fun table_record => table_record.table_id == table_id) table_records;
} = fun @num_tables table_records table_id => array16_find @num_tables @{
table_id : U32,
checksum : U32,
offset : U32,
length : U32,
} (fun table_record => table_record.table_id == table_id) table_records;
Copy link
Member Author

@brendanzab brendanzab Jan 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this results bloated terms in the elaborated output. I’d imagine that glued evaluation might be able to keep these terms small.

Comment on lines -301 to 303
array16_find _ (Repr table_record)
(fun table_record => table_record.table_id == table_id)
array16_find
(fun (table_record : Repr table_record) => table_record.table_id == table_id)
table_records;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if postponement would help with avoiding the need for a type annotation here? The issue is that we don’t know how to elaborate table_record.table_id without knowing the type of table_record parameter before hand which comes from the table_records argument that is supplied later.

option_fold (Repr table_record) Format {}
option_fold ({} : Format)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to postpone the elaboration of {} and () until later. At the moment we eagerly synthesise them to record literals.

@brendanzab brendanzab force-pushed the implicit-prims branch 2 times, most recently from a438999 to 994483e Compare January 11, 2023 23:21
@brendanzab
Copy link
Member Author

brendanzab commented Jan 12, 2023

This should be ready to merge – but it highlights some areas where our elaboration could be improved.

We were forgetting to take into account the type parameters in the
binary interpreter and the implementation of some of the primitives.
@brendanzab brendanzab merged commit 2f753e1 into yeslogic:main Jan 15, 2023
@brendanzab brendanzab deleted the implicit-prims branch January 15, 2023 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant