[GHC] #12240: Common Sense for Type Classes
GHC
ghc-devs at haskell.org
Wed Jun 29 02:55:09 UTC 2016
#12240: Common Sense for Type Classes
-------------------------------------+-------------------------------------
Reporter: Mathnerd314 | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by ezyang):
If you want refinement of this type to occur, you need to use a functional
dependency, ala:
{{{
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
module T4921 where
class C a b | a -> b where
f :: (a,b)
instance C Int Char where
f = undefined
-- x = fst f
y = fst f :: Int
}}}
Otherwise, a user can legally, WITHOUT `IncoherentInstances`, define
another `instance C Int Int` which would cause the instance resolution to
be ambiguous.
Maybe we can make the error message better though.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12240#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list