[GHC] #12592: Explicit type signature for type classes fails

#12592: Explicit type signature for type classes fails -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- GHC 8.0.1: Consider the [https://hackage.haskell.org/package/indexed-0.1 indexed classes]: {{{#!hs class IxFunctor f where imap :: (a -> b) -> f j k a -> f j k b class IxFunctor m => IxPointed m where ireturn :: a -> m i i a class IxPointed m => IxApplicative m where iap :: m i j (a -> b) -> m j k a -> m i k b class IxFunctor w => IxCopointed w where iextract :: w i i a -> a class IxApplicative m => IxMonad m where ibind :: (a -> m j k b) -> m i j a -> m i k b class IxMonad m => IxMonadFree f m | m -> f where iwrap :: f i j (m j k a) -> m i k a }}} GHCi gives their kinds: {{{ IxFunctor :: (k -> i -> * -> *) -> Constraint IxPointed :: (k -> k -> * -> *) -> Constraint IxApplicative :: (k -> k -> * -> *) -> Constraint IxCopointed :: (k -> k -> * -> *) -> Constraint IxMonad :: (k -> k -> * -> *) -> Constraint IxMonadFree :: (k -> k -> * -> *) -> (k -> k -> * -> *) -> Constraint }}} so I attempt to make them explicit: {{{#!hs type IxFunct i = i -> i -> Type -> Type class IxFunctor (f :: IxFunct i) where imap :: (a -> b) -> f j k a -> f j k b }}} Works fine, but if I add it to any of the others it fails: {{{#!hs -- tZRa.hs:15:17: error: … -- • Expected kind ‘i’, but ‘i’ has kind ‘*’ -- • In the first argument of ‘w’, namely ‘i’ -- In the type signature: -- iextract :: w i i a -> a -- In the class declaration for ‘IxCopointed’ -- Compilation failed. class IxFunctor w => IxCopointed (w :: IxFunct i) where iextract :: w i i a -> a -- ... class IxMonad m => IxMonadFree (f :: IxFunct i) (m :: IxFunct i) | m -> f where iwrap :: f i j (m j k a) -> m i k a }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12592 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12592: Explicit type signature for type classes fails -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): This is expected behavior. I think the problem is that you're confusing a type with its kind. In the definition for `IxCopointed` above, your kind for w -- `IxFunct i` or `i -> i -> Type -> Type` -- implies that the type of `i` is `i`, which is not what you mean. That is, when you say `w :: IxFunct i`, then the first two arguments to `w` should have ''kind'' `i`, not necessarily ''be'' `i`. Does this clarify? And I don't see a way to improve the error message (beyond the general improvement our error messages would enjoy). If so, please close the ticket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12592#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12592: Explicit type signature for type classes fails -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => invalid Comment: As mentioned in comment:1, this is not a bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12592#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC