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

Renaming instance method right-hand sides is probably not right (add tests) #1

Open
osa1 opened this issue Dec 22, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@osa1
Copy link
Owner

osa1 commented Dec 22, 2023

When renaming we want to give class methods and the methods in the instances different ids. Example:

class Functor f where
  fmap :: ...                    -- (1)

instance Functor Maybe where
  fmap = ...                     -- (2)

f x y z = ... fmap ...           -- (3)

Here the fmaps in (1) and (3) should have the same id, but (2) should have a different id.

This is to be able to type check (2) against a different type than the fmap in (1). Type of (1) is Functor f => (a -> b) -> f a -> f b, while type of (2) is (a -> b) -> Maybe a -> Maybe b.

This much should be working fine and we have some tests. However the right-hand sides of instance methods are probably not renamed correctly. For example:

class Show a where
  show :: a -> String                                   -- (1)

instance Show a => Show [a] where
  show l = "[" ++ intercalate "," (map show l) ++ "]"   -- (2)

Here I think the show in the right-hand side will have the id (2), but it should have the id (1) otherwise we can't type check map show l.

We should start by adding a test.

@osa1 osa1 added the bug Something isn't working label Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant