Skip to content

Commit 6af054b

Browse files
authored
Merge pull request #186 from sheaf/wip/typerep-changes
Adapt to changes in TypeRep complete patterns
2 parents 4eb7468 + 48477ba commit 6af054b

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

src/Data/Binary/Class.hs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,6 @@ instance Binary TypeLitSort where
994994
_ -> fail "GHCi.TH.Binary.putTypeLitSort: invalid tag"
995995

996996
putTypeRep :: TypeRep a -> Put
997-
-- Special handling for TYPE, (->), and RuntimeRep due to recursive kind
998-
-- relations.
999-
-- See Note [Mutually recursive representations of primitive types]
1000997
putTypeRep rep -- Handle Type specially since it's so common
1001998
| Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep Type)
1002999
= put (0 :: Word8)
@@ -1008,10 +1005,17 @@ putTypeRep (App f x) = do
10081005
put (2 :: Word8)
10091006
putTypeRep f
10101007
putTypeRep x
1008+
#if __GLASGOW_HASKELL__ < 903
1009+
-- N.B. This pattern never matches,
1010+
-- even on versions of GHC older than 9.3:
1011+
-- a `Fun` typerep will match with the `App` pattern.
1012+
-- This match is kept solely for pattern-match warnings,
1013+
-- which are incorrect on GHC prior to 9.3.
10111014
putTypeRep (Fun arg res) = do
10121015
put (3 :: Word8)
10131016
putTypeRep arg
10141017
putTypeRep res
1018+
#endif
10151019

10161020
getSomeTypeRep :: Get SomeTypeRep
10171021
getSomeTypeRep = do
@@ -1039,14 +1043,6 @@ getSomeTypeRep = do
10391043
[ "Applied type: " ++ show f
10401044
, "To argument: " ++ show x
10411045
]
1042-
3 -> do SomeTypeRep arg <- getSomeTypeRep
1043-
SomeTypeRep res <- getSomeTypeRep
1044-
case typeRepKind arg `eqTypeRep` (typeRep :: TypeRep Type) of
1045-
Just HRefl ->
1046-
case typeRepKind res `eqTypeRep` (typeRep :: TypeRep Type) of
1047-
Just HRefl -> return $ SomeTypeRep $ Fun arg res
1048-
Nothing -> failure "Kind mismatch" []
1049-
Nothing -> failure "Kind mismatch" []
10501046
_ -> failure "Invalid SomeTypeRep" []
10511047
where
10521048
failure description info =

0 commit comments

Comments
 (0)