X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FTypeable.hs;h=40d07aced4a07d73b9305e07f2a707cdb1ed0ea3;hb=2b88e86142ffbf79dad8596082ec301627a5682c;hp=77d7724415dcf71567db65084b86b64ed8dd2d54;hpb=2f01e7edb15fbb18e16b37dbada770c1b6db1528;p=ghc-base.git diff --git a/Data/Typeable.hs b/Data/Typeable.hs index 77d7724..40d07ac 100644 --- a/Data/Typeable.hs +++ b/Data/Typeable.hs @@ -331,6 +331,7 @@ class Typeable a where class Typeable1 t where typeOf1 :: t a -> TypeRep +#ifdef __GLASGOW_HASKELL__ -- | For defining a 'Typeable' instance from any 'Typeable1' instance. typeOfDefault :: forall t a. (Typeable1 t, Typeable a) => t a -> TypeRep typeOfDefault = \_ -> rep @@ -338,11 +339,20 @@ typeOfDefault = \_ -> rep rep = typeOf1 (undefined :: t a) `mkAppTy` typeOf (undefined :: a) -- Note [Memoising typeOf] +#else +-- | For defining a 'Typeable' instance from any 'Typeable1' instance. +typeOfDefault :: (Typeable1 t, Typeable a) => t a -> TypeRep +typeOfDefault x = typeOf1 x `mkAppTy` typeOf (argType x) + where + argType :: t a -> a + argType = undefined +#endif -- | Variant for binary type constructors class Typeable2 t where typeOf2 :: t a b -> TypeRep +#ifdef __GLASGOW_HASKELL__ -- | For defining a 'Typeable1' instance from any 'Typeable2' instance. typeOf1Default :: forall t a b. (Typeable2 t, Typeable a) => t a b -> TypeRep typeOf1Default = \_ -> rep @@ -350,11 +360,20 @@ typeOf1Default = \_ -> rep rep = typeOf2 (undefined :: t a b) `mkAppTy` typeOf (undefined :: a) -- Note [Memoising typeOf] +#else +-- | For defining a 'Typeable1' instance from any 'Typeable2' instance. +typeOf1Default :: (Typeable2 t, Typeable a) => t a b -> TypeRep +typeOf1Default x = typeOf2 x `mkAppTy` typeOf (argType x) + where + argType :: t a b -> a + argType = undefined +#endif -- | Variant for 3-ary type constructors class Typeable3 t where typeOf3 :: t a b c -> TypeRep +#ifdef __GLASGOW_HASKELL__ -- | For defining a 'Typeable2' instance from any 'Typeable3' instance. typeOf2Default :: forall t a b c. (Typeable3 t, Typeable a) => t a b c -> TypeRep typeOf2Default = \_ -> rep @@ -362,11 +381,20 @@ typeOf2Default = \_ -> rep rep = typeOf3 (undefined :: t a b c) `mkAppTy` typeOf (undefined :: a) -- Note [Memoising typeOf] +#else +-- | For defining a 'Typeable2' instance from any 'Typeable3' instance. +typeOf2Default :: (Typeable3 t, Typeable a) => t a b c -> TypeRep +typeOf2Default x = typeOf3 x `mkAppTy` typeOf (argType x) + where + argType :: t a b c -> a + argType = undefined +#endif -- | Variant for 4-ary type constructors class Typeable4 t where typeOf4 :: t a b c d -> TypeRep +#ifdef __GLASGOW_HASKELL__ -- | For defining a 'Typeable3' instance from any 'Typeable4' instance. typeOf3Default :: forall t a b c d. (Typeable4 t, Typeable a) => t a b c d -> TypeRep typeOf3Default = \_ -> rep @@ -374,11 +402,20 @@ typeOf3Default = \_ -> rep rep = typeOf4 (undefined :: t a b c d) `mkAppTy` typeOf (undefined :: a) -- Note [Memoising typeOf] +#else +-- | For defining a 'Typeable3' instance from any 'Typeable4' instance. +typeOf3Default :: (Typeable4 t, Typeable a) => t a b c d -> TypeRep +typeOf3Default x = typeOf4 x `mkAppTy` typeOf (argType x) + where + argType :: t a b c d -> a + argType = undefined +#endif -- | Variant for 5-ary type constructors class Typeable5 t where typeOf5 :: t a b c d e -> TypeRep +#ifdef __GLASGOW_HASKELL__ -- | For defining a 'Typeable4' instance from any 'Typeable5' instance. typeOf4Default :: forall t a b c d e. (Typeable5 t, Typeable a) => t a b c d e -> TypeRep typeOf4Default = \_ -> rep @@ -386,11 +423,20 @@ typeOf4Default = \_ -> rep rep = typeOf5 (undefined :: t a b c d e) `mkAppTy` typeOf (undefined :: a) -- Note [Memoising typeOf] +#else +-- | For defining a 'Typeable4' instance from any 'Typeable5' instance. +typeOf4Default :: (Typeable5 t, Typeable a) => t a b c d e -> TypeRep +typeOf4Default x = typeOf5 x `mkAppTy` typeOf (argType x) + where + argType :: t a b c d e -> a + argType = undefined +#endif -- | Variant for 6-ary type constructors class Typeable6 t where typeOf6 :: t a b c d e f -> TypeRep +#ifdef __GLASGOW_HASKELL__ -- | For defining a 'Typeable5' instance from any 'Typeable6' instance. typeOf5Default :: forall t a b c d e f. (Typeable6 t, Typeable a) => t a b c d e f -> TypeRep typeOf5Default = \_ -> rep @@ -398,11 +444,20 @@ typeOf5Default = \_ -> rep rep = typeOf6 (undefined :: t a b c d e f) `mkAppTy` typeOf (undefined :: a) -- Note [Memoising typeOf] +#else +-- | For defining a 'Typeable5' instance from any 'Typeable6' instance. +typeOf5Default :: (Typeable6 t, Typeable a) => t a b c d e f -> TypeRep +typeOf5Default x = typeOf6 x `mkAppTy` typeOf (argType x) + where + argType :: t a b c d e f -> a + argType = undefined +#endif -- | Variant for 7-ary type constructors class Typeable7 t where typeOf7 :: t a b c d e f g -> TypeRep +#ifdef __GLASGOW_HASKELL__ -- | For defining a 'Typeable6' instance from any 'Typeable7' instance. typeOf6Default :: forall t a b c d e f g. (Typeable7 t, Typeable a) => t a b c d e f g -> TypeRep typeOf6Default = \_ -> rep @@ -410,6 +465,14 @@ typeOf6Default = \_ -> rep rep = typeOf7 (undefined :: t a b c d e f g) `mkAppTy` typeOf (undefined :: a) -- Note [Memoising typeOf] +#else +-- | For defining a 'Typeable6' instance from any 'Typeable7' instance. +typeOf6Default :: (Typeable7 t, Typeable a) => t a b c d e f g -> TypeRep +typeOf6Default x = typeOf7 x `mkAppTy` typeOf (argType x) + where + argType :: t a b c d e f g -> a + argType = undefined +#endif #ifdef __GLASGOW_HASKELL__ -- Given a @Typeable@/n/ instance for an /n/-ary type constructor,