Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

Ryan Scott ryan.gl.scott at gmail.com
Thu Oct 25 14:40:06 UTC 2018


You *can* put `LL` into a COMPLETE set, but under the stipulation that
you specify which type constructor it's monomorphized to. To quote the
wiki page on COMPLETE sets:

    In the case where all the patterns are polymorphic, a user must
provide a type signature but we accept the definition regardless of
the type signature they provide. The type constructor for the whole
set of patterns is the type constructor as specified by the user. If
the user does not provide a type signature then the definition is
rejected as ambiguous.

    This design is a consequence of the design of the pattern match
checker. Complete sets of patterns must be identified relative to a
type. This is a sanity check as users would never be able to match on
all constructors if the set of patterns is inconsistent in this
manner.

In other words, this would work provided that you'd be willing to list
every single instance of `HasSrcSpan` in its own COMPLETE set. It's
tedious, but possible.

Ryan S.
-----
[1] https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms/CompleteSigs#Typing


More information about the ghc-devs mailing list