Skip to content

Feedback on breaking changes in GHC 9.4 (esp `Word64`)

I'm not sure the best place to put this, so I'm just writing it up here.

The GHC 9.4 upgrade had one breaking change in particular that occupied a really large amount of time:

-data {-# CTYPE "HsWord64" #-} Word64 = W64# Word#
+data {-# CTYPE "HsWord64" #-} Word64 = W64# Word64#

Specifically, the type of the constructor W64# went from

-W64# :: Word# -> Word64
+W64# :: Word64# -> Word64

This break resulted in a ton of CPP spread across libraries that want to be compatible.

An alternative design that would have resulted in much less break would be a pattern synonym.

-data {-# CTYPE "HsWord64" #-} Word64 = W64# Word#
+data {-# CTYPE "HsWord64" #-} Word64 = MkW64# Word64#
pattern W64# :: Word# -> Word64 
pattern W64# w <- MkW64# (word64ToWord# -> w) where
  W64# w = MkW64# (wordToWord64# w)

Unless I'm really mistaken, this would have been a drop in replacement, and would have allowed a considerable number of packages to build unchanged with GHC 9.4.

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