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

Better Handling of Duplicate Type Synonym Instances #1

Open
softmechanics opened this issue Apr 6, 2010 · 0 comments
Open

Better Handling of Duplicate Type Synonym Instances #1

softmechanics opened this issue Apr 6, 2010 · 0 comments

Comments

@softmechanics
Copy link
Owner

Consider the following example:
{-# LANGUAGE TypeSynonymInstances, ContextConstraints #-}

type A = Int

class Test a where
  test :: a -> [Char]

instance Test Int where
  test _ = "Int"

instance Test A where
  test _ = "A"       

main = do print $ test (0::Int)
          print $ test (0::A)

The two instances are considered duplicates of each other. ContextConstraints allows them, but always uses the first declared instance (in this case, Test Int). Distinguish between instances for a type and instances for synonyms.

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

1 participant