[GHC] #10009: type inference regression when faking injective type families
GHC
ghc-devs at haskell.org
Fri Jan 23 18:05:58 UTC 2015
#10009: type inference regression when faking injective type families
-------------------------------------+-------------------------------------
Reporter: aavogt | Owner:
Type: bug | Status: new
Priority: high | Milestone: 7.10.1
Component: Compiler (Type | Version: 7.10.1-rc1
checker) | Keywords:
Resolution: | Architecture:
Operating System: Unknown/Multiple | Unknown/Multiple
Type of failure: GHC rejects | Test Case:
valid program | Blocking:
Blocked By: | Differential Revisions:
Related Tickets: |
-------------------------------------+-------------------------------------
Comment (by aavogt):
It affects both: the library has a number of definitions that don't
compile with 7.10RC1 right now. It affects how clients can put library
functions together. For example the library defines:
{{{
-- possible type signatures:
-- hUntagSelf :: HList '[Tagged x x, Tagged y y] -> HList '[x,y]
-- hTagSelf :: HList '[x,y] -> HList '[Tagged x x, Tagged y y]
-- hZipTIP :: TIP '[Tagged x x] -> TIP '[Tagged y y]
-- -> TIP '[Tagged (x,y) (x,y)]
hZipTIP (TIP x) (TIP y) = TIP (hTagSelf (hZipList (hUntagSelf x)
(hUntagSelf y)))
}}}
If I figure out where to annotate to get rid of the 7.10RC1 type error:
{{{
Data/HList/TIP.hs:251:1: Warning:
Could not deduce (TagR a0 ~ TagR a)
from the context (HZipList x y a,
TagUntag a,
TagUntag x,
TagUntag y)
bound by the inferred type for ‘hZipTIP’:
(HZipList x y a, TagUntag a, TagUntag x, TagUntag y) =>
TIP (TagR x) -> TIP (TagR y) -> TIP (TagR a)
at Data/HList/TIP.hs:251:1-81
NB: ‘TagR’ is a type function, and may not be injective
The type variable ‘a0’ is ambiguous
Expected type: TIP (TagR x) -> TIP (TagR y) -> TIP (TagR a)
Actual type: TIP (TagR x0) -> TIP (TagR y0) -> TIP (TagR a0)
When checking that ‘hZipTIP’ has the inferred type
hZipTIP :: forall (a :: [*]) (x :: [*]) (y :: [*]).
(HZipList x y a, TagUntag a, TagUntag x, TagUntag y) =>
TIP (TagR x) -> TIP (TagR y) -> TIP (TagR a)
Probable cause: the inferred type is ambiguous
Data/HList/TIP.hs:251:1: Warning:
Could not deduce (HZipList x0 y0 a0)
from the context (HZipList x y a,
TagUntag a,
TagUntag x,
TagUntag y)
bound by the inferred type for ‘hZipTIP’:
(HZipList x y a, TagUntag a, TagUntag x, TagUntag y) =>
TIP (TagR x) -> TIP (TagR y) -> TIP (TagR a)
at Data/HList/TIP.hs:251:1-81
The type variables ‘a0’, ‘x0’, ‘y0’ are ambiguous
When checking that ‘hZipTIP’ has the inferred type
hZipTIP :: forall (a :: [*]) (x :: [*]) (y :: [*]).
(HZipList x y a, TagUntag a, TagUntag x, TagUntag y) =>
TIP (TagR x) -> TIP (TagR y) -> TIP (TagR a)
Probable cause: the inferred type is ambiguous
}}}
clients probably want to define functions like this too, and requiring a
type annotation here probably doubles the amount of code that has to be
written.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10009#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list