Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,828
    • Issues 4,828
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 446
    • Merge requests 446
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19106

Closed
Open
Created 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.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking