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

[RFC FS-1071] Witnesses passing for trait-constraints w.r.t. quotations #6345

Closed
wants to merge 114 commits into from

Conversation

dsyme
Copy link
Contributor

@dsyme dsyme commented Mar 20, 2019

Implementation for RFC FS-1071 - Witness passing for quotations using SRTP-constrained functions and methods

F# quotations of code using SRTP constraint trait calls don't contain sufficient information to represent the semantic intent of the code. Specifically the quotations are missing any record of the resolution of SRTP constraints or how to execute constraint calls.

This RFC addresses this problem by incorporating the necessary information into both quotations and the code laid down for dynamic interpretation of quotations.

TODO

@dsyme
Copy link
Contributor Author

dsyme commented Mar 20, 2019

@cartermp @KevinRansom @TIHan One specific motivation for fixing this core problem with quotations is the need to use quotations more heavily in any future evolution of the "F# for AI models" prototype I've been involved in.

@TIHan
Copy link
Contributor

TIHan commented Mar 20, 2019

What does the term "witness" mean in this case?

@dsyme
Copy link
Contributor Author

dsyme commented Mar 20, 2019

What does the term "witness" mean in this case?

A witness is the lambda term that represents the solution to an SRTP constraint. For example, if you use + in generic inline math code, then there will be an extra hidden parameter in the compiled form of that generic code. You will a type-specialized lambda passed as that argument at callsites where the generic function is called at a non-generic, specific type, e.g.

  • You will see (fun (a: double) (b: double) -> a + b) passed in at the place where the code is specialized at type double.

  • You will see (fun (a: TimeSpan) (b: TimeSpan) -> TimeSpan.op_Addition(a,b)) passed in at the place where the code is specialized at type TimeSpan.

Because this is only about quotations, you only actually see these witnesses by matching on the quotation using the new CallWithWitnesses active pattern when processing the quotation.

Each witness effectively records the resolution/implementation of a trait constraint in quotations and/or compiled code.

(note passing implicit witnesses is the standard technique for implementing Haskell type classes)

@dsyme dsyme removed the Needs-RFC label Mar 22, 2019
@dsyme dsyme changed the title [RFC needed] Witnesses passing for trait-constraints w.r.t. quotations [FS-1071] Witnesses passing for trait-constraints w.r.t. quotations Mar 22, 2019
@dsyme dsyme changed the title [FS-1071] Witnesses passing for trait-constraints w.r.t. quotations [RFC FS-1071] Witnesses passing for trait-constraints w.r.t. quotations Mar 22, 2019
@dsyme
Copy link
Contributor Author

dsyme commented May 22, 2019

Closed in favour of #6810 from feature branch

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.

4 participants