Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,390
    • Issues 4,390
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 373
    • Merge Requests 373
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14146

Closed
Open
Opened Aug 22, 2017 by Icelandjack@IcelandjackReporter

Can GHC propose kind restrictions?

This is UX. As my code gets more polykinded I find myself in situations such as these all the more often

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

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

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 g) 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)
Edited Mar 10, 2019 by Icelandjack
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#14146