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,334
    • Issues 4,334
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 370
    • Merge Requests 370
  • 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
  • #19106

Closed
Open
Opened Dec 22, 2020 by Richard Eisenberg@raeDeveloper

Partial type signature variable confuses instance solving

When I say

{-# LANGUAGE TypeFamilies, GADTs #-}

module Bug where

f :: (a ~ [b]) => T a -> _ -> String
f (MkT x) _ = show x

data T a where
  MkT :: G a => a -> T a

type family G a where
  G [b] = Show b

I get

Bug.hs:6:1: error:
    • Could not deduce (Show b)
      from the context: a ~ [b]
        bound by the inferred type for ‘f’:
                   forall a b {w}. (a ~ [b]) => T a -> w -> String
        at Bug.hs:6:1-20
    • When checking that the inferred type
        f :: forall {a} {b} {w}. (a ~ [b], Show [b]) => T a -> w -> String
      is as general as its (partial) signature
        f :: forall a b {w}. (a ~ [b]) => T a -> w -> String

We end up with

[G] Show b[tyv:1]
[W] Show [b[tyv:1]]

The check in matchableGivens considers b a meta-variable. This isn't entirely wrong, but b is a TyVarTv, and should not be considered unifiable in matchableGivens. The solution is very easy: just change matchableGivens to treat TyVarTvs like skolems.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#19106