Skip to content

Better Handling of Duplicate Type Synonym Instances #1

@softmechanics

Description

@softmechanics

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions