[GHC] #14146: Can GHC propose kind restrictions?
GHC
ghc-devs at haskell.org
Tue Aug 22 23:43:46 UTC 2017
#14146: Can GHC propose kind restrictions?
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: (none)
Type: feature | Status: new
request |
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.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:
-------------------------------------+-------------------------------------
This is UX. As my code gets more polykinded I find myself in situations
such as these all the more often
{{{#!hs
instance (Comonad f, Representable f, Comonad g, Representable g) =>
Comonad (Compose f g) where
extract = undefined
duplicate = undefined
instance ComonadApply (Compose f g) where
(<@>) = undefined
}}}
{{{
/tmp/a.hs:20:10-35: error:
• No instance for (Comonad (Compose f g))
arising from the superclasses of an instance declaration
• In the instance declaration for ‘ComonadApply (Compose f g)’
|
20 | instance ComonadApply (Compose f g) where
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, modules loaded: none.
}}}
It would help me if GHC looked up a `Comonad (Compose _ _)` instance,
compared the kinds
{{{#!hs
Comonad (Compose (f :: Type -> Type) (g :: Type -> Type) :: Type ->
Type)
ComonadApply (Compose (f :: k -> Type) (g :: Type -> k) :: Type ->
Type)
}}}
a simple suggestion like this would be helpful
{{{
• No instance for (Comonad (Compose f g))
arising from the superclasses of an instance declaration
Try adding a kind signature (ComonadApply (Compose (f :: Type ->
Type) g)).
}}}
Even more amazing would be
{{{
• No instance for (Comonad (Compose f g))
arising from the superclasses of an instance declaration
Try adding a context
(Comonad f, Representable f, Comonad g, Representable g)
=> ComonadApply (Compose f g)
}}}
Which the compiler could in theory guess, since following GHC's suggestion
iteratively you end up with
{{{#!hs
ComonadApply (Compose (f :: Type -> Type) g)
-- ==> add (Comonad f) to the context of the instance declaration
Comonad f => ComonadApply (Compose f g)
-- ==> add (Comonad g) to the context of the instance declaration
(Comonad f, Comonad g) => ComonadApply (Compose f g)
-- ==> add (Representable f) to the context of the instance declaration
(Comonad f, Comonad g, Representable g) => ComonadApply (Compose f g)
-- ==> add (Representable f) to the context of the instance declaration
(Comonad f, Comonad g, Representable g, Representable f) => ComonadApply
(Compose f g)
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14146>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list