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

Implementations for unrestricted functions are considered valid for linear functions #743

Closed
aDifferentJT opened this issue Oct 14, 2020 · 1 comment

Comments

@aDifferentJT
Copy link
Contributor

aDifferentJT commented Oct 14, 2020

While this works for interfaces like:

interface Iface a where
  f : a -> ()
  g : (() -> a) -> ()
  h : ((a -> ()) -> ()) -> ()

the following code should not compile:

interface Iface a where
  create : a

Iface (a -> (a, a)) where
  create x = (x, x)

dup' : (1 _ : a) -> (a, a)
dup' = create

This is basically the problem of variance, if we consider linear functions a subtype of unrestricted functions then some interfaces are covariant, some contravariant and some invariant, though I'd rather not drag that in, instead I suggest we just make these incompatible.

@mb64
Copy link
Contributor

mb64 commented Jan 14, 2021

This is fixed by #879. The compiler now says:

Error: While processing right hand side of dup'. Can't find an implementation for Iface ((1 _ : a) -> (a, a)).

test.idr:8:8--8:14
   |
 8 | dup' = create
   |        ^^^^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants