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

add TH support for nested higher kinded types #2515

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ndwarshuis
Copy link
Contributor

@ndwarshuis ndwarshuis commented Apr 20, 2023

This is a follow up to #2506 for a complicated case I forgot to add.

In the case where an imported type uses another higher kinded type, the current algorithm will compare this inner type after its arguments have already been applied, in which case the search will fail.

Example:

let InnerS = \(x : Type) -> \(y : Type) -> { ifoo : x, ibar : y }

let InnerU = \(x : Type) -> \(y : Type) -> < Ifoo : x | Ibar : y >

let Outer =
      \(i : Type) ->
      \(j : Type) ->
        { ofoo : InnerS i Text, obar : InnerU j Text }

Basic idea is to extend the nested type loop so that when matching a dhall type with an already-cached haskell type, it will store the type parameters for the outer haskell type constructor, gather the dhall types corresponding to the type parameters, recursively find the inner constructors for these nested dhall types, and finally apply the results to the outer type constructor.

@Gabriella439
Copy link
Collaborator

Sorry for taking so long to get to this

I'm a bit reluctant to merge this because (based on my cursory understanding of how this PR works), this is essentially implementing a form of unification (specifically gatherNestedVars) as part of this TemplateHaskell subroutine and I'm not sure I want to commit to maintaining a robust unification algorithm in order to support this feature.

@ndwarshuis
Copy link
Contributor Author

Sorry for taking so long to get to this

no problem :)

I'm not sure I want to commit to maintaining a robust unification algorithm in order to support this feature.

I'm not sure what you mean by this. Can you please elaborate on "unification" and why it would be difficult to maintain long term?

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.

2 participants