A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/src/Data-Typeable.html below:

Data/Typeable.hs
































module Data.Typeable
  (

        
        Typeable( typeOf ),     

        
        cast,                   
        gcast,                  

        
        TypeRep,        
        showsTypeRep,

        TyCon,          
        tyConString,    
        tyConPackage,   
        tyConModule,    
        tyConName,      

        
        mkTyCon,        
        mkTyCon3,       
        mkTyConApp,     
        mkAppTy,        
        mkFunTy,        

        
        splitTyConApp,  
        funResultTy,    
        typeRepTyCon,   
        typeRepArgs,    
        typeRepKey,     
        TypeRepKey,     

        
        
        Typeable1( typeOf1 ),   
        Typeable2( typeOf2 ),   
        Typeable3( typeOf3 ),   
        Typeable4( typeOf4 ),   
        Typeable5( typeOf5 ),   
        Typeable6( typeOf6 ),   
        Typeable7( typeOf7 ),   
        gcast1,                 
        gcast2,                 

        
        
        
        typeOfDefault,  
        typeOf1Default, 
        typeOf2Default, 
        typeOf3Default, 
        typeOf4Default, 
        typeOf5Default, 
        typeOf6Default  

  ) where

import Data.Typeable.Internal hiding (mkTyCon)

import Unsafe.Coerce
import Data.Maybe

#ifdef __GLASGOW_HASKELL__
import GHC.Base
import GHC.Err          (undefined)

import  GHC.Fingerprint
   
   
   
   

#endif

#ifdef __HUGS__
import Hugs.Prelude     ( Key(..), TypeRep(..), TyCon(..), Ratio,
                          Handle, Ptr, FunPtr, ForeignPtr, StablePtr )
import Hugs.IORef       ( IORef, newIORef, readIORef, writeIORef )
import Hugs.IOExts      ( unsafePerformIO )
        
import Hugs.Array       ( Array )
import Hugs.IOArray
import Hugs.ConcBase    ( MVar )
#endif

#ifdef __NHC__
import NHC.IOExtras (IOArray,IORef,newIORef,readIORef,writeIORef,unsafePerformIO)
import IO (Handle)
import Ratio (Ratio)
        
import NHC.FFI  ( Ptr,FunPtr,StablePtr,ForeignPtr )
import Array    ( Array )
#endif

#include "Typeable.h"







typeRepKey :: TypeRep -> IO TypeRepKey
typeRepKey (TypeRep f _ _) = return (TypeRepKey f)

        
        
        
        
        
        
        
        
        
        

newtype TypeRepKey = TypeRepKey Fingerprint
  deriving (Eq,Ord)





mkTyCon :: String       
        -> TyCon        
mkTyCon name = TyCon (fingerprintString name) "" "" name








cast :: (Typeable a, Typeable b) => a -> Maybe b
cast x = r
       where
         r = if typeOf x == typeOf (fromJust r)
               then Just $ unsafeCoerce x
               else Nothing


gcast :: (Typeable a, Typeable b) => c a -> Maybe (c b)
gcast x = r
 where
  r = if typeOf (getArg x) == typeOf (getArg (fromJust r))
        then Just $ unsafeCoerce x
        else Nothing
  getArg :: c x -> x 
  getArg = undefined


gcast1 :: (Typeable1 t, Typeable1 t') => c (t a) -> Maybe (c (t' a)) 
gcast1 x = r
 where
  r = if typeOf1 (getArg x) == typeOf1 (getArg (fromJust r))
       then Just $ unsafeCoerce x
       else Nothing
  getArg :: c x -> x 
  getArg = undefined


gcast2 :: (Typeable2 t, Typeable2 t') => c (t a b) -> Maybe (c (t' a b)) 
gcast2 x = r
 where
  r = if typeOf2 (getArg x) == typeOf2 (getArg (fromJust r))
       then Just $ unsafeCoerce x
       else Nothing
  getArg :: c x -> x 
  getArg = undefined


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4