[Haskell-cafe] Wincomplete-uni-patterns and bidirectional patterns

Olaf Klinke olf at aatal-apotheke.de
Mon Jan 15 11:00:16 UTC 2024


Dear Cafe,

I have a data type with a bidirectional pattern

{-# LANGUAGE PatternSynonyms #-}
newtype T f t = C (f Double)
pattern T :: Double -> T Identity t
pattern T x = C (Identity x)

Note that pattern T is the only way to construct something of type (T
Identity t) for any phantom parameter t. When using the pattern to
match in a where clause, the Wincomplete-uni-pattern warns me about
non-exhaustive pattern matches that are in fact matched:

f a = x where
  T x = g a :: T Identity ()

warning: [-Wincomplete-uni-patterns] Pattern match(es) are non-
exhaustive in a pattern binding: Patterns not matched: 
C (Identity _)

Minimal complete example is attached. 
How can I teach GHC 9 that the pattern is indeed exhaustive? GHC seems
to have only three issues involving incomplete-uni-patterns, only one
of them open, none of which matches my observations.

Thanks
Olaf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pattern.hs
Type: text/x-haskell
Size: 361 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20240115/72fa3633/attachment.hs>


More information about the Haskell-Cafe mailing list