[commit: ghc] wip/ttypeable: Fix serialization (cd17075)
git at git.haskell.org
git at git.haskell.org
Sat Oct 1 21:33:52 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/ttypeable
Link : http://ghc.haskell.org/trac/ghc/changeset/cd170751dce19005082e4497168101ccaa3f7d23/ghc
>---------------------------------------------------------------
commit cd170751dce19005082e4497168101ccaa3f7d23
Author: Ben Gamari <ben at smart-cactus.org>
Date: Fri Mar 11 19:23:16 2016 +0100
Fix serialization
>---------------------------------------------------------------
cd170751dce19005082e4497168101ccaa3f7d23
compiler/utils/Binary.hs | 12 +++++++-----
libraries/ghci/GHCi/TH/Binary.hs | 14 ++++++++------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs
index 92997b9..dadca68 100644
--- a/compiler/utils/Binary.hs
+++ b/compiler/utils/Binary.hs
@@ -605,14 +605,16 @@ getTypeRepX bh = do
case tag of
0 -> do con <- get bh
TypeRepX rep_k <- getTypeRepX bh
- Just HRefl <- pure $ eqTypeRep rep_k (typeRep :: TypeRep Type)
- pure $ TypeRepX $ mkTrCon con rep_k
+ case rep_k `eqTypeRep` (typeRep :: TypeRep Type) of
+ Just HRefl -> pure $ TypeRepX $ mkTrCon con rep_k
+ Nothing -> fail "getTypeRepX: Kind mismatch"
+
1 -> do TypeRepX f <- getTypeRepX bh
TypeRepX x <- getTypeRepX bh
case typeRepKind f of
- TRFun arg _ -> do
- Just HRefl <- pure $ eqTypeRep arg x
- pure $ TypeRepX $ mkTrApp f x
+ TRFun arg _ | Just HRefl <- arg `eqTypeRep` x ->
+ pure $ TypeRepX $ mkTrApp f x
+ _ -> fail "getTypeRepX: Kind mismatch"
_ -> fail "Binary: Invalid TypeRepX"
instance Typeable a => Binary (TypeRep (a :: k)) where
diff --git a/libraries/ghci/GHCi/TH/Binary.hs b/libraries/ghci/GHCi/TH/Binary.hs
index 2a8432b..9a4d314 100644
--- a/libraries/ghci/GHCi/TH/Binary.hs
+++ b/libraries/ghci/GHCi/TH/Binary.hs
@@ -98,15 +98,17 @@ getTypeRepX = do
case tag of
0 -> do con <- get :: Get TyCon
TypeRepX rep_k <- getTypeRepX
- Just HRefl <- pure $ eqTypeRep rep_k (typeRep :: TypeRep Type)
- pure $ TypeRepX $ mkTrCon con rep_k
+ case rep_k `eqTypeRep` (typeRep :: TypeRep Type) of
+ Just HRefl -> pure $ TypeRepX $ mkTrCon con rep_k
+ Nothing -> fail "getTypeRepX: Kind mismatch"
+
1 -> do TypeRepX f <- getTypeRepX
TypeRepX x <- getTypeRepX
case typeRepKind f of
- TRFun arg _ -> do
- Just HRefl <- pure $ eqTypeRep arg x
- pure $ TypeRepX $ mkTrApp f x
- _ -> fail "Binary: Invalid TTypeRep"
+ TRFun arg _ | Just HRefl <- arg `eqTypeRep` x ->
+ pure $ TypeRepX $ mkTrApp f x
+ _ -> fail "getTypeRepX: Kind mismatch"
+ _ -> fail "getTypeRepX: Invalid TypeRepX"
instance Typeable a => Binary (TypeRep (a :: k)) where
put = putTypeRep
More information about the ghc-commits
mailing list