Skip to content

Adapt to changes in TypeRep complete patterns#186

Merged
bgamari merged 1 commit intohaskell:masterfrom
sheaf:wip/typerep-changes
Mar 30, 2022
Merged

Adapt to changes in TypeRep complete patterns#186
bgamari merged 1 commit intohaskell:masterfrom
sheaf:wip/typerep-changes

Conversation

@sheaf
Copy link
Copy Markdown
Contributor

@sheaf sheaf commented Aug 13, 2021

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 sheaf force-pushed the wip/typerep-changes branch 3 times, most recently from 5052209 to d0e9641 Compare August 18, 2021 10:36
GHC merge request !963 improved warnings in the presence of
COMPLETE annotations. This allows the removal of the Fun pattern
from the complete set.

This patch accounts for the resulting changes in pattern match warnings.
@sheaf sheaf force-pushed the wip/typerep-changes branch from d0e9641 to 48477ba Compare August 18, 2021 11:53
@sheaf
Copy link
Copy Markdown
Contributor Author

sheaf commented Aug 18, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants