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

Overlapping implementation again #4296

Open
nicolabotta opened this issue Jan 19, 2018 · 2 comments
Open

Overlapping implementation again #4296

nicolabotta opened this issue Jan 19, 2018 · 2 comments

Comments

@nicolabotta
Copy link

The program

> %default total
> %auto_implicits off
> %access public export

> postulate Real    : Type 
> postulate plus    : Real -> Real -> Real
> postulate mult    : Real -> Real -> Real
> postulate fromNat : Nat -> Real

> implementation Num Real where
>   (+) = plus
>   (*) = mult
>   fromInteger = fromNat . fromIntegerNat

fails to type check with

- + Errors (1)
 `-- ./Testing/implementation1.lidr line 10 col 17:
     Overlapping implementation: Num Integer already defined

which seems an Idris error. Most likely related to #4279 but here in a perhaps more obvious form. Why is it still so difficult to use interfaces? Is there something obviously wrong with the example above? Is the error message is perhaps misleading?

@ahmadsalim
Copy link

@nicolabotta This does seem strange indeed. At least the error message is wrong.

I would assume that you can only define interfaces on concrete type constructors, and not postulates.

@nicolabotta
Copy link
Author

@ahmadsalim Defining interfaces in terms of postulated features should be fine as long as these features are not accessed at run time. Notiuce that replacing

> implementation Num Real where

with

> implementation [Lala] Num Real where

makes the code type check. Thus, this seems to be just an Idris bug, not a problem with postulates!

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

2 participants