#8563 closed bug (fixed)
Deriving with PolyKinds broken
Reported by: | edsko | Owned by: | nomeata |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Compiler | Version: | 7.7 |
Keywords: | Cc: | ||
Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
Type of failure: | None/Unknown | Test Case: | |
Blocked By: | Blocking: | ||
Related Tickets: | Differential Revisions: |
Description
Compiling
{-# LANGUAGE DeriveDataTypeable, PolyKinds #-} module Tagged where import Data.Typeable import Data.Ix newtype Tagged s b = Tagged { unTagged :: b } deriving ( Eq, Ord, Ix, Bounded, Typeable )
gives
Tagged.hs:8:5: ‛Tagged’ is applied to too many type arguments In an expression type signature: Tagged k s b -> Tagged k s b -> Bool In the expression: GHC.Prim.coerce ((==) :: b -> b -> Bool) :: Tagged k s b -> Tagged k s b -> Bool In an equation for ‛==’: (==) = GHC.Prim.coerce ((==) :: b -> b -> Bool) :: Tagged k s b -> Tagged k s b -> Bool Tagged.hs:8:9: ‛Tagged’ is applied to too many type arguments In an expression type signature: Tagged k s b -> Tagged k s b -> Ordering In the expression: GHC.Prim.coerce (compare :: b -> b -> Ordering) :: Tagged k s b -> Tagged k s b -> Ordering In an equation for ‛compare’: compare = GHC.Prim.coerce (compare :: b -> b -> Ordering) :: Tagged k s b -> Tagged k s b -> Ordering Tagged.hs:8:14: ‛Tagged’ is applied to too many type arguments In an expression type signature: (,) (Tagged k s b) (Tagged k s b) -> [] (Tagged k s b) In the expression: GHC.Prim.coerce (range :: (,) b b -> [] b) :: (,) (Tagged k s b) (Tagged k s b) -> [] (Tagged k s b) In an equation for ‛range’: range = GHC.Prim.coerce (range :: (,) b b -> [] b) :: (,) (Tagged k s b) (Tagged k s b) -> [] (Tagged k s b) Tagged.hs:8:18: ‛Tagged’ is applied to too many type arguments In an expression type signature: Tagged k s b In the expression: GHC.Prim.coerce (minBound :: b) :: Tagged k s b In an equation for ‛minBound’: minBound = GHC.Prim.coerce (minBound :: b) :: Tagged k s b
Change History (8)
comment:1 Changed 20 months ago by nomeata
comment:2 Changed 20 months ago by Joachim Breitner <mail@…>
comment:3 Changed 20 months ago by goldfire
Filter out the kind vars in cls_tys and cls_tvs in gen_Newtype_binds in TcGenDeriv -- I think that should fix it. Let me know if you want me to take a closer look, but it seems like you're on it.
comment:4 Changed 20 months ago by nomeata
- Owner set to nomeata
I’m on it, just put a trace on cls_tys. I’ll let you know if I have problems – thanks.
comment:5 Changed 20 months ago by nomeata
The problem seems to be in toHsType in HsUtils; if I do
to_hs_type (TyConApp tc args) = nlHsTyConApp (getRdrName tc) (map toHsType args') where args' = filter (not . isKind) args
it works. (Which make sense: In Core types, we want kinds; in the user-visible type that toHsType provides us, we don’t want them). Do you agree?
Running validate right now...
comment:6 Changed 20 months ago by Joachim Breitner <mail@…>
comment:7 Changed 20 months ago by nomeata
- Resolution set to fixed
- Status changed from new to closed
Yes, validate went through (and I need a faster machine so that I can go home earlier ;-)).
If you disagree with the fix, let me know.
comment:8 Changed 20 months ago by goldfire
Looks great to me. I agree that toHsType is the right place for this, not in the deriving code.
Thanks for the report, added as T8563 in a even simpler form:
The problems goes away without PolyKinds so it is related to that. Probably the k option to Tagged should not be explicitly given here.