Skip to content

pattern synonyms changed semantics from 9.8 to 9.10?

Summary

For a simple program with pattern synonyms, code generated by ghc-9.10.1 (alpha-1) behaves differently (throws exception) than code from ghc-9.8.2 (no exception, which seems correct to me).

Also, the exception's name is confusing (mentions "lambda" but there is none)

I checked 9.10 release notes (file ghc-9.10.0.20240313/docs/users_guide/9.10.1-notes.rst) they did not mention any change w.r.t. semantics of pattern synonyms.

Reproduce

the following (silly) example is minimized from real code

{-# language PatternSynonyms #-}

import Prelude hiding (Maybe, Nothing,Just)
import qualified Prelude as P

data Maybe a = Nothing_  | Just_  a

pattern Nothing :: Maybe a
pattern Nothing <- Nothing_ where Nothing = Nothing_

pattern Just :: a -> Maybe a
pattern Just x <- Just_ x where Just = Just_

main = print $ do Just x <- [Nothing, Just ()] ; return x

Actual Behaviour

$ /opt/ghc/ghc-9.10.0.20240313/bin/runhaskell ps.hs 
ps.hs: ps.hs:14:19-24: Non-exhaustive patterns in lambda

HasCallStack backtrace:
  collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:92:13 in ghc-internal:GHC.Internal.Exception
...

Expected behavior

$ /opt/ghc/ghc-9.8.2/bin/runhaskell ps.hs 
[()]
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information