module Dingo.Internal.TypeableShim
       ( TypeId
       , getTypeId
       ) where

#if __GLASGOW_HASKELL__ >= 702
import Data.Typeable (Typeable, TypeRep, typeOf)
newtype TypeId = TypeId TypeRep deriving (Eq, Ord, Show)
getTypeId :: Typeable a => a -> IO TypeId
getTypeId a = return $ TypeId $ typeOf a
#else
import Data.Typeable (Typeable, typeOf, typeRepKey)
import Control.Monad (liftM)
newtype TypeId = TypeId Int deriving (Eq, Ord, Show)
getTypeId :: Typeable a => a -> IO TypeId
getTypeId a = liftM TypeId $ typeRepKey $ typeOf a
#endif