[commit: ghc] wip/ttypeable: Binary: More explicit pattern matching (74b9694)
git at git.haskell.org
git at git.haskell.org
Sun Jan 29 20:18:11 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/ttypeable
Link : http://ghc.haskell.org/trac/ghc/changeset/74b9694219324a4ad9ffc1c5ef006a643e250774/ghc
>---------------------------------------------------------------
commit 74b9694219324a4ad9ffc1c5ef006a643e250774
Author: Ben Gamari <ben at smart-cactus.org>
Date: Wed Mar 16 09:40:54 2016 +0100
Binary: More explicit pattern matching
>---------------------------------------------------------------
74b9694219324a4ad9ffc1c5ef006a643e250774
compiler/utils/Binary.hs | 9 ++++++---
libraries/ghci/GHCi/TH/Binary.hs | 9 ++++++---
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs
index a0b002e..e9bac4c 100644
--- a/compiler/utils/Binary.hs
+++ b/compiler/utils/Binary.hs
@@ -604,9 +604,12 @@ getTypeRepX bh = do
1 -> do TypeRepX f <- getTypeRepX bh
TypeRepX x <- getTypeRepX bh
case typeRepKind f of
- TRFun arg _ | Just HRefl <- arg `eqTypeRep` x ->
- pure $ TypeRepX $ mkTrApp f x
- _ -> fail "getTypeRepX: Kind mismatch"
+ TRFun arg _ ->
+ case arg `eqTypeRep` x of
+ Just HRefl ->
+ pure $ TypeRepX $ mkTrApp f x
+ _ -> fail "getTypeRepX: Kind mismatch"
+ _ -> fail "getTypeRepX: Applied non-arrow type"
_ -> 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 73ff12e..9def3c0 100644
--- a/libraries/ghci/GHCi/TH/Binary.hs
+++ b/libraries/ghci/GHCi/TH/Binary.hs
@@ -107,9 +107,12 @@ getTypeRepX = do
1 -> do TypeRepX f <- getTypeRepX
TypeRepX x <- getTypeRepX
case typeRepKind f of
- TRFun arg _ | Just HRefl <- arg `eqTypeRep` x ->
- pure $ TypeRepX $ mkTrApp f x
- _ -> fail "getTypeRepX: Kind mismatch"
+ TRFun arg _ ->
+ case arg `eqTypeRep` x of
+ Just HRefl ->
+ pure $ TypeRepX $ mkTrApp f x
+ _ -> fail "getTypeRepX: Kind mismatch"
+ _ -> fail "getTypeRepX: Applied non-arrow type"
_ -> fail "getTypeRepX: Invalid TypeRepX"
instance Typeable a => Binary (TypeRep (a :: k)) where
More information about the ghc-commits
mailing list