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,243
    • Issues 5,243
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 570
    • Merge requests 570
  • 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
  • #9954
Closed
Open
Issue created Jan 03, 2015 by Gergő Érdi@cactusContributor

Required constraints are not inferred for pattern synonyms involving GADTs

Let's say we have the following setup:

{-# LANGUAGE GADTs, PatternSynonyms, ViewPatterns #-}

data T a where
  MkT1 :: a -> T a
  MkT2 :: a -> T (Maybe a)

f :: (Eq a) => a -> a
f = id

Then the following definition works as expected:

pattern P1 x <- MkT1 (f -> x)

with the following inferred type:

λ» :i P1
pattern P1 :: () => Eq t => t -> T t

However, trying to do the same with {{MkT2}} doesn't work:

pattern P2 x <- MkT2 (f -> x)

this results in

Could not deduce (Eq a1) arising from a use of ‘f’
from the context (t ~ Maybe a1)
  bound by a pattern with constructor
             MkT2 :: forall a. a -> T (Maybe a),
           in a pattern synonym declaration
Trac metadata
Trac field Value
Version
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking