|
9 | 9 | {-# LANGUAGE PolyKinds #-} |
10 | 10 | #endif |
11 | 11 |
|
| 12 | +#if MIN_VERSION_base(4,10,0) |
| 13 | +{-# LANGUAGE MultiWayIf #-} |
| 14 | +#endif |
| 15 | + |
12 | 16 | #if MIN_VERSION_base(4,8,0) |
13 | 17 | #define HAS_NATURAL |
14 | 18 | #define HAS_VOID |
@@ -77,7 +81,7 @@ import Data.List (unfoldr, foldl') |
77 | 81 | import Type.Reflection |
78 | 82 | import Type.Reflection.Unsafe |
79 | 83 | import Data.Kind (Type) |
80 | | -import GHC.Exts (RuntimeRep(..), VecCount, VecElem) |
| 84 | +import GHC.Exts (TYPE, RuntimeRep(..), VecCount, VecElem) |
81 | 85 | #endif |
82 | 86 | import qualified Data.ByteString as B |
83 | 87 | #if MIN_VERSION_bytestring(0,10,4) |
@@ -981,14 +985,18 @@ getSomeTypeRep = do |
981 | 985 | ] |
982 | 986 | 3 -> do SomeTypeRep arg <- getSomeTypeRep |
983 | 987 | SomeTypeRep res <- getSomeTypeRep |
984 | | - case typeRepKind arg `eqTypeRep` (typeRep :: TypeRep Type) of |
985 | | - Just HRefl -> |
986 | | - case typeRepKind res `eqTypeRep` (typeRep :: TypeRep Type) of |
987 | | - Just HRefl -> return $ SomeTypeRep $ Fun arg res |
988 | | - Nothing -> failure "Kind mismatch" [] |
989 | | - Nothing -> failure "Kind mismatch" [] |
| 988 | + if |
| 989 | + | App argkcon _ <- typeRepKind arg |
| 990 | + , App reskcon _ <- typeRepKind res |
| 991 | + , Just HRefl <- argkcon `eqTypeRep` tYPErep |
| 992 | + , Just HRefl <- reskcon `eqTypeRep` tYPErep |
| 993 | + -> return $ SomeTypeRep $ Fun arg res |
| 994 | + | otherwise -> failure "Kind mismatch" [] |
990 | 995 | _ -> failure "Invalid SomeTypeRep" [] |
991 | 996 | where |
| 997 | + tYPErep :: TypeRep TYPE |
| 998 | + tYPErep = typeRep |
| 999 | + |
992 | 1000 | failure description info = |
993 | 1001 | fail $ unlines $ [ "GHCi.TH.Binary.getSomeTypeRep: "++description ] |
994 | 1002 | ++ map (" "++) info |
|
0 commit comments