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

Implicits in Interface Functions cause Typecheck Error #336

Open
fabianhjr opened this issue Apr 29, 2020 · 5 comments
Open

Implicits in Interface Functions cause Typecheck Error #336

fabianhjr opened this issue Apr 29, 2020 · 5 comments

Comments

@fabianhjr
Copy link
Contributor

fabianhjr commented Apr 29, 2020

Steps to Reproduce

module Test

interface Foo a where
  bar : a -> {auto ok: ()} -> a 

Expected Behavior

Typecheck (Like Idris1)

Observed Behavior

1/1: Building Test (Test.idr)
Test.idr:4:3--5:1:While processing left hand side of bar at Test.idr:4:3--5:1:
ok is not a valid implicit argument in bar

Edit: maybe related to #8, however I couldn't change it to a constraint as a workaround since I was restricting the domain of a division to nonzero elements.

@rgrover
Copy link
Contributor

rgrover commented Apr 29, 2020

The following rewrite doesn't give a type error:

module Foo

interface Foo a where
  bar : {auto ok: ()} -> a -> a

perhaps the implicit argument needs to be the first.

@fabianhjr
Copy link
Contributor Author

fabianhjr commented Apr 29, 2020

@rgrover, the issue is that I was working on div/mod and wanted to remove the ring's zero:

div : (n, d: a) -> {auto ok: d `NEQ` Semiring.zero} -> a

(I did check the issue #8 with the constraint workaround suggestion)

@rgrover
Copy link
Contributor

rgrover commented Apr 29, 2020

Could the style in https://github.com/edwinb/Idris2/blob/master/libs/base/Data/Nat.idr#L191 work for you?

@fabianhjr
Copy link
Contributor Author

fabianhjr commented Apr 29, 2020

Well, it would typecheck but so would any usages of div that didn't verify that they weren't dividing by zero. (Or ask for such a proof explicitly when it could attempt to derive it)

@rgrover
Copy link
Contributor

rgrover commented Apr 29, 2020

div : (n, d: a) -> Not (d = Semiring.zero) -> a

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

No branches or pull requests

2 participants