Skip to content
GitLab
Projects Groups Snippets
  • /
  • 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 5,244
    • Issues 5,244
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 569
    • Merge requests 569
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #20845
Closed
Open
Issue created Dec 20, 2021 by Ashley Yakeley@AshleyYakeleyDeveloper

Cannot satisfy QuantifiedConstraints

Motivation

I cannot satisfy a quantified constraint, even if I can satisfy the constraint for every value of the type variable.

Example:

{-# LANGUAGE QuantifiedConstraints, UndecidableInstances, RankNTypes,
    KindSignatures, TypeApplications, ScopedTypeVariables, GADTs #-}

module QuantifiedConstraints where
import Data.Kind

class IsUnit (a :: Type) where
    isUnit :: forall r. (a ~ () => r) -> r

class C (a :: Type)
instance C ()

-- requires quantified constraint I want to satisfy
f1 :: (forall a. IsUnit a => C a) => Int
f1 = 3

-- can satisfy C for any particular a (that has IsUnit)
f2 :: forall a r. IsUnit a => (C a => r) -> r
f2 cr = isUnit @a cr

f :: Int
f = f2 f1 -- GHC (correctly) rejects this, but no other option

Proposal

Provide some way of satisfying quantified constraints in this manner.

Sorry I don't have a concrete proposal, nor is this strictly a defect in GHC, I just want to raise the issue.

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