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

Can't unify an interface with its instance #66

Closed
edwinb opened this issue May 20, 2020 · 2 comments · Fixed by #384
Closed

Can't unify an interface with its instance #66

edwinb opened this issue May 20, 2020 · 2 comments · Fixed by #384

Comments

@edwinb
Copy link
Collaborator

edwinb commented May 20, 2020

Issue by berewt
Monday Apr 27, 2020 at 12:46 GMT
Originally opened as edwinb/Idris2-boot#330


The compiler seems to struggle to unify interfaces with dependent types with their implementation.

Steps to Reproduce

try to compile this module:

module Test

data Dummy : (lbl : Type) -> (st : List lbl) -> Type -> Type where
  MkDummy : a -> Dummy b st a


public export
interface IxPure (f : (lbl : Type) -> (st : List lbl) -> Type -> Type)
          where
  ixPure : a -> f lbl st a

IxPure Dummy where
  ixPure = MkDummy

pure12 : Dummy String xs Integer
pure12 = ixPure $ 12

Fails with:

Expected Behavior

It should compile.

Observed Behavior

It fails with:

Test.idr:16:10--17:1:While processing right hand side of pure12 at Test.idr:16:1--17:1:
Can't find an implementation for IxPure ?f

Workarounds

Specifying explicitly the value of f in pure12 solve the issue:

pure12 : Dummy String xs Integer
pure12 = ixPure {f = Dummy} $ 12

And the problem disappears as well if we remove the st parameters.

melted pushed a commit to melted/Idris2 that referenced this issue Jun 1, 2020
check noprelude option when starting up without loading a file
@edwinb
Copy link
Collaborator Author

edwinb commented Jun 29, 2020

Poking around inside here, the problem is that it can't solve the unification problem ?f ?lbl ?st = Dummy String xs, and telling it any one of f, lbl or st resolves it. It's supposed to notice that f is an argument to an implementation so should be treated as invertible, but somehow it seems that isn't happening...

EDIT: In fact it is happening, but isn't helping. I'll dig further.

@edwinb
Copy link
Collaborator Author

edwinb commented Jun 29, 2020

Ah, it's using the conversion check (which doesn't solve holes) for arguments to invertible holes, not unification, which would resolve the holes lbl and st. I believe I have a fix.

edwinb added a commit to edwinb/Idris2 that referenced this issue Jun 29, 2020
'convert' doesn't solve holes, so might reject things that are solvable.
This can be an issue when resolving interfaces, because we were using
convert for arguments of the invertible holes that arise when trying to
resolve them. Fixes idris-lang#66.
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 a pull request may close this issue.

1 participant