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,324
    • Issues 4,324
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 385
    • Merge Requests 385
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9200

Closed
Open
Opened Jun 12, 2014 by Edward Kmett@ekmett

Milner-Mycroft failure at the kind level

This is a reduction of a problem that occurs in real code.

{-# LANGUAGE PolyKinds #-}
class D a => C (f :: k) a
class C () a => D a

Typechecking complains:

    The first argument of ‘C’ should have kind ‘k’,
      but ‘()’ has kind ‘*’
    In the class declaration for ‘D’

This program should be accepted, but we're not generalizing enough.

A slightly less reduced version of the problem arises in practice in:

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PolyKinds #-}

import Control.Category

class (Category c, Category d, Category e) => Profunctor
  (p :: x -> y -> z)
  (c :: x -> x -> *)
  (d :: y -> y -> *)
  (e :: z -> z -> *)
  | p -> c d e

-- lens-style isomorphism families in an arbitrary category
type Iso (c :: i -> i -> *) (s :: i) (a :: i) = forall (p :: i -> i -> *). 
  Profunctor p c c (->) => p a a -> p s s

class Category e => Cartesian (e :: z -> z -> *) where
  type P e :: z -> z -> z
  associate :: Iso e (P e (P e a b) c) (P e a (P e b c))

This typechecks, but if I replace the line

class (Category c, Category d, Category e) => Profunctor

with

class (Category c, Category d, Cartesian e) => Profunctor

to say that you can only enrich a category over a monoidal category (using Cartesian in the approximation here), then it fails because a more baroque version of the same kind of cycle as the minimal example above as Profunctor references Cartesian which references an Iso which mentions a Profunctor.

I'm supplying explicit kind variables in the signature of the class, so we should be able to use those like we do with function signatures a universe down. =/

Trac metadata
Trac field Value
Version 7.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC ekmett
Operating system
Architecture
Assignee
Assign to
7.10.1
Milestone
7.10.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#9200