Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
    • Insights
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 3,631
    • Issues 3,631
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 202
    • Merge Requests 202
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Security & Compliance
    • Security & Compliance
    • Dependency List
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17178

Closed
Open
Opened Sep 11, 2019 by Andrew Martin@andrewthad
  • Report abuse
  • New issue
Report abuse New issue

Levity Polymorphic Pattern Synonyms

GHC currently rejects the following program:

pattern Just# :: forall (r :: RuntimeRep) (a :: TYPE r). a -> (# (# #) | a #)
pattern Just# a = (# | a #)

With this error message (the line number reference is the one where the signature of the pattern synonym is given):

    A levity-polymorphic type is not allowed here:
      Type: a
      Kind: TYPE r
   |
26 | pattern Just# :: forall (r :: RuntimeRep) (a :: TYPE r). a -> (# (# #) | a #)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I would like for GHC to accept this pattern synonym. I think that it should just be possible to remove the levity-polymorphism check from pattern synonym signatures. I don't this can lead to any unsoundness since patterns are just expanded in Core.

Related issues

  • Discussion
  • Designs
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
3
Labels
feature request levity polymorphism PatternSynonyms
Assign labels
  • View project labels
Reference: ghc/ghc#17178