#14394 closed bug (fixed)

Inferred type for pattern synonym has redundant equality constraint

Reported by: RyanGlScott Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 8.2.1
Keywords: PatternSynonyms, TypeInType Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: patsyn/should_compile/T14394
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Load this file into GHCi:

{-# LANGUAGE PatternSynonyms #-}
module Bug where

import Data.Type.Equality

pattern Foo = HRefl
$ /opt/ghc/8.2.1/bin/ghci Bug.hs
GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Ok, 1 module loaded.
λ> :i Foo
pattern Foo :: () => (* ~ *, b ~ a) => a :~~: b

Notice that the type signature for Foo has an entirely redundant * ~ * constraint. The same does not happen if TypeInType is enabled.

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeInType #-}
module Works where

import Data.Type.Equality

pattern Foo = HRefl
λ> :i Foo
pattern Foo :: forall k2 k1 (a :: k1) (b :: k2). () => (k2 ~ k1,
                                                        (b :: k2) ~~ (a :: k1)) => a :~~: b

Change History (2)

comment:1 Changed 23 months ago by Simon Peyton Jones <simonpj@…>

In 2c2f3ce/ghc:

Minimise provided dictionaries in pattern synonyms

Trac #14394 showed that it's possible to get redundant
constraints in the inferred provided constraints of a pattern
synonym.  This patch removes the redundancy with mkMinimalBySCs.

To do this I had to generalise the type of mkMinimalBySCs slightly.
And, to reduce confusing reversal, I made it stable: it now returns
its result in the same order as its input.  That led to a raft of
error message wibbles, mostly for the better.

comment:2 Changed 23 months ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: patsyn/should_compile/T14394

Ha! Indeed. Thanks.

Note: See TracTickets for help on using tickets.