kolmodin / binary

Efficient, pure binary serialisation using ByteStrings in Haskell.
Other
105 stars 67 forks source link

Adapt to changes in TypeRep complete patterns #186

Closed sheaf closed 2 years ago

sheaf commented 2 years ago

GHC merge request !963 improved the behaviour of the pattern match checker in the presence of COMPLETE annotations. This allows the removal of the Fun pattern from the complete sets Con, App and Con', App in Data.Typeable.Internal, which I expect to be done in GHC 9.4 (so base 4.17).

As a result, we get a pattern match warning in Data.Binary.Class.putTypeRep, which this patch addresses.

To be clear, the pattern was already redundant, it's just that GHC didn't see it because of how the COMPLETE pragmas used to be set up; calling putTypeRep (Fun arg res) already went through through the App branch:

import Data.Binary ( encode )
import Data.ByteString.Lazy ( unpack )
import Type.Reflection ( pattern Fun, typeRep )

> head . unpack . encode $ Fun (typeRep @Int) (typeRep @Int)
2

Which indicates the App branch, and not the Fun branch (which uses the tag 3).

sheaf commented 2 years ago

I believe this is ready to be merged. Companion GHC MR: !6372.