summaryrefslogtreecommitdiff
path: root/compiler/utils
diff options
context:
space:
mode:
authorDavid Feuer <david.feuer@gmail.com>2017-11-02 17:30:59 -0400
committerBen Gamari <ben@smart-cactus.org>2017-11-02 20:15:48 -0400
commit19ca2cab4b32ff2eaacb1fb3502849ad762af0e1 (patch)
treefc097e4cabd0a21e3f710df49c8b625ad9527ad5 /compiler/utils
parent3c8e55ce7383e73bbca74b9954560b8555c5c5d4 (diff)
downloadhaskell-19ca2cab4b32ff2eaacb1fb3502849ad762af0e1.tar.gz
Deserialize all function TypeReps
Previously, we could only deserialize `TypeRep (a -> b)` if both `a` and `b` had kind `Type`. Now, we do it regardless of their runtime representations. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4137
Diffstat (limited to 'compiler/utils')
-rw-r--r--compiler/utils/Binary.hs19
1 files changed, 12 insertions, 7 deletions
diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs
index 1c0284a332..a7bbfd51ad 100644
--- a/compiler/utils/Binary.hs
+++ b/compiler/utils/Binary.hs
@@ -3,6 +3,7 @@
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE GADTs #-}
+{-# LANGUAGE MultiWayIf #-}
{-# OPTIONS_GHC -O -funbox-strict-fields #-}
-- We always optimise this, otherwise performance of a non-optimised
@@ -82,7 +83,7 @@ import Data.Time
import Type.Reflection
import Type.Reflection.Unsafe
import Data.Kind (Type)
-import GHC.Exts (RuntimeRep(..), VecCount(..), VecElem(..))
+import GHC.Exts (TYPE, RuntimeRep(..), VecCount(..), VecElem(..))
#else
import Data.Typeable
#endif
@@ -748,14 +749,18 @@ getSomeTypeRep bh = do
]
3 -> do SomeTypeRep arg <- getSomeTypeRep bh
SomeTypeRep res <- getSomeTypeRep bh
- case typeRepKind arg `eqTypeRep` (typeRep :: TypeRep Type) of
- Just HRefl ->
- case typeRepKind res `eqTypeRep` (typeRep :: TypeRep Type) of
- Just HRefl -> return $ SomeTypeRep $ Fun arg res
- Nothing -> failure "Kind mismatch" []
- _ -> failure "Kind mismatch" []
+ if
+ | App argkcon _ <- typeRepKind arg
+ , App reskcon _ <- typeRepKind res
+ , Just HRefl <- argkcon `eqTypeRep` tYPErep
+ , Just HRefl <- reskcon `eqTypeRep` tYPErep
+ -> return $ SomeTypeRep $ Fun arg res
+ | otherwise -> failure "Kind mismatch" []
_ -> failure "Invalid SomeTypeRep" []
where
+ tYPErep :: TypeRep TYPE
+ tYPErep = typeRep
+
failure description info =
fail $ unlines $ [ "Binary.getSomeTypeRep: "++description ]
++ map (" "++) info