Commit 0c7507a0 authored by jpm@cs.ox.ac.uk's avatar jpm@cs.ox.ac.uk
Browse files

Provide Typeable1..7 as type synonyms (see #8813)

parent d3ad3eec
...@@ -35,6 +35,11 @@ ...@@ -35,6 +35,11 @@
-- and type-safe cast (but not dynamics) to support the \"Scrap your -- and type-safe cast (but not dynamics) to support the \"Scrap your
-- boilerplate\" style of generic programming. -- boilerplate\" style of generic programming.
-- --
-- Since GHC 7.8, 'Typeable' is poly-kinded. The changes required for this might
-- break some old programs involving 'Typeable'. More details on this, including
-- how to fix your code, are on the wiki page:
-- <https://ghc.haskell.org/trac/ghc/wiki/GhcKinds/PolyTypeable>
--
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
module Data.Typeable module Data.Typeable
...@@ -48,6 +53,8 @@ module Data.Typeable ...@@ -48,6 +53,8 @@ module Data.Typeable
-- * For backwards compatibility -- * For backwards compatibility
typeOf, typeOf1, typeOf2, typeOf3, typeOf4, typeOf5, typeOf6, typeOf7, typeOf, typeOf1, typeOf2, typeOf3, typeOf4, typeOf5, typeOf6, typeOf7,
Typeable1, Typeable2, Typeable3, Typeable4, Typeable5, Typeable6,
Typeable7,
-- * Type-safe cast -- * Type-safe cast
cast, cast,
......
{-# LANGUAGE Unsafe #-} {-# LANGUAGE Unsafe #-}
{-# LANGUAGE ConstraintKinds #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
...@@ -28,6 +29,7 @@ module Data.Typeable.Internal ( ...@@ -28,6 +29,7 @@ module Data.Typeable.Internal (
TypeRep(..), TypeRep(..),
Fingerprint(..), Fingerprint(..),
typeOf, typeOf1, typeOf2, typeOf3, typeOf4, typeOf5, typeOf6, typeOf7, typeOf, typeOf1, typeOf2, typeOf3, typeOf4, typeOf5, typeOf6, typeOf7,
Typeable1, Typeable2, Typeable3, Typeable4, Typeable5, Typeable6, Typeable7,
TyCon(..), TyCon(..),
typeRep, typeRep,
mkTyCon, mkTyCon,
...@@ -232,6 +234,22 @@ typeOf7 :: forall t (a :: *) (b :: *) (c :: *) (d :: *) (e :: *) (f :: *) ...@@ -232,6 +234,22 @@ typeOf7 :: forall t (a :: *) (b :: *) (c :: *) (d :: *) (e :: *) (f :: *)
(g :: *). Typeable t => t a b c d e f g -> TypeRep (g :: *). Typeable t => t a b c d e f g -> TypeRep
typeOf7 _ = typeRep (Proxy :: Proxy t) typeOf7 _ = typeRep (Proxy :: Proxy t)
type Typeable1 (a :: * -> *) = Typeable a
type Typeable2 (a :: * -> * -> *) = Typeable a
type Typeable3 (a :: * -> * -> * -> *) = Typeable a
type Typeable4 (a :: * -> * -> * -> * -> *) = Typeable a
type Typeable5 (a :: * -> * -> * -> * -> * -> *) = Typeable a
type Typeable6 (a :: * -> * -> * -> * -> * -> * -> *) = Typeable a
type Typeable7 (a :: * -> * -> * -> * -> * -> * -> * -> *) = Typeable a
{-# DEPRECATED Typeable1 "renamed to 'Typeable'" #-} -- deprecated in 7.8
{-# DEPRECATED Typeable2 "renamed to 'Typeable'" #-} -- deprecated in 7.8
{-# DEPRECATED Typeable3 "renamed to 'Typeable'" #-} -- deprecated in 7.8
{-# DEPRECATED Typeable4 "renamed to 'Typeable'" #-} -- deprecated in 7.8
{-# DEPRECATED Typeable5 "renamed to 'Typeable'" #-} -- deprecated in 7.8
{-# DEPRECATED Typeable6 "renamed to 'Typeable'" #-} -- deprecated in 7.8
{-# DEPRECATED Typeable7 "renamed to 'Typeable'" #-} -- deprecated in 7.8
-- | Kind-polymorphic Typeable instance for type application -- | Kind-polymorphic Typeable instance for type application
instance (Typeable s, Typeable a) => Typeable (s a) where instance (Typeable s, Typeable a) => Typeable (s a) where
typeRep# _ = typeRep# (proxy# :: Proxy# s) `mkAppTy` typeRep# (proxy# :: Proxy# a) typeRep# _ = typeRep# (proxy# :: Proxy# s) `mkAppTy` typeRep# (proxy# :: Proxy# a)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment