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 371
    • Merge Requests 371
  • 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
  • #19051

Closed
Open
Opened Dec 10, 2020 by sheaf@trac-sheafDeveloper

Allow named wildcards in constraints

{-# LANGUAGE ConstraintKinds       #-}
{-# LANGUAGE NamedWildCards        #-}
{-# LANGUAGE PartialTypeSignatures #-}

module Test where

class C a where
  meth :: a

unnamed :: _ => a
unnamed = meth

named :: _c => a
named = meth

The unnamed version causes no problems, however named causes the following error:

    * Could not deduce: _0
      from the context: _
        bound by the inferred type for `named':
                   forall a (_ :: Constraint). _ => a
        at Test.hs:14:1-12
    * In the ambiguity check for the inferred type for `named'
      To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
      When checking the inferred type
        named :: forall a (_ :: Constraint). _ => a
   |
14 | named = meth
   | ^^^^^^^^^^^^

That is, in this example, _c is not a named wildcard, but is instead universally quantified. So GHC unsurprisingly throws the same error as if we had written

universal :: c => a
universal = meth

I would have expected that the named wildcard _c behave just like the wildcard _, except that it would give me the ability to refer to the inferred constraint at the type-level inside the body of named.

(I came across this while thinking about #19010.)

Edited Dec 10, 2020 by sheaf
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#19051