[commit: ghc] wip/ttypeable: Binary: More explicit pattern matching (2f88acc)

git at git.haskell.org git at git.haskell.org
Wed Apr 13 17:54:47 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/ttypeable
Link       : http://ghc.haskell.org/trac/ghc/changeset/2f88acc723502c0fd858b166ff9f59102bed7171/ghc

>---------------------------------------------------------------

commit 2f88acc723502c0fd858b166ff9f59102bed7171
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Wed Mar 16 09:40:54 2016 +0100

    Binary: More explicit pattern matching


>---------------------------------------------------------------

2f88acc723502c0fd858b166ff9f59102bed7171
 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 fcf9ce7..431b187 100644
--- a/compiler/utils/Binary.hs
+++ b/compiler/utils/Binary.hs
@@ -601,9 +601,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 2433057..522cc80 100644
--- a/libraries/ghci/GHCi/TH/Binary.hs
+++ b/libraries/ghci/GHCi/TH/Binary.hs
@@ -102,9 +102,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