Skip to content

Bad error message for incorrect pattern synonym signature

Consider the following program

{-# LANGUAGE PatternSynonyms #-}

pattern Pat :: () => Show a => a -> Maybe a
pattern Pat a = Just a

GHC complains that

test.hs:4:9: No instance for (Show a) arising from a pattern

I think this is quite difficult to understand. The problem is that matching on Just a doesn't provide the show constraint (it provides no constraints). A better error message here would explain this fact and maybe a short explanation of the difference between prov/req in a pattern synonym signature.

Edited by Matthew Pickering
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information