Wincomplete-uni-patterns and bidirectional patterns

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

On Mon, Jan 15, 2024 at 12:00:16PM +0100, Olaf Klinke wrote:
How can I teach GHC 9 that the pattern is indeed exhaustive?
Have you tried COMPLETE pragmas? https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/pragmas.html#complet... Tom

Richard Eisenberg has videos on pattern synonyms where he adds a COMPLETE pragma to teach GHC that he is performing exhaustive/complete pattern matches, https://www.youtube.com/watch?v=SPC_R5nwFqo&t=397s. On Mon, Jan 15, 2024 at 7:09 AM Tom Ellis < tom-lists-haskell-cafe-2023@jaguarpaw.co.uk> wrote:
On Mon, Jan 15, 2024 at 12:00:16PM +0100, Olaf Klinke wrote:
How can I teach GHC 9 that the pattern is indeed exhaustive?
Have you tried COMPLETE pragmas?
https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/pragmas.html#complet...
Tom _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (3)
-
Jesse Rudel
-
Olaf Klinke
-
Tom Ellis