{-# LANGUAGE TypeFamilies, GADTs, ExistentialQuantification, EmptyDataDecls #-}

module HROOT.Class.Existential where

--import Foreign.C            
import Foreign.ForeignPtr
--import Foreign.Marshal.Array


import HROOT.Class.Interface
import HROOT.Class.Implementation ()

data BottomType

class GADTTypeable a where
  data GADTType a :: * -> *
  data EGADTType a :: *

instance GADTTypeable TKey where
  data GADTType TKey a where 
    GADTTKeyTKey :: TKey -> GADTType TKey TKey
    GADTTKeyBottom  :: GADTType TKey BottomType
  data EGADTType TKey = forall a. EGADTTKey (GADTType TKey a)

castTKey :: Exist TKey -> IO (EGADTType TKey)
castTKey eobj = do 
  let obj = TKey (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TKey" -> case obj of
        TKey fptr -> let obj' = TKey (castForeignPtr fptr :: ForeignPtr RawTKey)
                        in  return . EGADTTKey . GADTTKeyTKey $ obj'
    _         -> return . EGADTTKey $ GADTTKeyBottom





instance GADTTypeable TList where
  data GADTType TList a where 
    GADTTListTList :: TList -> GADTType TList TList
    GADTTListBottom  :: GADTType TList BottomType
  data EGADTType TList = forall a. EGADTTList (GADTType TList a)

castTList :: Exist TList -> IO (EGADTType TList)
castTList eobj = do 
  let obj = TList (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TList" -> case obj of
        TList fptr -> let obj' = TList (castForeignPtr fptr :: ForeignPtr RawTList)
                        in  return . EGADTTList . GADTTListTList $ obj'
    _         -> return . EGADTTList $ GADTTListBottom





instance GADTTypeable TObjArray where
  data GADTType TObjArray a where 
    GADTTObjArrayTObjArray :: TObjArray -> GADTType TObjArray TObjArray
    GADTTObjArrayBottom  :: GADTType TObjArray BottomType
  data EGADTType TObjArray = forall a. EGADTTObjArray (GADTType TObjArray a)

castTObjArray :: Exist TObjArray -> IO (EGADTType TObjArray)
castTObjArray eobj = do 
  let obj = TObjArray (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TObjArray" -> case obj of
        TObjArray fptr -> let obj' = TObjArray (castForeignPtr fptr :: ForeignPtr RawTObjArray)
                        in  return . EGADTTObjArray . GADTTObjArrayTObjArray $ obj'
    _         -> return . EGADTTObjArray $ GADTTObjArrayBottom





instance GADTTypeable TSeqCollection where
  data GADTType TSeqCollection a where 
    GADTTSeqCollectionTSeqCollection :: TSeqCollection -> GADTType TSeqCollection TSeqCollection
    GADTTSeqCollectionTObjArray :: TObjArray -> GADTType TSeqCollection TObjArray
    GADTTSeqCollectionTList :: TList -> GADTType TSeqCollection TList
    GADTTSeqCollectionBottom  :: GADTType TSeqCollection BottomType
  data EGADTType TSeqCollection = forall a. EGADTTSeqCollection (GADTType TSeqCollection a)

castTSeqCollection :: Exist TSeqCollection -> IO (EGADTType TSeqCollection)
castTSeqCollection eobj = do 
  let obj = TSeqCollection (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TSeqCollection" -> case obj of
        TSeqCollection fptr -> let obj' = TSeqCollection (castForeignPtr fptr :: ForeignPtr RawTSeqCollection)
                        in  return . EGADTTSeqCollection . GADTTSeqCollectionTSeqCollection $ obj'
    "TObjArray" -> case obj of
        TSeqCollection fptr -> let obj' = TObjArray (castForeignPtr fptr :: ForeignPtr RawTObjArray)
                        in  return . EGADTTSeqCollection . GADTTSeqCollectionTObjArray $ obj'
    "TList" -> case obj of
        TSeqCollection fptr -> let obj' = TList (castForeignPtr fptr :: ForeignPtr RawTList)
                        in  return . EGADTTSeqCollection . GADTTSeqCollectionTList $ obj'
    _         -> return . EGADTTSeqCollection $ GADTTSeqCollectionBottom





instance GADTTypeable TCollection where
  data GADTType TCollection a where 
    GADTTCollectionTCollection :: TCollection -> GADTType TCollection TCollection
    GADTTCollectionTSeqCollection :: TSeqCollection -> GADTType TCollection TSeqCollection
    GADTTCollectionTObjArray :: TObjArray -> GADTType TCollection TObjArray
    GADTTCollectionTList :: TList -> GADTType TCollection TList
    GADTTCollectionBottom  :: GADTType TCollection BottomType
  data EGADTType TCollection = forall a. EGADTTCollection (GADTType TCollection a)

castTCollection :: Exist TCollection -> IO (EGADTType TCollection)
castTCollection eobj = do 
  let obj = TCollection (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TCollection" -> case obj of
        TCollection fptr -> let obj' = TCollection (castForeignPtr fptr :: ForeignPtr RawTCollection)
                        in  return . EGADTTCollection . GADTTCollectionTCollection $ obj'
    "TSeqCollection" -> case obj of
        TCollection fptr -> let obj' = TSeqCollection (castForeignPtr fptr :: ForeignPtr RawTSeqCollection)
                        in  return . EGADTTCollection . GADTTCollectionTSeqCollection $ obj'
    "TObjArray" -> case obj of
        TCollection fptr -> let obj' = TObjArray (castForeignPtr fptr :: ForeignPtr RawTObjArray)
                        in  return . EGADTTCollection . GADTTCollectionTObjArray $ obj'
    "TList" -> case obj of
        TCollection fptr -> let obj' = TList (castForeignPtr fptr :: ForeignPtr RawTList)
                        in  return . EGADTTCollection . GADTTCollectionTList $ obj'
    _         -> return . EGADTTCollection $ GADTTCollectionBottom





instance GADTTypeable TRandom where
  data GADTType TRandom a where 
    GADTTRandomTRandom :: TRandom -> GADTType TRandom TRandom
    GADTTRandomBottom  :: GADTType TRandom BottomType
  data EGADTType TRandom = forall a. EGADTTRandom (GADTType TRandom a)

castTRandom :: Exist TRandom -> IO (EGADTType TRandom)
castTRandom eobj = do 
  let obj = TRandom (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TRandom" -> case obj of
        TRandom fptr -> let obj' = TRandom (castForeignPtr fptr :: ForeignPtr RawTRandom)
                        in  return . EGADTTRandom . GADTTRandomTRandom $ obj'
    _         -> return . EGADTTRandom $ GADTTRandomBottom





instance GADTTypeable TRint where
  data GADTType TRint a where 
    GADTTRintTRint :: TRint -> GADTType TRint TRint
    GADTTRintBottom  :: GADTType TRint BottomType
  data EGADTType TRint = forall a. EGADTTRint (GADTType TRint a)

castTRint :: Exist TRint -> IO (EGADTType TRint)
castTRint eobj = do 
  let obj = TRint (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TRint" -> case obj of
        TRint fptr -> let obj' = TRint (castForeignPtr fptr :: ForeignPtr RawTRint)
                        in  return . EGADTTRint . GADTTRintTRint $ obj'
    _         -> return . EGADTTRint $ GADTTRintBottom





instance GADTTypeable TApplication where
  data GADTType TApplication a where 
    GADTTApplicationTApplication :: TApplication -> GADTType TApplication TApplication
    GADTTApplicationTRint :: TRint -> GADTType TApplication TRint
    GADTTApplicationBottom  :: GADTType TApplication BottomType
  data EGADTType TApplication = forall a. EGADTTApplication (GADTType TApplication a)

castTApplication :: Exist TApplication -> IO (EGADTType TApplication)
castTApplication eobj = do 
  let obj = TApplication (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TApplication" -> case obj of
        TApplication fptr -> let obj' = TApplication (castForeignPtr fptr :: ForeignPtr RawTApplication)
                        in  return . EGADTTApplication . GADTTApplicationTApplication $ obj'
    "TRint" -> case obj of
        TApplication fptr -> let obj' = TRint (castForeignPtr fptr :: ForeignPtr RawTRint)
                        in  return . EGADTTApplication . GADTTApplicationTRint $ obj'
    _         -> return . EGADTTApplication $ GADTTApplicationBottom





instance GADTTypeable TSlider where
  data GADTType TSlider a where 
    GADTTSliderTSlider :: TSlider -> GADTType TSlider TSlider
    GADTTSliderBottom  :: GADTType TSlider BottomType
  data EGADTType TSlider = forall a. EGADTTSlider (GADTType TSlider a)

castTSlider :: Exist TSlider -> IO (EGADTType TSlider)
castTSlider eobj = do 
  let obj = TSlider (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TSlider" -> case obj of
        TSlider fptr -> let obj' = TSlider (castForeignPtr fptr :: ForeignPtr RawTSlider)
                        in  return . EGADTTSlider . GADTTSliderTSlider $ obj'
    _         -> return . EGADTTSlider $ GADTTSliderBottom





instance GADTTypeable TEvePad where
  data GADTType TEvePad a where 
    GADTTEvePadTEvePad :: TEvePad -> GADTType TEvePad TEvePad
    GADTTEvePadBottom  :: GADTType TEvePad BottomType
  data EGADTType TEvePad = forall a. EGADTTEvePad (GADTType TEvePad a)

castTEvePad :: Exist TEvePad -> IO (EGADTType TEvePad)
castTEvePad eobj = do 
  let obj = TEvePad (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TEvePad" -> case obj of
        TEvePad fptr -> let obj' = TEvePad (castForeignPtr fptr :: ForeignPtr RawTEvePad)
                        in  return . EGADTTEvePad . GADTTEvePadTEvePad $ obj'
    _         -> return . EGADTTEvePad $ GADTTEvePadBottom





instance GADTTypeable TInspectCanvas where
  data GADTType TInspectCanvas a where 
    GADTTInspectCanvasTInspectCanvas :: TInspectCanvas -> GADTType TInspectCanvas TInspectCanvas
    GADTTInspectCanvasBottom  :: GADTType TInspectCanvas BottomType
  data EGADTType TInspectCanvas = forall a. EGADTTInspectCanvas (GADTType TInspectCanvas a)

castTInspectCanvas :: Exist TInspectCanvas -> IO (EGADTType TInspectCanvas)
castTInspectCanvas eobj = do 
  let obj = TInspectCanvas (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TInspectCanvas" -> case obj of
        TInspectCanvas fptr -> let obj' = TInspectCanvas (castForeignPtr fptr :: ForeignPtr RawTInspectCanvas)
                        in  return . EGADTTInspectCanvas . GADTTInspectCanvasTInspectCanvas $ obj'
    _         -> return . EGADTTInspectCanvas $ GADTTInspectCanvasBottom





instance GADTTypeable TDialogCanvas where
  data GADTType TDialogCanvas a where 
    GADTTDialogCanvasTDialogCanvas :: TDialogCanvas -> GADTType TDialogCanvas TDialogCanvas
    GADTTDialogCanvasBottom  :: GADTType TDialogCanvas BottomType
  data EGADTType TDialogCanvas = forall a. EGADTTDialogCanvas (GADTType TDialogCanvas a)

castTDialogCanvas :: Exist TDialogCanvas -> IO (EGADTType TDialogCanvas)
castTDialogCanvas eobj = do 
  let obj = TDialogCanvas (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TDialogCanvas" -> case obj of
        TDialogCanvas fptr -> let obj' = TDialogCanvas (castForeignPtr fptr :: ForeignPtr RawTDialogCanvas)
                        in  return . EGADTTDialogCanvas . GADTTDialogCanvasTDialogCanvas $ obj'
    _         -> return . EGADTTDialogCanvas $ GADTTDialogCanvasBottom





instance GADTTypeable TCanvas where
  data GADTType TCanvas a where 
    GADTTCanvasTCanvas :: TCanvas -> GADTType TCanvas TCanvas
    GADTTCanvasTDialogCanvas :: TDialogCanvas -> GADTType TCanvas TDialogCanvas
    GADTTCanvasTInspectCanvas :: TInspectCanvas -> GADTType TCanvas TInspectCanvas
    GADTTCanvasBottom  :: GADTType TCanvas BottomType
  data EGADTType TCanvas = forall a. EGADTTCanvas (GADTType TCanvas a)

castTCanvas :: Exist TCanvas -> IO (EGADTType TCanvas)
castTCanvas eobj = do 
  let obj = TCanvas (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TCanvas" -> case obj of
        TCanvas fptr -> let obj' = TCanvas (castForeignPtr fptr :: ForeignPtr RawTCanvas)
                        in  return . EGADTTCanvas . GADTTCanvasTCanvas $ obj'
    "TDialogCanvas" -> case obj of
        TCanvas fptr -> let obj' = TDialogCanvas (castForeignPtr fptr :: ForeignPtr RawTDialogCanvas)
                        in  return . EGADTTCanvas . GADTTCanvasTDialogCanvas $ obj'
    "TInspectCanvas" -> case obj of
        TCanvas fptr -> let obj' = TInspectCanvas (castForeignPtr fptr :: ForeignPtr RawTInspectCanvas)
                        in  return . EGADTTCanvas . GADTTCanvasTInspectCanvas $ obj'
    _         -> return . EGADTTCanvas $ GADTTCanvasBottom





instance GADTTypeable TGroupButton where
  data GADTType TGroupButton a where 
    GADTTGroupButtonTGroupButton :: TGroupButton -> GADTType TGroupButton TGroupButton
    GADTTGroupButtonBottom  :: GADTType TGroupButton BottomType
  data EGADTType TGroupButton = forall a. EGADTTGroupButton (GADTType TGroupButton a)

castTGroupButton :: Exist TGroupButton -> IO (EGADTType TGroupButton)
castTGroupButton eobj = do 
  let obj = TGroupButton (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TGroupButton" -> case obj of
        TGroupButton fptr -> let obj' = TGroupButton (castForeignPtr fptr :: ForeignPtr RawTGroupButton)
                        in  return . EGADTTGroupButton . GADTTGroupButtonTGroupButton $ obj'
    _         -> return . EGADTTGroupButton $ GADTTGroupButtonBottom





instance GADTTypeable TButton where
  data GADTType TButton a where 
    GADTTButtonTButton :: TButton -> GADTType TButton TButton
    GADTTButtonTGroupButton :: TGroupButton -> GADTType TButton TGroupButton
    GADTTButtonBottom  :: GADTType TButton BottomType
  data EGADTType TButton = forall a. EGADTTButton (GADTType TButton a)

castTButton :: Exist TButton -> IO (EGADTType TButton)
castTButton eobj = do 
  let obj = TButton (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TButton" -> case obj of
        TButton fptr -> let obj' = TButton (castForeignPtr fptr :: ForeignPtr RawTButton)
                        in  return . EGADTTButton . GADTTButtonTButton $ obj'
    "TGroupButton" -> case obj of
        TButton fptr -> let obj' = TGroupButton (castForeignPtr fptr :: ForeignPtr RawTGroupButton)
                        in  return . EGADTTButton . GADTTButtonTGroupButton $ obj'
    _         -> return . EGADTTButton $ GADTTButtonBottom





instance GADTTypeable TPad where
  data GADTType TPad a where 
    GADTTPadTPad :: TPad -> GADTType TPad TPad
    GADTTPadTButton :: TButton -> GADTType TPad TButton
    GADTTPadTGroupButton :: TGroupButton -> GADTType TPad TGroupButton
    GADTTPadTCanvas :: TCanvas -> GADTType TPad TCanvas
    GADTTPadTDialogCanvas :: TDialogCanvas -> GADTType TPad TDialogCanvas
    GADTTPadTInspectCanvas :: TInspectCanvas -> GADTType TPad TInspectCanvas
    GADTTPadTEvePad :: TEvePad -> GADTType TPad TEvePad
    GADTTPadTSlider :: TSlider -> GADTType TPad TSlider
    GADTTPadBottom  :: GADTType TPad BottomType
  data EGADTType TPad = forall a. EGADTTPad (GADTType TPad a)

castTPad :: Exist TPad -> IO (EGADTType TPad)
castTPad eobj = do 
  let obj = TPad (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TPad" -> case obj of
        TPad fptr -> let obj' = TPad (castForeignPtr fptr :: ForeignPtr RawTPad)
                        in  return . EGADTTPad . GADTTPadTPad $ obj'
    "TButton" -> case obj of
        TPad fptr -> let obj' = TButton (castForeignPtr fptr :: ForeignPtr RawTButton)
                        in  return . EGADTTPad . GADTTPadTButton $ obj'
    "TGroupButton" -> case obj of
        TPad fptr -> let obj' = TGroupButton (castForeignPtr fptr :: ForeignPtr RawTGroupButton)
                        in  return . EGADTTPad . GADTTPadTGroupButton $ obj'
    "TCanvas" -> case obj of
        TPad fptr -> let obj' = TCanvas (castForeignPtr fptr :: ForeignPtr RawTCanvas)
                        in  return . EGADTTPad . GADTTPadTCanvas $ obj'
    "TDialogCanvas" -> case obj of
        TPad fptr -> let obj' = TDialogCanvas (castForeignPtr fptr :: ForeignPtr RawTDialogCanvas)
                        in  return . EGADTTPad . GADTTPadTDialogCanvas $ obj'
    "TInspectCanvas" -> case obj of
        TPad fptr -> let obj' = TInspectCanvas (castForeignPtr fptr :: ForeignPtr RawTInspectCanvas)
                        in  return . EGADTTPad . GADTTPadTInspectCanvas $ obj'
    "TEvePad" -> case obj of
        TPad fptr -> let obj' = TEvePad (castForeignPtr fptr :: ForeignPtr RawTEvePad)
                        in  return . EGADTTPad . GADTTPadTEvePad $ obj'
    "TSlider" -> case obj of
        TPad fptr -> let obj' = TSlider (castForeignPtr fptr :: ForeignPtr RawTSlider)
                        in  return . EGADTTPad . GADTTPadTSlider $ obj'
    _         -> return . EGADTTPad $ GADTTPadBottom





instance GADTTypeable TVirtualPad where
  data GADTType TVirtualPad a where 
    GADTTVirtualPadTVirtualPad :: TVirtualPad -> GADTType TVirtualPad TVirtualPad
    GADTTVirtualPadTPad :: TPad -> GADTType TVirtualPad TPad
    GADTTVirtualPadTButton :: TButton -> GADTType TVirtualPad TButton
    GADTTVirtualPadTGroupButton :: TGroupButton -> GADTType TVirtualPad TGroupButton
    GADTTVirtualPadTCanvas :: TCanvas -> GADTType TVirtualPad TCanvas
    GADTTVirtualPadTDialogCanvas :: TDialogCanvas -> GADTType TVirtualPad TDialogCanvas
    GADTTVirtualPadTInspectCanvas :: TInspectCanvas -> GADTType TVirtualPad TInspectCanvas
    GADTTVirtualPadTEvePad :: TEvePad -> GADTType TVirtualPad TEvePad
    GADTTVirtualPadTSlider :: TSlider -> GADTType TVirtualPad TSlider
    GADTTVirtualPadBottom  :: GADTType TVirtualPad BottomType
  data EGADTType TVirtualPad = forall a. EGADTTVirtualPad (GADTType TVirtualPad a)

castTVirtualPad :: Exist TVirtualPad -> IO (EGADTType TVirtualPad)
castTVirtualPad eobj = do 
  let obj = TVirtualPad (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TVirtualPad" -> case obj of
        TVirtualPad fptr -> let obj' = TVirtualPad (castForeignPtr fptr :: ForeignPtr RawTVirtualPad)
                        in  return . EGADTTVirtualPad . GADTTVirtualPadTVirtualPad $ obj'
    "TPad" -> case obj of
        TVirtualPad fptr -> let obj' = TPad (castForeignPtr fptr :: ForeignPtr RawTPad)
                        in  return . EGADTTVirtualPad . GADTTVirtualPadTPad $ obj'
    "TButton" -> case obj of
        TVirtualPad fptr -> let obj' = TButton (castForeignPtr fptr :: ForeignPtr RawTButton)
                        in  return . EGADTTVirtualPad . GADTTVirtualPadTButton $ obj'
    "TGroupButton" -> case obj of
        TVirtualPad fptr -> let obj' = TGroupButton (castForeignPtr fptr :: ForeignPtr RawTGroupButton)
                        in  return . EGADTTVirtualPad . GADTTVirtualPadTGroupButton $ obj'
    "TCanvas" -> case obj of
        TVirtualPad fptr -> let obj' = TCanvas (castForeignPtr fptr :: ForeignPtr RawTCanvas)
                        in  return . EGADTTVirtualPad . GADTTVirtualPadTCanvas $ obj'
    "TDialogCanvas" -> case obj of
        TVirtualPad fptr -> let obj' = TDialogCanvas (castForeignPtr fptr :: ForeignPtr RawTDialogCanvas)
                        in  return . EGADTTVirtualPad . GADTTVirtualPadTDialogCanvas $ obj'
    "TInspectCanvas" -> case obj of
        TVirtualPad fptr -> let obj' = TInspectCanvas (castForeignPtr fptr :: ForeignPtr RawTInspectCanvas)
                        in  return . EGADTTVirtualPad . GADTTVirtualPadTInspectCanvas $ obj'
    "TEvePad" -> case obj of
        TVirtualPad fptr -> let obj' = TEvePad (castForeignPtr fptr :: ForeignPtr RawTEvePad)
                        in  return . EGADTTVirtualPad . GADTTVirtualPadTEvePad $ obj'
    "TSlider" -> case obj of
        TVirtualPad fptr -> let obj' = TSlider (castForeignPtr fptr :: ForeignPtr RawTSlider)
                        in  return . EGADTTVirtualPad . GADTTVirtualPadTSlider $ obj'
    _         -> return . EGADTTVirtualPad $ GADTTVirtualPadBottom





instance GADTTypeable TH3S where
  data GADTType TH3S a where 
    GADTTH3STH3S :: TH3S -> GADTType TH3S TH3S
    GADTTH3SBottom  :: GADTType TH3S BottomType
  data EGADTType TH3S = forall a. EGADTTH3S (GADTType TH3S a)

castTH3S :: Exist TH3S -> IO (EGADTType TH3S)
castTH3S eobj = do 
  let obj = TH3S (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH3S" -> case obj of
        TH3S fptr -> let obj' = TH3S (castForeignPtr fptr :: ForeignPtr RawTH3S)
                        in  return . EGADTTH3S . GADTTH3STH3S $ obj'
    _         -> return . EGADTTH3S $ GADTTH3SBottom





instance GADTTypeable TH3I where
  data GADTType TH3I a where 
    GADTTH3ITH3I :: TH3I -> GADTType TH3I TH3I
    GADTTH3IBottom  :: GADTType TH3I BottomType
  data EGADTType TH3I = forall a. EGADTTH3I (GADTType TH3I a)

castTH3I :: Exist TH3I -> IO (EGADTType TH3I)
castTH3I eobj = do 
  let obj = TH3I (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH3I" -> case obj of
        TH3I fptr -> let obj' = TH3I (castForeignPtr fptr :: ForeignPtr RawTH3I)
                        in  return . EGADTTH3I . GADTTH3ITH3I $ obj'
    _         -> return . EGADTTH3I $ GADTTH3IBottom





instance GADTTypeable TH3F where
  data GADTType TH3F a where 
    GADTTH3FTH3F :: TH3F -> GADTType TH3F TH3F
    GADTTH3FBottom  :: GADTType TH3F BottomType
  data EGADTType TH3F = forall a. EGADTTH3F (GADTType TH3F a)

castTH3F :: Exist TH3F -> IO (EGADTType TH3F)
castTH3F eobj = do 
  let obj = TH3F (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH3F" -> case obj of
        TH3F fptr -> let obj' = TH3F (castForeignPtr fptr :: ForeignPtr RawTH3F)
                        in  return . EGADTTH3F . GADTTH3FTH3F $ obj'
    _         -> return . EGADTTH3F $ GADTTH3FBottom





instance GADTTypeable TH3D where
  data GADTType TH3D a where 
    GADTTH3DTH3D :: TH3D -> GADTType TH3D TH3D
    GADTTH3DBottom  :: GADTType TH3D BottomType
  data EGADTType TH3D = forall a. EGADTTH3D (GADTType TH3D a)

castTH3D :: Exist TH3D -> IO (EGADTType TH3D)
castTH3D eobj = do 
  let obj = TH3D (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH3D" -> case obj of
        TH3D fptr -> let obj' = TH3D (castForeignPtr fptr :: ForeignPtr RawTH3D)
                        in  return . EGADTTH3D . GADTTH3DTH3D $ obj'
    _         -> return . EGADTTH3D $ GADTTH3DBottom





instance GADTTypeable TH3C where
  data GADTType TH3C a where 
    GADTTH3CTH3C :: TH3C -> GADTType TH3C TH3C
    GADTTH3CBottom  :: GADTType TH3C BottomType
  data EGADTType TH3C = forall a. EGADTTH3C (GADTType TH3C a)

castTH3C :: Exist TH3C -> IO (EGADTType TH3C)
castTH3C eobj = do 
  let obj = TH3C (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH3C" -> case obj of
        TH3C fptr -> let obj' = TH3C (castForeignPtr fptr :: ForeignPtr RawTH3C)
                        in  return . EGADTTH3C . GADTTH3CTH3C $ obj'
    _         -> return . EGADTTH3C $ GADTTH3CBottom





instance GADTTypeable TH2S where
  data GADTType TH2S a where 
    GADTTH2STH2S :: TH2S -> GADTType TH2S TH2S
    GADTTH2SBottom  :: GADTType TH2S BottomType
  data EGADTType TH2S = forall a. EGADTTH2S (GADTType TH2S a)

castTH2S :: Exist TH2S -> IO (EGADTType TH2S)
castTH2S eobj = do 
  let obj = TH2S (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH2S" -> case obj of
        TH2S fptr -> let obj' = TH2S (castForeignPtr fptr :: ForeignPtr RawTH2S)
                        in  return . EGADTTH2S . GADTTH2STH2S $ obj'
    _         -> return . EGADTTH2S $ GADTTH2SBottom





instance GADTTypeable TH2Poly where
  data GADTType TH2Poly a where 
    GADTTH2PolyTH2Poly :: TH2Poly -> GADTType TH2Poly TH2Poly
    GADTTH2PolyBottom  :: GADTType TH2Poly BottomType
  data EGADTType TH2Poly = forall a. EGADTTH2Poly (GADTType TH2Poly a)

castTH2Poly :: Exist TH2Poly -> IO (EGADTType TH2Poly)
castTH2Poly eobj = do 
  let obj = TH2Poly (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH2Poly" -> case obj of
        TH2Poly fptr -> let obj' = TH2Poly (castForeignPtr fptr :: ForeignPtr RawTH2Poly)
                        in  return . EGADTTH2Poly . GADTTH2PolyTH2Poly $ obj'
    _         -> return . EGADTTH2Poly $ GADTTH2PolyBottom





instance GADTTypeable TH2I where
  data GADTType TH2I a where 
    GADTTH2ITH2I :: TH2I -> GADTType TH2I TH2I
    GADTTH2IBottom  :: GADTType TH2I BottomType
  data EGADTType TH2I = forall a. EGADTTH2I (GADTType TH2I a)

castTH2I :: Exist TH2I -> IO (EGADTType TH2I)
castTH2I eobj = do 
  let obj = TH2I (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH2I" -> case obj of
        TH2I fptr -> let obj' = TH2I (castForeignPtr fptr :: ForeignPtr RawTH2I)
                        in  return . EGADTTH2I . GADTTH2ITH2I $ obj'
    _         -> return . EGADTTH2I $ GADTTH2IBottom





instance GADTTypeable TH2F where
  data GADTType TH2F a where 
    GADTTH2FTH2F :: TH2F -> GADTType TH2F TH2F
    GADTTH2FBottom  :: GADTType TH2F BottomType
  data EGADTType TH2F = forall a. EGADTTH2F (GADTType TH2F a)

castTH2F :: Exist TH2F -> IO (EGADTType TH2F)
castTH2F eobj = do 
  let obj = TH2F (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH2F" -> case obj of
        TH2F fptr -> let obj' = TH2F (castForeignPtr fptr :: ForeignPtr RawTH2F)
                        in  return . EGADTTH2F . GADTTH2FTH2F $ obj'
    _         -> return . EGADTTH2F $ GADTTH2FBottom





instance GADTTypeable TH2D where
  data GADTType TH2D a where 
    GADTTH2DTH2D :: TH2D -> GADTType TH2D TH2D
    GADTTH2DBottom  :: GADTType TH2D BottomType
  data EGADTType TH2D = forall a. EGADTTH2D (GADTType TH2D a)

castTH2D :: Exist TH2D -> IO (EGADTType TH2D)
castTH2D eobj = do 
  let obj = TH2D (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH2D" -> case obj of
        TH2D fptr -> let obj' = TH2D (castForeignPtr fptr :: ForeignPtr RawTH2D)
                        in  return . EGADTTH2D . GADTTH2DTH2D $ obj'
    _         -> return . EGADTTH2D $ GADTTH2DBottom





instance GADTTypeable TH2C where
  data GADTType TH2C a where 
    GADTTH2CTH2C :: TH2C -> GADTType TH2C TH2C
    GADTTH2CBottom  :: GADTType TH2C BottomType
  data EGADTType TH2C = forall a. EGADTTH2C (GADTType TH2C a)

castTH2C :: Exist TH2C -> IO (EGADTType TH2C)
castTH2C eobj = do 
  let obj = TH2C (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH2C" -> case obj of
        TH2C fptr -> let obj' = TH2C (castForeignPtr fptr :: ForeignPtr RawTH2C)
                        in  return . EGADTTH2C . GADTTH2CTH2C $ obj'
    _         -> return . EGADTTH2C $ GADTTH2CBottom





instance GADTTypeable TH1S where
  data GADTType TH1S a where 
    GADTTH1STH1S :: TH1S -> GADTType TH1S TH1S
    GADTTH1SBottom  :: GADTType TH1S BottomType
  data EGADTType TH1S = forall a. EGADTTH1S (GADTType TH1S a)

castTH1S :: Exist TH1S -> IO (EGADTType TH1S)
castTH1S eobj = do 
  let obj = TH1S (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH1S" -> case obj of
        TH1S fptr -> let obj' = TH1S (castForeignPtr fptr :: ForeignPtr RawTH1S)
                        in  return . EGADTTH1S . GADTTH1STH1S $ obj'
    _         -> return . EGADTTH1S $ GADTTH1SBottom





instance GADTTypeable TH1I where
  data GADTType TH1I a where 
    GADTTH1ITH1I :: TH1I -> GADTType TH1I TH1I
    GADTTH1IBottom  :: GADTType TH1I BottomType
  data EGADTType TH1I = forall a. EGADTTH1I (GADTType TH1I a)

castTH1I :: Exist TH1I -> IO (EGADTType TH1I)
castTH1I eobj = do 
  let obj = TH1I (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH1I" -> case obj of
        TH1I fptr -> let obj' = TH1I (castForeignPtr fptr :: ForeignPtr RawTH1I)
                        in  return . EGADTTH1I . GADTTH1ITH1I $ obj'
    _         -> return . EGADTTH1I $ GADTTH1IBottom





instance GADTTypeable TH1F where
  data GADTType TH1F a where 
    GADTTH1FTH1F :: TH1F -> GADTType TH1F TH1F
    GADTTH1FBottom  :: GADTType TH1F BottomType
  data EGADTType TH1F = forall a. EGADTTH1F (GADTType TH1F a)

castTH1F :: Exist TH1F -> IO (EGADTType TH1F)
castTH1F eobj = do 
  let obj = TH1F (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH1F" -> case obj of
        TH1F fptr -> let obj' = TH1F (castForeignPtr fptr :: ForeignPtr RawTH1F)
                        in  return . EGADTTH1F . GADTTH1FTH1F $ obj'
    _         -> return . EGADTTH1F $ GADTTH1FBottom





instance GADTTypeable TH1D where
  data GADTType TH1D a where 
    GADTTH1DTH1D :: TH1D -> GADTType TH1D TH1D
    GADTTH1DBottom  :: GADTType TH1D BottomType
  data EGADTType TH1D = forall a. EGADTTH1D (GADTType TH1D a)

castTH1D :: Exist TH1D -> IO (EGADTType TH1D)
castTH1D eobj = do 
  let obj = TH1D (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH1D" -> case obj of
        TH1D fptr -> let obj' = TH1D (castForeignPtr fptr :: ForeignPtr RawTH1D)
                        in  return . EGADTTH1D . GADTTH1DTH1D $ obj'
    _         -> return . EGADTTH1D $ GADTTH1DBottom





instance GADTTypeable TH1C where
  data GADTType TH1C a where 
    GADTTH1CTH1C :: TH1C -> GADTType TH1C TH1C
    GADTTH1CBottom  :: GADTType TH1C BottomType
  data EGADTType TH1C = forall a. EGADTTH1C (GADTType TH1C a)

castTH1C :: Exist TH1C -> IO (EGADTType TH1C)
castTH1C eobj = do 
  let obj = TH1C (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH1C" -> case obj of
        TH1C fptr -> let obj' = TH1C (castForeignPtr fptr :: ForeignPtr RawTH1C)
                        in  return . EGADTTH1C . GADTTH1CTH1C $ obj'
    _         -> return . EGADTTH1C $ GADTTH1CBottom





instance GADTTypeable TH3 where
  data GADTType TH3 a where 
    GADTTH3TH3 :: TH3 -> GADTType TH3 TH3
    GADTTH3TH3C :: TH3C -> GADTType TH3 TH3C
    GADTTH3TH3D :: TH3D -> GADTType TH3 TH3D
    GADTTH3TH3F :: TH3F -> GADTType TH3 TH3F
    GADTTH3TH3I :: TH3I -> GADTType TH3 TH3I
    GADTTH3TH3S :: TH3S -> GADTType TH3 TH3S
    GADTTH3Bottom  :: GADTType TH3 BottomType
  data EGADTType TH3 = forall a. EGADTTH3 (GADTType TH3 a)

castTH3 :: Exist TH3 -> IO (EGADTType TH3)
castTH3 eobj = do 
  let obj = TH3 (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH3" -> case obj of
        TH3 fptr -> let obj' = TH3 (castForeignPtr fptr :: ForeignPtr RawTH3)
                        in  return . EGADTTH3 . GADTTH3TH3 $ obj'
    "TH3C" -> case obj of
        TH3 fptr -> let obj' = TH3C (castForeignPtr fptr :: ForeignPtr RawTH3C)
                        in  return . EGADTTH3 . GADTTH3TH3C $ obj'
    "TH3D" -> case obj of
        TH3 fptr -> let obj' = TH3D (castForeignPtr fptr :: ForeignPtr RawTH3D)
                        in  return . EGADTTH3 . GADTTH3TH3D $ obj'
    "TH3F" -> case obj of
        TH3 fptr -> let obj' = TH3F (castForeignPtr fptr :: ForeignPtr RawTH3F)
                        in  return . EGADTTH3 . GADTTH3TH3F $ obj'
    "TH3I" -> case obj of
        TH3 fptr -> let obj' = TH3I (castForeignPtr fptr :: ForeignPtr RawTH3I)
                        in  return . EGADTTH3 . GADTTH3TH3I $ obj'
    "TH3S" -> case obj of
        TH3 fptr -> let obj' = TH3S (castForeignPtr fptr :: ForeignPtr RawTH3S)
                        in  return . EGADTTH3 . GADTTH3TH3S $ obj'
    _         -> return . EGADTTH3 $ GADTTH3Bottom





instance GADTTypeable TH2 where
  data GADTType TH2 a where 
    GADTTH2TH2 :: TH2 -> GADTType TH2 TH2
    GADTTH2TH2C :: TH2C -> GADTType TH2 TH2C
    GADTTH2TH2D :: TH2D -> GADTType TH2 TH2D
    GADTTH2TH2F :: TH2F -> GADTType TH2 TH2F
    GADTTH2TH2I :: TH2I -> GADTType TH2 TH2I
    GADTTH2TH2Poly :: TH2Poly -> GADTType TH2 TH2Poly
    GADTTH2TH2S :: TH2S -> GADTType TH2 TH2S
    GADTTH2Bottom  :: GADTType TH2 BottomType
  data EGADTType TH2 = forall a. EGADTTH2 (GADTType TH2 a)

castTH2 :: Exist TH2 -> IO (EGADTType TH2)
castTH2 eobj = do 
  let obj = TH2 (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH2" -> case obj of
        TH2 fptr -> let obj' = TH2 (castForeignPtr fptr :: ForeignPtr RawTH2)
                        in  return . EGADTTH2 . GADTTH2TH2 $ obj'
    "TH2C" -> case obj of
        TH2 fptr -> let obj' = TH2C (castForeignPtr fptr :: ForeignPtr RawTH2C)
                        in  return . EGADTTH2 . GADTTH2TH2C $ obj'
    "TH2D" -> case obj of
        TH2 fptr -> let obj' = TH2D (castForeignPtr fptr :: ForeignPtr RawTH2D)
                        in  return . EGADTTH2 . GADTTH2TH2D $ obj'
    "TH2F" -> case obj of
        TH2 fptr -> let obj' = TH2F (castForeignPtr fptr :: ForeignPtr RawTH2F)
                        in  return . EGADTTH2 . GADTTH2TH2F $ obj'
    "TH2I" -> case obj of
        TH2 fptr -> let obj' = TH2I (castForeignPtr fptr :: ForeignPtr RawTH2I)
                        in  return . EGADTTH2 . GADTTH2TH2I $ obj'
    "TH2Poly" -> case obj of
        TH2 fptr -> let obj' = TH2Poly (castForeignPtr fptr :: ForeignPtr RawTH2Poly)
                        in  return . EGADTTH2 . GADTTH2TH2Poly $ obj'
    "TH2S" -> case obj of
        TH2 fptr -> let obj' = TH2S (castForeignPtr fptr :: ForeignPtr RawTH2S)
                        in  return . EGADTTH2 . GADTTH2TH2S $ obj'
    _         -> return . EGADTTH2 $ GADTTH2Bottom





instance GADTTypeable TH1 where
  data GADTType TH1 a where 
    GADTTH1TH1 :: TH1 -> GADTType TH1 TH1
    GADTTH1TH2 :: TH2 -> GADTType TH1 TH2
    GADTTH1TH3 :: TH3 -> GADTType TH1 TH3
    GADTTH1TH1C :: TH1C -> GADTType TH1 TH1C
    GADTTH1TH1D :: TH1D -> GADTType TH1 TH1D
    GADTTH1TH1F :: TH1F -> GADTType TH1 TH1F
    GADTTH1TH1I :: TH1I -> GADTType TH1 TH1I
    GADTTH1TH1S :: TH1S -> GADTType TH1 TH1S
    GADTTH1TH2C :: TH2C -> GADTType TH1 TH2C
    GADTTH1TH2D :: TH2D -> GADTType TH1 TH2D
    GADTTH1TH2F :: TH2F -> GADTType TH1 TH2F
    GADTTH1TH2I :: TH2I -> GADTType TH1 TH2I
    GADTTH1TH2Poly :: TH2Poly -> GADTType TH1 TH2Poly
    GADTTH1TH2S :: TH2S -> GADTType TH1 TH2S
    GADTTH1TH3C :: TH3C -> GADTType TH1 TH3C
    GADTTH1TH3D :: TH3D -> GADTType TH1 TH3D
    GADTTH1TH3F :: TH3F -> GADTType TH1 TH3F
    GADTTH1TH3I :: TH3I -> GADTType TH1 TH3I
    GADTTH1TH3S :: TH3S -> GADTType TH1 TH3S
    GADTTH1Bottom  :: GADTType TH1 BottomType
  data EGADTType TH1 = forall a. EGADTTH1 (GADTType TH1 a)

castTH1 :: Exist TH1 -> IO (EGADTType TH1)
castTH1 eobj = do 
  let obj = TH1 (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TH1" -> case obj of
        TH1 fptr -> let obj' = TH1 (castForeignPtr fptr :: ForeignPtr RawTH1)
                        in  return . EGADTTH1 . GADTTH1TH1 $ obj'
    "TH2" -> case obj of
        TH1 fptr -> let obj' = TH2 (castForeignPtr fptr :: ForeignPtr RawTH2)
                        in  return . EGADTTH1 . GADTTH1TH2 $ obj'
    "TH3" -> case obj of
        TH1 fptr -> let obj' = TH3 (castForeignPtr fptr :: ForeignPtr RawTH3)
                        in  return . EGADTTH1 . GADTTH1TH3 $ obj'
    "TH1C" -> case obj of
        TH1 fptr -> let obj' = TH1C (castForeignPtr fptr :: ForeignPtr RawTH1C)
                        in  return . EGADTTH1 . GADTTH1TH1C $ obj'
    "TH1D" -> case obj of
        TH1 fptr -> let obj' = TH1D (castForeignPtr fptr :: ForeignPtr RawTH1D)
                        in  return . EGADTTH1 . GADTTH1TH1D $ obj'
    "TH1F" -> case obj of
        TH1 fptr -> let obj' = TH1F (castForeignPtr fptr :: ForeignPtr RawTH1F)
                        in  return . EGADTTH1 . GADTTH1TH1F $ obj'
    "TH1I" -> case obj of
        TH1 fptr -> let obj' = TH1I (castForeignPtr fptr :: ForeignPtr RawTH1I)
                        in  return . EGADTTH1 . GADTTH1TH1I $ obj'
    "TH1S" -> case obj of
        TH1 fptr -> let obj' = TH1S (castForeignPtr fptr :: ForeignPtr RawTH1S)
                        in  return . EGADTTH1 . GADTTH1TH1S $ obj'
    "TH2C" -> case obj of
        TH1 fptr -> let obj' = TH2C (castForeignPtr fptr :: ForeignPtr RawTH2C)
                        in  return . EGADTTH1 . GADTTH1TH2C $ obj'
    "TH2D" -> case obj of
        TH1 fptr -> let obj' = TH2D (castForeignPtr fptr :: ForeignPtr RawTH2D)
                        in  return . EGADTTH1 . GADTTH1TH2D $ obj'
    "TH2F" -> case obj of
        TH1 fptr -> let obj' = TH2F (castForeignPtr fptr :: ForeignPtr RawTH2F)
                        in  return . EGADTTH1 . GADTTH1TH2F $ obj'
    "TH2I" -> case obj of
        TH1 fptr -> let obj' = TH2I (castForeignPtr fptr :: ForeignPtr RawTH2I)
                        in  return . EGADTTH1 . GADTTH1TH2I $ obj'
    "TH2Poly" -> case obj of
        TH1 fptr -> let obj' = TH2Poly (castForeignPtr fptr :: ForeignPtr RawTH2Poly)
                        in  return . EGADTTH1 . GADTTH1TH2Poly $ obj'
    "TH2S" -> case obj of
        TH1 fptr -> let obj' = TH2S (castForeignPtr fptr :: ForeignPtr RawTH2S)
                        in  return . EGADTTH1 . GADTTH1TH2S $ obj'
    "TH3C" -> case obj of
        TH1 fptr -> let obj' = TH3C (castForeignPtr fptr :: ForeignPtr RawTH3C)
                        in  return . EGADTTH1 . GADTTH1TH3C $ obj'
    "TH3D" -> case obj of
        TH1 fptr -> let obj' = TH3D (castForeignPtr fptr :: ForeignPtr RawTH3D)
                        in  return . EGADTTH1 . GADTTH1TH3D $ obj'
    "TH3F" -> case obj of
        TH1 fptr -> let obj' = TH3F (castForeignPtr fptr :: ForeignPtr RawTH3F)
                        in  return . EGADTTH1 . GADTTH1TH3F $ obj'
    "TH3I" -> case obj of
        TH1 fptr -> let obj' = TH3I (castForeignPtr fptr :: ForeignPtr RawTH3I)
                        in  return . EGADTTH1 . GADTTH1TH3I $ obj'
    "TH3S" -> case obj of
        TH1 fptr -> let obj' = TH3S (castForeignPtr fptr :: ForeignPtr RawTH3S)
                        in  return . EGADTTH1 . GADTTH1TH3S $ obj'
    _         -> return . EGADTTH1 $ GADTTH1Bottom





instance GADTTypeable TTreePlayer where
  data GADTType TTreePlayer a where 
    GADTTTreePlayerTTreePlayer :: TTreePlayer -> GADTType TTreePlayer TTreePlayer
    GADTTTreePlayerBottom  :: GADTType TTreePlayer BottomType
  data EGADTType TTreePlayer = forall a. EGADTTTreePlayer (GADTType TTreePlayer a)

castTTreePlayer :: Exist TTreePlayer -> IO (EGADTType TTreePlayer)
castTTreePlayer eobj = do 
  let obj = TTreePlayer (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TTreePlayer" -> case obj of
        TTreePlayer fptr -> let obj' = TTreePlayer (castForeignPtr fptr :: ForeignPtr RawTTreePlayer)
                        in  return . EGADTTTreePlayer . GADTTTreePlayerTTreePlayer $ obj'
    _         -> return . EGADTTTreePlayer $ GADTTTreePlayerBottom





instance GADTTypeable TVirtualTreePlayer where
  data GADTType TVirtualTreePlayer a where 
    GADTTVirtualTreePlayerTVirtualTreePlayer :: TVirtualTreePlayer -> GADTType TVirtualTreePlayer TVirtualTreePlayer
    GADTTVirtualTreePlayerTTreePlayer :: TTreePlayer -> GADTType TVirtualTreePlayer TTreePlayer
    GADTTVirtualTreePlayerBottom  :: GADTType TVirtualTreePlayer BottomType
  data EGADTType TVirtualTreePlayer = forall a. EGADTTVirtualTreePlayer (GADTType TVirtualTreePlayer a)

castTVirtualTreePlayer :: Exist TVirtualTreePlayer -> IO (EGADTType TVirtualTreePlayer)
castTVirtualTreePlayer eobj = do 
  let obj = TVirtualTreePlayer (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TVirtualTreePlayer" -> case obj of
        TVirtualTreePlayer fptr -> let obj' = TVirtualTreePlayer (castForeignPtr fptr :: ForeignPtr RawTVirtualTreePlayer)
                        in  return . EGADTTVirtualTreePlayer . GADTTVirtualTreePlayerTVirtualTreePlayer $ obj'
    "TTreePlayer" -> case obj of
        TVirtualTreePlayer fptr -> let obj' = TTreePlayer (castForeignPtr fptr :: ForeignPtr RawTTreePlayer)
                        in  return . EGADTTVirtualTreePlayer . GADTTVirtualTreePlayerTTreePlayer $ obj'
    _         -> return . EGADTTVirtualTreePlayer $ GADTTVirtualTreePlayerBottom





instance GADTTypeable TBranch where
  data GADTType TBranch a where 
    GADTTBranchTBranch :: TBranch -> GADTType TBranch TBranch
    GADTTBranchBottom  :: GADTType TBranch BottomType
  data EGADTType TBranch = forall a. EGADTTBranch (GADTType TBranch a)

castTBranch :: Exist TBranch -> IO (EGADTType TBranch)
castTBranch eobj = do 
  let obj = TBranch (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TBranch" -> case obj of
        TBranch fptr -> let obj' = TBranch (castForeignPtr fptr :: ForeignPtr RawTBranch)
                        in  return . EGADTTBranch . GADTTBranchTBranch $ obj'
    _         -> return . EGADTTBranch $ GADTTBranchBottom





instance GADTTypeable TFile where
  data GADTType TFile a where 
    GADTTFileTFile :: TFile -> GADTType TFile TFile
    GADTTFileBottom  :: GADTType TFile BottomType
  data EGADTType TFile = forall a. EGADTTFile (GADTType TFile a)

castTFile :: Exist TFile -> IO (EGADTType TFile)
castTFile eobj = do 
  let obj = TFile (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TFile" -> case obj of
        TFile fptr -> let obj' = TFile (castForeignPtr fptr :: ForeignPtr RawTFile)
                        in  return . EGADTTFile . GADTTFileTFile $ obj'
    _         -> return . EGADTTFile $ GADTTFileBottom





instance GADTTypeable TDirectoryFile where
  data GADTType TDirectoryFile a where 
    GADTTDirectoryFileTDirectoryFile :: TDirectoryFile -> GADTType TDirectoryFile TDirectoryFile
    GADTTDirectoryFileTFile :: TFile -> GADTType TDirectoryFile TFile
    GADTTDirectoryFileBottom  :: GADTType TDirectoryFile BottomType
  data EGADTType TDirectoryFile = forall a. EGADTTDirectoryFile (GADTType TDirectoryFile a)

castTDirectoryFile :: Exist TDirectoryFile -> IO (EGADTType TDirectoryFile)
castTDirectoryFile eobj = do 
  let obj = TDirectoryFile (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TDirectoryFile" -> case obj of
        TDirectoryFile fptr -> let obj' = TDirectoryFile (castForeignPtr fptr :: ForeignPtr RawTDirectoryFile)
                        in  return . EGADTTDirectoryFile . GADTTDirectoryFileTDirectoryFile $ obj'
    "TFile" -> case obj of
        TDirectoryFile fptr -> let obj' = TFile (castForeignPtr fptr :: ForeignPtr RawTFile)
                        in  return . EGADTTDirectoryFile . GADTTDirectoryFileTFile $ obj'
    _         -> return . EGADTTDirectoryFile $ GADTTDirectoryFileBottom





instance GADTTypeable TDirectory where
  data GADTType TDirectory a where 
    GADTTDirectoryTDirectory :: TDirectory -> GADTType TDirectory TDirectory
    GADTTDirectoryTDirectoryFile :: TDirectoryFile -> GADTType TDirectory TDirectoryFile
    GADTTDirectoryTFile :: TFile -> GADTType TDirectory TFile
    GADTTDirectoryBottom  :: GADTType TDirectory BottomType
  data EGADTType TDirectory = forall a. EGADTTDirectory (GADTType TDirectory a)

castTDirectory :: Exist TDirectory -> IO (EGADTType TDirectory)
castTDirectory eobj = do 
  let obj = TDirectory (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TDirectory" -> case obj of
        TDirectory fptr -> let obj' = TDirectory (castForeignPtr fptr :: ForeignPtr RawTDirectory)
                        in  return . EGADTTDirectory . GADTTDirectoryTDirectory $ obj'
    "TDirectoryFile" -> case obj of
        TDirectory fptr -> let obj' = TDirectoryFile (castForeignPtr fptr :: ForeignPtr RawTDirectoryFile)
                        in  return . EGADTTDirectory . GADTTDirectoryTDirectoryFile $ obj'
    "TFile" -> case obj of
        TDirectory fptr -> let obj' = TFile (castForeignPtr fptr :: ForeignPtr RawTFile)
                        in  return . EGADTTDirectory . GADTTDirectoryTFile $ obj'
    _         -> return . EGADTTDirectory $ GADTTDirectoryBottom





instance GADTTypeable TText where
  data GADTType TText a where 
    GADTTTextTLatex :: TLatex -> GADTType TText TLatex
    GADTTTextTText :: TText -> GADTType TText TText
    GADTTTextBottom  :: GADTType TText BottomType
  data EGADTType TText = forall a. EGADTTText (GADTType TText a)

castTText :: Exist TText -> IO (EGADTType TText)
castTText eobj = do 
  let obj = TText (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TLatex" -> case obj of
        TText fptr -> let obj' = TLatex (castForeignPtr fptr :: ForeignPtr RawTLatex)
                        in  return . EGADTTText . GADTTTextTLatex $ obj'
    "TText" -> case obj of
        TText fptr -> let obj' = TText (castForeignPtr fptr :: ForeignPtr RawTText)
                        in  return . EGADTTText . GADTTTextTText $ obj'
    _         -> return . EGADTTText $ GADTTTextBottom





instance GADTTypeable TLatex where
  data GADTType TLatex a where 
    GADTTLatexTLatex :: TLatex -> GADTType TLatex TLatex
    GADTTLatexBottom  :: GADTType TLatex BottomType
  data EGADTType TLatex = forall a. EGADTTLatex (GADTType TLatex a)

castTLatex :: Exist TLatex -> IO (EGADTType TLatex)
castTLatex eobj = do 
  let obj = TLatex (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TLatex" -> case obj of
        TLatex fptr -> let obj' = TLatex (castForeignPtr fptr :: ForeignPtr RawTLatex)
                        in  return . EGADTTLatex . GADTTLatexTLatex $ obj'
    _         -> return . EGADTTLatex $ GADTTLatexBottom





instance GADTTypeable TAxis where
  data GADTType TAxis a where 
    GADTTAxisTAxis :: TAxis -> GADTType TAxis TAxis
    GADTTAxisBottom  :: GADTType TAxis BottomType
  data EGADTType TAxis = forall a. EGADTTAxis (GADTType TAxis a)

castTAxis :: Exist TAxis -> IO (EGADTType TAxis)
castTAxis eobj = do 
  let obj = TAxis (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TAxis" -> case obj of
        TAxis fptr -> let obj' = TAxis (castForeignPtr fptr :: ForeignPtr RawTAxis)
                        in  return . EGADTTAxis . GADTTAxisTAxis $ obj'
    _         -> return . EGADTTAxis $ GADTTAxisBottom





instance GADTTypeable TEfficiency where
  data GADTType TEfficiency a where 
    GADTTEfficiencyTEfficiency :: TEfficiency -> GADTType TEfficiency TEfficiency
    GADTTEfficiencyBottom  :: GADTType TEfficiency BottomType
  data EGADTType TEfficiency = forall a. EGADTTEfficiency (GADTType TEfficiency a)

castTEfficiency :: Exist TEfficiency -> IO (EGADTType TEfficiency)
castTEfficiency eobj = do 
  let obj = TEfficiency (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TEfficiency" -> case obj of
        TEfficiency fptr -> let obj' = TEfficiency (castForeignPtr fptr :: ForeignPtr RawTEfficiency)
                        in  return . EGADTTEfficiency . GADTTEfficiencyTEfficiency $ obj'
    _         -> return . EGADTTEfficiency $ GADTTEfficiencyBottom





instance GADTTypeable TCurlyArc where
  data GADTType TCurlyArc a where 
    GADTTCurlyArcTCurlyArc :: TCurlyArc -> GADTType TCurlyArc TCurlyArc
    GADTTCurlyArcBottom  :: GADTType TCurlyArc BottomType
  data EGADTType TCurlyArc = forall a. EGADTTCurlyArc (GADTType TCurlyArc a)

castTCurlyArc :: Exist TCurlyArc -> IO (EGADTType TCurlyArc)
castTCurlyArc eobj = do 
  let obj = TCurlyArc (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TCurlyArc" -> case obj of
        TCurlyArc fptr -> let obj' = TCurlyArc (castForeignPtr fptr :: ForeignPtr RawTCurlyArc)
                        in  return . EGADTTCurlyArc . GADTTCurlyArcTCurlyArc $ obj'
    _         -> return . EGADTTCurlyArc $ GADTTCurlyArcBottom





instance GADTTypeable TCurlyLine where
  data GADTType TCurlyLine a where 
    GADTTCurlyLineTCurlyLine :: TCurlyLine -> GADTType TCurlyLine TCurlyLine
    GADTTCurlyLineTCurlyArc :: TCurlyArc -> GADTType TCurlyLine TCurlyArc
    GADTTCurlyLineBottom  :: GADTType TCurlyLine BottomType
  data EGADTType TCurlyLine = forall a. EGADTTCurlyLine (GADTType TCurlyLine a)

castTCurlyLine :: Exist TCurlyLine -> IO (EGADTType TCurlyLine)
castTCurlyLine eobj = do 
  let obj = TCurlyLine (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TCurlyLine" -> case obj of
        TCurlyLine fptr -> let obj' = TCurlyLine (castForeignPtr fptr :: ForeignPtr RawTCurlyLine)
                        in  return . EGADTTCurlyLine . GADTTCurlyLineTCurlyLine $ obj'
    "TCurlyArc" -> case obj of
        TCurlyLine fptr -> let obj' = TCurlyArc (castForeignPtr fptr :: ForeignPtr RawTCurlyArc)
                        in  return . EGADTTCurlyLine . GADTTCurlyLineTCurlyArc $ obj'
    _         -> return . EGADTTCurlyLine $ GADTTCurlyLineBottom





instance GADTTypeable TPolyLine where
  data GADTType TPolyLine a where 
    GADTTPolyLineTPolyLine :: TPolyLine -> GADTType TPolyLine TPolyLine
    GADTTPolyLineTCurlyLine :: TCurlyLine -> GADTType TPolyLine TCurlyLine
    GADTTPolyLineTCurlyArc :: TCurlyArc -> GADTType TPolyLine TCurlyArc
    GADTTPolyLineBottom  :: GADTType TPolyLine BottomType
  data EGADTType TPolyLine = forall a. EGADTTPolyLine (GADTType TPolyLine a)

castTPolyLine :: Exist TPolyLine -> IO (EGADTType TPolyLine)
castTPolyLine eobj = do 
  let obj = TPolyLine (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TPolyLine" -> case obj of
        TPolyLine fptr -> let obj' = TPolyLine (castForeignPtr fptr :: ForeignPtr RawTPolyLine)
                        in  return . EGADTTPolyLine . GADTTPolyLineTPolyLine $ obj'
    "TCurlyLine" -> case obj of
        TPolyLine fptr -> let obj' = TCurlyLine (castForeignPtr fptr :: ForeignPtr RawTCurlyLine)
                        in  return . EGADTTPolyLine . GADTTPolyLineTCurlyLine $ obj'
    "TCurlyArc" -> case obj of
        TPolyLine fptr -> let obj' = TCurlyArc (castForeignPtr fptr :: ForeignPtr RawTCurlyArc)
                        in  return . EGADTTPolyLine . GADTTPolyLineTCurlyArc $ obj'
    _         -> return . EGADTTPolyLine $ GADTTPolyLineBottom





instance GADTTypeable TTreeSQL where
  data GADTType TTreeSQL a where 
    GADTTTreeSQLTTreeSQL :: TTreeSQL -> GADTType TTreeSQL TTreeSQL
    GADTTTreeSQLBottom  :: GADTType TTreeSQL BottomType
  data EGADTType TTreeSQL = forall a. EGADTTTreeSQL (GADTType TTreeSQL a)

castTTreeSQL :: Exist TTreeSQL -> IO (EGADTType TTreeSQL)
castTTreeSQL eobj = do 
  let obj = TTreeSQL (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TTreeSQL" -> case obj of
        TTreeSQL fptr -> let obj' = TTreeSQL (castForeignPtr fptr :: ForeignPtr RawTTreeSQL)
                        in  return . EGADTTTreeSQL . GADTTTreeSQLTTreeSQL $ obj'
    _         -> return . EGADTTTreeSQL $ GADTTTreeSQLBottom





instance GADTTypeable TNtupleD where
  data GADTType TNtupleD a where 
    GADTTNtupleDTNtupleD :: TNtupleD -> GADTType TNtupleD TNtupleD
    GADTTNtupleDBottom  :: GADTType TNtupleD BottomType
  data EGADTType TNtupleD = forall a. EGADTTNtupleD (GADTType TNtupleD a)

castTNtupleD :: Exist TNtupleD -> IO (EGADTType TNtupleD)
castTNtupleD eobj = do 
  let obj = TNtupleD (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TNtupleD" -> case obj of
        TNtupleD fptr -> let obj' = TNtupleD (castForeignPtr fptr :: ForeignPtr RawTNtupleD)
                        in  return . EGADTTNtupleD . GADTTNtupleDTNtupleD $ obj'
    _         -> return . EGADTTNtupleD $ GADTTNtupleDBottom





instance GADTTypeable TNtuple where
  data GADTType TNtuple a where 
    GADTTNtupleTNtuple :: TNtuple -> GADTType TNtuple TNtuple
    GADTTNtupleBottom  :: GADTType TNtuple BottomType
  data EGADTType TNtuple = forall a. EGADTTNtuple (GADTType TNtuple a)

castTNtuple :: Exist TNtuple -> IO (EGADTType TNtuple)
castTNtuple eobj = do 
  let obj = TNtuple (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TNtuple" -> case obj of
        TNtuple fptr -> let obj' = TNtuple (castForeignPtr fptr :: ForeignPtr RawTNtuple)
                        in  return . EGADTTNtuple . GADTTNtupleTNtuple $ obj'
    _         -> return . EGADTTNtuple $ GADTTNtupleBottom





instance GADTTypeable TChain where
  data GADTType TChain a where 
    GADTTChainTChain :: TChain -> GADTType TChain TChain
    GADTTChainBottom  :: GADTType TChain BottomType
  data EGADTType TChain = forall a. EGADTTChain (GADTType TChain a)

castTChain :: Exist TChain -> IO (EGADTType TChain)
castTChain eobj = do 
  let obj = TChain (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TChain" -> case obj of
        TChain fptr -> let obj' = TChain (castForeignPtr fptr :: ForeignPtr RawTChain)
                        in  return . EGADTTChain . GADTTChainTChain $ obj'
    _         -> return . EGADTTChain $ GADTTChainBottom





instance GADTTypeable TTree where
  data GADTType TTree a where 
    GADTTTreeTTree :: TTree -> GADTType TTree TTree
    GADTTTreeTChain :: TChain -> GADTType TTree TChain
    GADTTTreeTNtuple :: TNtuple -> GADTType TTree TNtuple
    GADTTTreeTNtupleD :: TNtupleD -> GADTType TTree TNtupleD
    GADTTTreeTTreeSQL :: TTreeSQL -> GADTType TTree TTreeSQL
    GADTTTreeBottom  :: GADTType TTree BottomType
  data EGADTType TTree = forall a. EGADTTTree (GADTType TTree a)

castTTree :: Exist TTree -> IO (EGADTType TTree)
castTTree eobj = do 
  let obj = TTree (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TTree" -> case obj of
        TTree fptr -> let obj' = TTree (castForeignPtr fptr :: ForeignPtr RawTTree)
                        in  return . EGADTTTree . GADTTTreeTTree $ obj'
    "TChain" -> case obj of
        TTree fptr -> let obj' = TChain (castForeignPtr fptr :: ForeignPtr RawTChain)
                        in  return . EGADTTTree . GADTTTreeTChain $ obj'
    "TNtuple" -> case obj of
        TTree fptr -> let obj' = TNtuple (castForeignPtr fptr :: ForeignPtr RawTNtuple)
                        in  return . EGADTTTree . GADTTTreeTNtuple $ obj'
    "TNtupleD" -> case obj of
        TTree fptr -> let obj' = TNtupleD (castForeignPtr fptr :: ForeignPtr RawTNtupleD)
                        in  return . EGADTTTree . GADTTTreeTNtupleD $ obj'
    "TTreeSQL" -> case obj of
        TTree fptr -> let obj' = TTreeSQL (castForeignPtr fptr :: ForeignPtr RawTTreeSQL)
                        in  return . EGADTTTree . GADTTTreeTTreeSQL $ obj'
    _         -> return . EGADTTTree $ GADTTTreeBottom





instance GADTTypeable TSliderBox where
  data GADTType TSliderBox a where 
    GADTTSliderBoxTSliderBox :: TSliderBox -> GADTType TSliderBox TSliderBox
    GADTTSliderBoxBottom  :: GADTType TSliderBox BottomType
  data EGADTType TSliderBox = forall a. EGADTTSliderBox (GADTType TSliderBox a)

castTSliderBox :: Exist TSliderBox -> IO (EGADTType TSliderBox)
castTSliderBox eobj = do 
  let obj = TSliderBox (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TSliderBox" -> case obj of
        TSliderBox fptr -> let obj' = TSliderBox (castForeignPtr fptr :: ForeignPtr RawTSliderBox)
                        in  return . EGADTTSliderBox . GADTTSliderBoxTSliderBox $ obj'
    _         -> return . EGADTTSliderBox $ GADTTSliderBoxBottom





instance GADTTypeable TFrame where
  data GADTType TFrame a where 
    GADTTFrameTFrame :: TFrame -> GADTType TFrame TFrame
    GADTTFrameBottom  :: GADTType TFrame BottomType
  data EGADTType TFrame = forall a. EGADTTFrame (GADTType TFrame a)

castTFrame :: Exist TFrame -> IO (EGADTType TFrame)
castTFrame eobj = do 
  let obj = TFrame (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TFrame" -> case obj of
        TFrame fptr -> let obj' = TFrame (castForeignPtr fptr :: ForeignPtr RawTFrame)
                        in  return . EGADTTFrame . GADTTFrameTFrame $ obj'
    _         -> return . EGADTTFrame $ GADTTFrameBottom





instance GADTTypeable TWbox where
  data GADTType TWbox a where 
    GADTTWboxTWbox :: TWbox -> GADTType TWbox TWbox
    GADTTWboxTFrame :: TFrame -> GADTType TWbox TFrame
    GADTTWboxTSliderBox :: TSliderBox -> GADTType TWbox TSliderBox
    GADTTWboxBottom  :: GADTType TWbox BottomType
  data EGADTType TWbox = forall a. EGADTTWbox (GADTType TWbox a)

castTWbox :: Exist TWbox -> IO (EGADTType TWbox)
castTWbox eobj = do 
  let obj = TWbox (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TWbox" -> case obj of
        TWbox fptr -> let obj' = TWbox (castForeignPtr fptr :: ForeignPtr RawTWbox)
                        in  return . EGADTTWbox . GADTTWboxTWbox $ obj'
    "TFrame" -> case obj of
        TWbox fptr -> let obj' = TFrame (castForeignPtr fptr :: ForeignPtr RawTFrame)
                        in  return . EGADTTWbox . GADTTWboxTFrame $ obj'
    "TSliderBox" -> case obj of
        TWbox fptr -> let obj' = TSliderBox (castForeignPtr fptr :: ForeignPtr RawTSliderBox)
                        in  return . EGADTTWbox . GADTTWboxTSliderBox $ obj'
    _         -> return . EGADTTWbox $ GADTTWboxBottom





instance GADTTypeable TPaveClass where
  data GADTType TPaveClass a where 
    GADTTPaveClassTPaveClass :: TPaveClass -> GADTType TPaveClass TPaveClass
    GADTTPaveClassBottom  :: GADTType TPaveClass BottomType
  data EGADTType TPaveClass = forall a. EGADTTPaveClass (GADTType TPaveClass a)

castTPaveClass :: Exist TPaveClass -> IO (EGADTType TPaveClass)
castTPaveClass eobj = do 
  let obj = TPaveClass (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TPaveClass" -> case obj of
        TPaveClass fptr -> let obj' = TPaveClass (castForeignPtr fptr :: ForeignPtr RawTPaveClass)
                        in  return . EGADTTPaveClass . GADTTPaveClassTPaveClass $ obj'
    _         -> return . EGADTTPaveClass $ GADTTPaveClassBottom





instance GADTTypeable TPaveLabel where
  data GADTType TPaveLabel a where 
    GADTTPaveLabelTPaveLabel :: TPaveLabel -> GADTType TPaveLabel TPaveLabel
    GADTTPaveLabelTPaveClass :: TPaveClass -> GADTType TPaveLabel TPaveClass
    GADTTPaveLabelBottom  :: GADTType TPaveLabel BottomType
  data EGADTType TPaveLabel = forall a. EGADTTPaveLabel (GADTType TPaveLabel a)

castTPaveLabel :: Exist TPaveLabel -> IO (EGADTType TPaveLabel)
castTPaveLabel eobj = do 
  let obj = TPaveLabel (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TPaveLabel" -> case obj of
        TPaveLabel fptr -> let obj' = TPaveLabel (castForeignPtr fptr :: ForeignPtr RawTPaveLabel)
                        in  return . EGADTTPaveLabel . GADTTPaveLabelTPaveLabel $ obj'
    "TPaveClass" -> case obj of
        TPaveLabel fptr -> let obj' = TPaveClass (castForeignPtr fptr :: ForeignPtr RawTPaveClass)
                        in  return . EGADTTPaveLabel . GADTTPaveLabelTPaveClass $ obj'
    _         -> return . EGADTTPaveLabel $ GADTTPaveLabelBottom





instance GADTTypeable TLegendEntry where
  data GADTType TLegendEntry a where 
    GADTTLegendEntryTLegendEntry :: TLegendEntry -> GADTType TLegendEntry TLegendEntry
    GADTTLegendEntryBottom  :: GADTType TLegendEntry BottomType
  data EGADTType TLegendEntry = forall a. EGADTTLegendEntry (GADTType TLegendEntry a)

castTLegendEntry :: Exist TLegendEntry -> IO (EGADTType TLegendEntry)
castTLegendEntry eobj = do 
  let obj = TLegendEntry (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TLegendEntry" -> case obj of
        TLegendEntry fptr -> let obj' = TLegendEntry (castForeignPtr fptr :: ForeignPtr RawTLegendEntry)
                        in  return . EGADTTLegendEntry . GADTTLegendEntryTLegendEntry $ obj'
    _         -> return . EGADTTLegendEntry $ GADTTLegendEntryBottom





instance GADTTypeable TLegend where
  data GADTType TLegend a where 
    GADTTLegendTLegend :: TLegend -> GADTType TLegend TLegend
    GADTTLegendBottom  :: GADTType TLegend BottomType
  data EGADTType TLegend = forall a. EGADTTLegend (GADTType TLegend a)

castTLegend :: Exist TLegend -> IO (EGADTType TLegend)
castTLegend eobj = do 
  let obj = TLegend (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TLegend" -> case obj of
        TLegend fptr -> let obj' = TLegend (castForeignPtr fptr :: ForeignPtr RawTLegend)
                        in  return . EGADTTLegend . GADTTLegendTLegend $ obj'
    _         -> return . EGADTTLegend $ GADTTLegendBottom





instance GADTTypeable TPavesText where
  data GADTType TPavesText a where 
    GADTTPavesTextTPavesText :: TPavesText -> GADTType TPavesText TPavesText
    GADTTPavesTextBottom  :: GADTType TPavesText BottomType
  data EGADTType TPavesText = forall a. EGADTTPavesText (GADTType TPavesText a)

castTPavesText :: Exist TPavesText -> IO (EGADTType TPavesText)
castTPavesText eobj = do 
  let obj = TPavesText (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TPavesText" -> case obj of
        TPavesText fptr -> let obj' = TPavesText (castForeignPtr fptr :: ForeignPtr RawTPavesText)
                        in  return . EGADTTPavesText . GADTTPavesTextTPavesText $ obj'
    _         -> return . EGADTTPavesText $ GADTTPavesTextBottom





instance GADTTypeable TPaveStats where
  data GADTType TPaveStats a where 
    GADTTPaveStatsTPaveStats :: TPaveStats -> GADTType TPaveStats TPaveStats
    GADTTPaveStatsBottom  :: GADTType TPaveStats BottomType
  data EGADTType TPaveStats = forall a. EGADTTPaveStats (GADTType TPaveStats a)

castTPaveStats :: Exist TPaveStats -> IO (EGADTType TPaveStats)
castTPaveStats eobj = do 
  let obj = TPaveStats (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TPaveStats" -> case obj of
        TPaveStats fptr -> let obj' = TPaveStats (castForeignPtr fptr :: ForeignPtr RawTPaveStats)
                        in  return . EGADTTPaveStats . GADTTPaveStatsTPaveStats $ obj'
    _         -> return . EGADTTPaveStats $ GADTTPaveStatsBottom





instance GADTTypeable TDiamond where
  data GADTType TDiamond a where 
    GADTTDiamondTDiamond :: TDiamond -> GADTType TDiamond TDiamond
    GADTTDiamondBottom  :: GADTType TDiamond BottomType
  data EGADTType TDiamond = forall a. EGADTTDiamond (GADTType TDiamond a)

castTDiamond :: Exist TDiamond -> IO (EGADTType TDiamond)
castTDiamond eobj = do 
  let obj = TDiamond (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TDiamond" -> case obj of
        TDiamond fptr -> let obj' = TDiamond (castForeignPtr fptr :: ForeignPtr RawTDiamond)
                        in  return . EGADTTDiamond . GADTTDiamondTDiamond $ obj'
    _         -> return . EGADTTDiamond $ GADTTDiamondBottom





instance GADTTypeable TPaveText where
  data GADTType TPaveText a where 
    GADTTPaveTextTPaveText :: TPaveText -> GADTType TPaveText TPaveText
    GADTTPaveTextTDiamond :: TDiamond -> GADTType TPaveText TDiamond
    GADTTPaveTextTPaveStats :: TPaveStats -> GADTType TPaveText TPaveStats
    GADTTPaveTextTPavesText :: TPavesText -> GADTType TPaveText TPavesText
    GADTTPaveTextBottom  :: GADTType TPaveText BottomType
  data EGADTType TPaveText = forall a. EGADTTPaveText (GADTType TPaveText a)

castTPaveText :: Exist TPaveText -> IO (EGADTType TPaveText)
castTPaveText eobj = do 
  let obj = TPaveText (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TPaveText" -> case obj of
        TPaveText fptr -> let obj' = TPaveText (castForeignPtr fptr :: ForeignPtr RawTPaveText)
                        in  return . EGADTTPaveText . GADTTPaveTextTPaveText $ obj'
    "TDiamond" -> case obj of
        TPaveText fptr -> let obj' = TDiamond (castForeignPtr fptr :: ForeignPtr RawTDiamond)
                        in  return . EGADTTPaveText . GADTTPaveTextTDiamond $ obj'
    "TPaveStats" -> case obj of
        TPaveText fptr -> let obj' = TPaveStats (castForeignPtr fptr :: ForeignPtr RawTPaveStats)
                        in  return . EGADTTPaveText . GADTTPaveTextTPaveStats $ obj'
    "TPavesText" -> case obj of
        TPaveText fptr -> let obj' = TPavesText (castForeignPtr fptr :: ForeignPtr RawTPavesText)
                        in  return . EGADTTPaveText . GADTTPaveTextTPavesText $ obj'
    _         -> return . EGADTTPaveText $ GADTTPaveTextBottom





instance GADTTypeable TPave where
  data GADTType TPave a where 
    GADTTPaveTPave :: TPave -> GADTType TPave TPave
    GADTTPaveTPaveText :: TPaveText -> GADTType TPave TPaveText
    GADTTPaveTDiamond :: TDiamond -> GADTType TPave TDiamond
    GADTTPaveTPaveStats :: TPaveStats -> GADTType TPave TPaveStats
    GADTTPaveTPavesText :: TPavesText -> GADTType TPave TPavesText
    GADTTPaveTLegend :: TLegend -> GADTType TPave TLegend
    GADTTPaveTPaveLabel :: TPaveLabel -> GADTType TPave TPaveLabel
    GADTTPaveTPaveClass :: TPaveClass -> GADTType TPave TPaveClass
    GADTTPaveBottom  :: GADTType TPave BottomType
  data EGADTType TPave = forall a. EGADTTPave (GADTType TPave a)

castTPave :: Exist TPave -> IO (EGADTType TPave)
castTPave eobj = do 
  let obj = TPave (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TPave" -> case obj of
        TPave fptr -> let obj' = TPave (castForeignPtr fptr :: ForeignPtr RawTPave)
                        in  return . EGADTTPave . GADTTPaveTPave $ obj'
    "TPaveText" -> case obj of
        TPave fptr -> let obj' = TPaveText (castForeignPtr fptr :: ForeignPtr RawTPaveText)
                        in  return . EGADTTPave . GADTTPaveTPaveText $ obj'
    "TDiamond" -> case obj of
        TPave fptr -> let obj' = TDiamond (castForeignPtr fptr :: ForeignPtr RawTDiamond)
                        in  return . EGADTTPave . GADTTPaveTDiamond $ obj'
    "TPaveStats" -> case obj of
        TPave fptr -> let obj' = TPaveStats (castForeignPtr fptr :: ForeignPtr RawTPaveStats)
                        in  return . EGADTTPave . GADTTPaveTPaveStats $ obj'
    "TPavesText" -> case obj of
        TPave fptr -> let obj' = TPavesText (castForeignPtr fptr :: ForeignPtr RawTPavesText)
                        in  return . EGADTTPave . GADTTPaveTPavesText $ obj'
    "TLegend" -> case obj of
        TPave fptr -> let obj' = TLegend (castForeignPtr fptr :: ForeignPtr RawTLegend)
                        in  return . EGADTTPave . GADTTPaveTLegend $ obj'
    "TPaveLabel" -> case obj of
        TPave fptr -> let obj' = TPaveLabel (castForeignPtr fptr :: ForeignPtr RawTPaveLabel)
                        in  return . EGADTTPave . GADTTPaveTPaveLabel $ obj'
    "TPaveClass" -> case obj of
        TPave fptr -> let obj' = TPaveClass (castForeignPtr fptr :: ForeignPtr RawTPaveClass)
                        in  return . EGADTTPave . GADTTPaveTPaveClass $ obj'
    _         -> return . EGADTTPave $ GADTTPaveBottom





instance GADTTypeable TBox where
  data GADTType TBox a where 
    GADTTBoxTBox :: TBox -> GADTType TBox TBox
    GADTTBoxTPave :: TPave -> GADTType TBox TPave
    GADTTBoxTPaveText :: TPaveText -> GADTType TBox TPaveText
    GADTTBoxTDiamond :: TDiamond -> GADTType TBox TDiamond
    GADTTBoxTPaveStats :: TPaveStats -> GADTType TBox TPaveStats
    GADTTBoxTPavesText :: TPavesText -> GADTType TBox TPavesText
    GADTTBoxTLegend :: TLegend -> GADTType TBox TLegend
    GADTTBoxTPaveLabel :: TPaveLabel -> GADTType TBox TPaveLabel
    GADTTBoxTPaveClass :: TPaveClass -> GADTType TBox TPaveClass
    GADTTBoxTWbox :: TWbox -> GADTType TBox TWbox
    GADTTBoxTFrame :: TFrame -> GADTType TBox TFrame
    GADTTBoxTSliderBox :: TSliderBox -> GADTType TBox TSliderBox
    GADTTBoxBottom  :: GADTType TBox BottomType
  data EGADTType TBox = forall a. EGADTTBox (GADTType TBox a)

castTBox :: Exist TBox -> IO (EGADTType TBox)
castTBox eobj = do 
  let obj = TBox (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TBox" -> case obj of
        TBox fptr -> let obj' = TBox (castForeignPtr fptr :: ForeignPtr RawTBox)
                        in  return . EGADTTBox . GADTTBoxTBox $ obj'
    "TPave" -> case obj of
        TBox fptr -> let obj' = TPave (castForeignPtr fptr :: ForeignPtr RawTPave)
                        in  return . EGADTTBox . GADTTBoxTPave $ obj'
    "TPaveText" -> case obj of
        TBox fptr -> let obj' = TPaveText (castForeignPtr fptr :: ForeignPtr RawTPaveText)
                        in  return . EGADTTBox . GADTTBoxTPaveText $ obj'
    "TDiamond" -> case obj of
        TBox fptr -> let obj' = TDiamond (castForeignPtr fptr :: ForeignPtr RawTDiamond)
                        in  return . EGADTTBox . GADTTBoxTDiamond $ obj'
    "TPaveStats" -> case obj of
        TBox fptr -> let obj' = TPaveStats (castForeignPtr fptr :: ForeignPtr RawTPaveStats)
                        in  return . EGADTTBox . GADTTBoxTPaveStats $ obj'
    "TPavesText" -> case obj of
        TBox fptr -> let obj' = TPavesText (castForeignPtr fptr :: ForeignPtr RawTPavesText)
                        in  return . EGADTTBox . GADTTBoxTPavesText $ obj'
    "TLegend" -> case obj of
        TBox fptr -> let obj' = TLegend (castForeignPtr fptr :: ForeignPtr RawTLegend)
                        in  return . EGADTTBox . GADTTBoxTLegend $ obj'
    "TPaveLabel" -> case obj of
        TBox fptr -> let obj' = TPaveLabel (castForeignPtr fptr :: ForeignPtr RawTPaveLabel)
                        in  return . EGADTTBox . GADTTBoxTPaveLabel $ obj'
    "TPaveClass" -> case obj of
        TBox fptr -> let obj' = TPaveClass (castForeignPtr fptr :: ForeignPtr RawTPaveClass)
                        in  return . EGADTTBox . GADTTBoxTPaveClass $ obj'
    "TWbox" -> case obj of
        TBox fptr -> let obj' = TWbox (castForeignPtr fptr :: ForeignPtr RawTWbox)
                        in  return . EGADTTBox . GADTTBoxTWbox $ obj'
    "TFrame" -> case obj of
        TBox fptr -> let obj' = TFrame (castForeignPtr fptr :: ForeignPtr RawTFrame)
                        in  return . EGADTTBox . GADTTBoxTFrame $ obj'
    "TSliderBox" -> case obj of
        TBox fptr -> let obj' = TSliderBox (castForeignPtr fptr :: ForeignPtr RawTSliderBox)
                        in  return . EGADTTBox . GADTTBoxTSliderBox $ obj'
    _         -> return . EGADTTBox $ GADTTBoxBottom





instance GADTTypeable TXTRU where
  data GADTType TXTRU a where 
    GADTTXTRUTXTRU :: TXTRU -> GADTType TXTRU TXTRU
    GADTTXTRUBottom  :: GADTType TXTRU BottomType
  data EGADTType TXTRU = forall a. EGADTTXTRU (GADTType TXTRU a)

castTXTRU :: Exist TXTRU -> IO (EGADTType TXTRU)
castTXTRU eobj = do 
  let obj = TXTRU (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TXTRU" -> case obj of
        TXTRU fptr -> let obj' = TXTRU (castForeignPtr fptr :: ForeignPtr RawTXTRU)
                        in  return . EGADTTXTRU . GADTTXTRUTXTRU $ obj'
    _         -> return . EGADTTXTRU $ GADTTXTRUBottom





instance GADTTypeable TSPHE where
  data GADTType TSPHE a where 
    GADTTSPHETSPHE :: TSPHE -> GADTType TSPHE TSPHE
    GADTTSPHEBottom  :: GADTType TSPHE BottomType
  data EGADTType TSPHE = forall a. EGADTTSPHE (GADTType TSPHE a)

castTSPHE :: Exist TSPHE -> IO (EGADTType TSPHE)
castTSPHE eobj = do 
  let obj = TSPHE (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TSPHE" -> case obj of
        TSPHE fptr -> let obj' = TSPHE (castForeignPtr fptr :: ForeignPtr RawTSPHE)
                        in  return . EGADTTSPHE . GADTTSPHETSPHE $ obj'
    _         -> return . EGADTTSPHE $ GADTTSPHEBottom





instance GADTTypeable TPCON where
  data GADTType TPCON a where 
    GADTTPCONTPCON :: TPCON -> GADTType TPCON TPCON
    GADTTPCONBottom  :: GADTType TPCON BottomType
  data EGADTType TPCON = forall a. EGADTTPCON (GADTType TPCON a)

castTPCON :: Exist TPCON -> IO (EGADTType TPCON)
castTPCON eobj = do 
  let obj = TPCON (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TPCON" -> case obj of
        TPCON fptr -> let obj' = TPCON (castForeignPtr fptr :: ForeignPtr RawTPCON)
                        in  return . EGADTTPCON . GADTTPCONTPCON $ obj'
    _         -> return . EGADTTPCON $ GADTTPCONBottom





instance GADTTypeable TTUBE where
  data GADTType TTUBE a where 
    GADTTTUBETTUBE :: TTUBE -> GADTType TTUBE TTUBE
    GADTTTUBEBottom  :: GADTType TTUBE BottomType
  data EGADTType TTUBE = forall a. EGADTTTUBE (GADTType TTUBE a)

castTTUBE :: Exist TTUBE -> IO (EGADTType TTUBE)
castTTUBE eobj = do 
  let obj = TTUBE (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TTUBE" -> case obj of
        TTUBE fptr -> let obj' = TTUBE (castForeignPtr fptr :: ForeignPtr RawTTUBE)
                        in  return . EGADTTTUBE . GADTTTUBETTUBE $ obj'
    _         -> return . EGADTTTUBE $ GADTTTUBEBottom





instance GADTTypeable TBRIK where
  data GADTType TBRIK a where 
    GADTTBRIKTBRIK :: TBRIK -> GADTType TBRIK TBRIK
    GADTTBRIKBottom  :: GADTType TBRIK BottomType
  data EGADTType TBRIK = forall a. EGADTTBRIK (GADTType TBRIK a)

castTBRIK :: Exist TBRIK -> IO (EGADTType TBRIK)
castTBRIK eobj = do 
  let obj = TBRIK (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TBRIK" -> case obj of
        TBRIK fptr -> let obj' = TBRIK (castForeignPtr fptr :: ForeignPtr RawTBRIK)
                        in  return . EGADTTBRIK . GADTTBRIKTBRIK $ obj'
    _         -> return . EGADTTBRIK $ GADTTBRIKBottom





instance GADTTypeable TShape where
  data GADTType TShape a where 
    GADTTShapeTShape :: TShape -> GADTType TShape TShape
    GADTTShapeTBRIK :: TBRIK -> GADTType TShape TBRIK
    GADTTShapeTTUBE :: TTUBE -> GADTType TShape TTUBE
    GADTTShapeTPCON :: TPCON -> GADTType TShape TPCON
    GADTTShapeTSPHE :: TSPHE -> GADTType TShape TSPHE
    GADTTShapeTXTRU :: TXTRU -> GADTType TShape TXTRU
    GADTTShapeBottom  :: GADTType TShape BottomType
  data EGADTType TShape = forall a. EGADTTShape (GADTType TShape a)

castTShape :: Exist TShape -> IO (EGADTType TShape)
castTShape eobj = do 
  let obj = TShape (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TShape" -> case obj of
        TShape fptr -> let obj' = TShape (castForeignPtr fptr :: ForeignPtr RawTShape)
                        in  return . EGADTTShape . GADTTShapeTShape $ obj'
    "TBRIK" -> case obj of
        TShape fptr -> let obj' = TBRIK (castForeignPtr fptr :: ForeignPtr RawTBRIK)
                        in  return . EGADTTShape . GADTTShapeTBRIK $ obj'
    "TTUBE" -> case obj of
        TShape fptr -> let obj' = TTUBE (castForeignPtr fptr :: ForeignPtr RawTTUBE)
                        in  return . EGADTTShape . GADTTShapeTTUBE $ obj'
    "TPCON" -> case obj of
        TShape fptr -> let obj' = TPCON (castForeignPtr fptr :: ForeignPtr RawTPCON)
                        in  return . EGADTTShape . GADTTShapeTPCON $ obj'
    "TSPHE" -> case obj of
        TShape fptr -> let obj' = TSPHE (castForeignPtr fptr :: ForeignPtr RawTSPHE)
                        in  return . EGADTTShape . GADTTShapeTSPHE $ obj'
    "TXTRU" -> case obj of
        TShape fptr -> let obj' = TXTRU (castForeignPtr fptr :: ForeignPtr RawTXTRU)
                        in  return . EGADTTShape . GADTTShapeTXTRU $ obj'
    _         -> return . EGADTTShape $ GADTTShapeBottom





instance GADTTypeable TGaxis where
  data GADTType TGaxis a where 
    GADTTGaxisTGaxis :: TGaxis -> GADTType TGaxis TGaxis
    GADTTGaxisBottom  :: GADTType TGaxis BottomType
  data EGADTType TGaxis = forall a. EGADTTGaxis (GADTType TGaxis a)

castTGaxis :: Exist TGaxis -> IO (EGADTType TGaxis)
castTGaxis eobj = do 
  let obj = TGaxis (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TGaxis" -> case obj of
        TGaxis fptr -> let obj' = TGaxis (castForeignPtr fptr :: ForeignPtr RawTGaxis)
                        in  return . EGADTTGaxis . GADTTGaxisTGaxis $ obj'
    _         -> return . EGADTTGaxis $ GADTTGaxisBottom





instance GADTTypeable TArrow where
  data GADTType TArrow a where 
    GADTTArrowTArrow :: TArrow -> GADTType TArrow TArrow
    GADTTArrowBottom  :: GADTType TArrow BottomType
  data EGADTType TArrow = forall a. EGADTTArrow (GADTType TArrow a)

castTArrow :: Exist TArrow -> IO (EGADTType TArrow)
castTArrow eobj = do 
  let obj = TArrow (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TArrow" -> case obj of
        TArrow fptr -> let obj' = TArrow (castForeignPtr fptr :: ForeignPtr RawTArrow)
                        in  return . EGADTTArrow . GADTTArrowTArrow $ obj'
    _         -> return . EGADTTArrow $ GADTTArrowBottom





instance GADTTypeable TLine where
  data GADTType TLine a where 
    GADTTLineTLine :: TLine -> GADTType TLine TLine
    GADTTLineTArrow :: TArrow -> GADTType TLine TArrow
    GADTTLineTGaxis :: TGaxis -> GADTType TLine TGaxis
    GADTTLineBottom  :: GADTType TLine BottomType
  data EGADTType TLine = forall a. EGADTTLine (GADTType TLine a)

castTLine :: Exist TLine -> IO (EGADTType TLine)
castTLine eobj = do 
  let obj = TLine (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TLine" -> case obj of
        TLine fptr -> let obj' = TLine (castForeignPtr fptr :: ForeignPtr RawTLine)
                        in  return . EGADTTLine . GADTTLineTLine $ obj'
    "TArrow" -> case obj of
        TLine fptr -> let obj' = TArrow (castForeignPtr fptr :: ForeignPtr RawTArrow)
                        in  return . EGADTTLine . GADTTLineTArrow $ obj'
    "TGaxis" -> case obj of
        TLine fptr -> let obj' = TGaxis (castForeignPtr fptr :: ForeignPtr RawTGaxis)
                        in  return . EGADTTLine . GADTTLineTGaxis $ obj'
    _         -> return . EGADTTLine $ GADTTLineBottom





instance GADTTypeable TCrown where
  data GADTType TCrown a where 
    GADTTCrownTCrown :: TCrown -> GADTType TCrown TCrown
    GADTTCrownBottom  :: GADTType TCrown BottomType
  data EGADTType TCrown = forall a. EGADTTCrown (GADTType TCrown a)

castTCrown :: Exist TCrown -> IO (EGADTType TCrown)
castTCrown eobj = do 
  let obj = TCrown (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TCrown" -> case obj of
        TCrown fptr -> let obj' = TCrown (castForeignPtr fptr :: ForeignPtr RawTCrown)
                        in  return . EGADTTCrown . GADTTCrownTCrown $ obj'
    _         -> return . EGADTTCrown $ GADTTCrownBottom





instance GADTTypeable TArc where
  data GADTType TArc a where 
    GADTTArcTArc :: TArc -> GADTType TArc TArc
    GADTTArcBottom  :: GADTType TArc BottomType
  data EGADTType TArc = forall a. EGADTTArc (GADTType TArc a)

castTArc :: Exist TArc -> IO (EGADTType TArc)
castTArc eobj = do 
  let obj = TArc (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TArc" -> case obj of
        TArc fptr -> let obj' = TArc (castForeignPtr fptr :: ForeignPtr RawTArc)
                        in  return . EGADTTArc . GADTTArcTArc $ obj'
    _         -> return . EGADTTArc $ GADTTArcBottom





instance GADTTypeable TEllipse where
  data GADTType TEllipse a where 
    GADTTEllipseTEllipse :: TEllipse -> GADTType TEllipse TEllipse
    GADTTEllipseTArc :: TArc -> GADTType TEllipse TArc
    GADTTEllipseTCrown :: TCrown -> GADTType TEllipse TCrown
    GADTTEllipseBottom  :: GADTType TEllipse BottomType
  data EGADTType TEllipse = forall a. EGADTTEllipse (GADTType TEllipse a)

castTEllipse :: Exist TEllipse -> IO (EGADTType TEllipse)
castTEllipse eobj = do 
  let obj = TEllipse (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TEllipse" -> case obj of
        TEllipse fptr -> let obj' = TEllipse (castForeignPtr fptr :: ForeignPtr RawTEllipse)
                        in  return . EGADTTEllipse . GADTTEllipseTEllipse $ obj'
    "TArc" -> case obj of
        TEllipse fptr -> let obj' = TArc (castForeignPtr fptr :: ForeignPtr RawTArc)
                        in  return . EGADTTEllipse . GADTTEllipseTArc $ obj'
    "TCrown" -> case obj of
        TEllipse fptr -> let obj' = TCrown (castForeignPtr fptr :: ForeignPtr RawTCrown)
                        in  return . EGADTTEllipse . GADTTEllipseTCrown $ obj'
    _         -> return . EGADTTEllipse $ GADTTEllipseBottom





instance GADTTypeable TGraphQQ where
  data GADTType TGraphQQ a where 
    GADTTGraphQQTGraphQQ :: TGraphQQ -> GADTType TGraphQQ TGraphQQ
    GADTTGraphQQBottom  :: GADTType TGraphQQ BottomType
  data EGADTType TGraphQQ = forall a. EGADTTGraphQQ (GADTType TGraphQQ a)

castTGraphQQ :: Exist TGraphQQ -> IO (EGADTType TGraphQQ)
castTGraphQQ eobj = do 
  let obj = TGraphQQ (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TGraphQQ" -> case obj of
        TGraphQQ fptr -> let obj' = TGraphQQ (castForeignPtr fptr :: ForeignPtr RawTGraphQQ)
                        in  return . EGADTTGraphQQ . GADTTGraphQQTGraphQQ $ obj'
    _         -> return . EGADTTGraphQQ $ GADTTGraphQQBottom





instance GADTTypeable TGraphPolar where
  data GADTType TGraphPolar a where 
    GADTTGraphPolarTGraphPolar :: TGraphPolar -> GADTType TGraphPolar TGraphPolar
    GADTTGraphPolarBottom  :: GADTType TGraphPolar BottomType
  data EGADTType TGraphPolar = forall a. EGADTTGraphPolar (GADTType TGraphPolar a)

castTGraphPolar :: Exist TGraphPolar -> IO (EGADTType TGraphPolar)
castTGraphPolar eobj = do 
  let obj = TGraphPolar (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TGraphPolar" -> case obj of
        TGraphPolar fptr -> let obj' = TGraphPolar (castForeignPtr fptr :: ForeignPtr RawTGraphPolar)
                        in  return . EGADTTGraphPolar . GADTTGraphPolarTGraphPolar $ obj'
    _         -> return . EGADTTGraphPolar $ GADTTGraphPolarBottom





instance GADTTypeable TGraphErrors where
  data GADTType TGraphErrors a where 
    GADTTGraphErrorsTGraphErrors :: TGraphErrors -> GADTType TGraphErrors TGraphErrors
    GADTTGraphErrorsTGraphPolar :: TGraphPolar -> GADTType TGraphErrors TGraphPolar
    GADTTGraphErrorsBottom  :: GADTType TGraphErrors BottomType
  data EGADTType TGraphErrors = forall a. EGADTTGraphErrors (GADTType TGraphErrors a)

castTGraphErrors :: Exist TGraphErrors -> IO (EGADTType TGraphErrors)
castTGraphErrors eobj = do 
  let obj = TGraphErrors (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TGraphErrors" -> case obj of
        TGraphErrors fptr -> let obj' = TGraphErrors (castForeignPtr fptr :: ForeignPtr RawTGraphErrors)
                        in  return . EGADTTGraphErrors . GADTTGraphErrorsTGraphErrors $ obj'
    "TGraphPolar" -> case obj of
        TGraphErrors fptr -> let obj' = TGraphPolar (castForeignPtr fptr :: ForeignPtr RawTGraphPolar)
                        in  return . EGADTTGraphErrors . GADTTGraphErrorsTGraphPolar $ obj'
    _         -> return . EGADTTGraphErrors $ GADTTGraphErrorsBottom





instance GADTTypeable TGraphBentErrors where
  data GADTType TGraphBentErrors a where 
    GADTTGraphBentErrorsTGraphBentErrors :: TGraphBentErrors -> GADTType TGraphBentErrors TGraphBentErrors
    GADTTGraphBentErrorsBottom  :: GADTType TGraphBentErrors BottomType
  data EGADTType TGraphBentErrors = forall a. EGADTTGraphBentErrors (GADTType TGraphBentErrors a)

castTGraphBentErrors :: Exist TGraphBentErrors -> IO (EGADTType TGraphBentErrors)
castTGraphBentErrors eobj = do 
  let obj = TGraphBentErrors (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TGraphBentErrors" -> case obj of
        TGraphBentErrors fptr -> let obj' = TGraphBentErrors (castForeignPtr fptr :: ForeignPtr RawTGraphBentErrors)
                        in  return . EGADTTGraphBentErrors . GADTTGraphBentErrorsTGraphBentErrors $ obj'
    _         -> return . EGADTTGraphBentErrors $ GADTTGraphBentErrorsBottom





instance GADTTypeable TCutG where
  data GADTType TCutG a where 
    GADTTCutGTCutG :: TCutG -> GADTType TCutG TCutG
    GADTTCutGBottom  :: GADTType TCutG BottomType
  data EGADTType TCutG = forall a. EGADTTCutG (GADTType TCutG a)

castTCutG :: Exist TCutG -> IO (EGADTType TCutG)
castTCutG eobj = do 
  let obj = TCutG (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TCutG" -> case obj of
        TCutG fptr -> let obj' = TCutG (castForeignPtr fptr :: ForeignPtr RawTCutG)
                        in  return . EGADTTCutG . GADTTCutGTCutG $ obj'
    _         -> return . EGADTTCutG $ GADTTCutGBottom





instance GADTTypeable TGraphAsymmErrors where
  data GADTType TGraphAsymmErrors a where 
    GADTTGraphAsymmErrorsTGraphAsymmErrors :: TGraphAsymmErrors -> GADTType TGraphAsymmErrors TGraphAsymmErrors
    GADTTGraphAsymmErrorsBottom  :: GADTType TGraphAsymmErrors BottomType
  data EGADTType TGraphAsymmErrors = forall a. EGADTTGraphAsymmErrors (GADTType TGraphAsymmErrors a)

castTGraphAsymmErrors :: Exist TGraphAsymmErrors -> IO (EGADTType TGraphAsymmErrors)
castTGraphAsymmErrors eobj = do 
  let obj = TGraphAsymmErrors (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TGraphAsymmErrors" -> case obj of
        TGraphAsymmErrors fptr -> let obj' = TGraphAsymmErrors (castForeignPtr fptr :: ForeignPtr RawTGraphAsymmErrors)
                        in  return . EGADTTGraphAsymmErrors . GADTTGraphAsymmErrorsTGraphAsymmErrors $ obj'
    _         -> return . EGADTTGraphAsymmErrors $ GADTTGraphAsymmErrorsBottom





instance GADTTypeable TGraph where
  data GADTType TGraph a where 
    GADTTGraphTGraph :: TGraph -> GADTType TGraph TGraph
    GADTTGraphTGraphAsymmErrors :: TGraphAsymmErrors -> GADTType TGraph TGraphAsymmErrors
    GADTTGraphTCutG :: TCutG -> GADTType TGraph TCutG
    GADTTGraphTGraphBentErrors :: TGraphBentErrors -> GADTType TGraph TGraphBentErrors
    GADTTGraphTGraphErrors :: TGraphErrors -> GADTType TGraph TGraphErrors
    GADTTGraphTGraphPolar :: TGraphPolar -> GADTType TGraph TGraphPolar
    GADTTGraphTGraphQQ :: TGraphQQ -> GADTType TGraph TGraphQQ
    GADTTGraphBottom  :: GADTType TGraph BottomType
  data EGADTType TGraph = forall a. EGADTTGraph (GADTType TGraph a)

castTGraph :: Exist TGraph -> IO (EGADTType TGraph)
castTGraph eobj = do 
  let obj = TGraph (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TGraph" -> case obj of
        TGraph fptr -> let obj' = TGraph (castForeignPtr fptr :: ForeignPtr RawTGraph)
                        in  return . EGADTTGraph . GADTTGraphTGraph $ obj'
    "TGraphAsymmErrors" -> case obj of
        TGraph fptr -> let obj' = TGraphAsymmErrors (castForeignPtr fptr :: ForeignPtr RawTGraphAsymmErrors)
                        in  return . EGADTTGraph . GADTTGraphTGraphAsymmErrors $ obj'
    "TCutG" -> case obj of
        TGraph fptr -> let obj' = TCutG (castForeignPtr fptr :: ForeignPtr RawTCutG)
                        in  return . EGADTTGraph . GADTTGraphTCutG $ obj'
    "TGraphBentErrors" -> case obj of
        TGraph fptr -> let obj' = TGraphBentErrors (castForeignPtr fptr :: ForeignPtr RawTGraphBentErrors)
                        in  return . EGADTTGraph . GADTTGraphTGraphBentErrors $ obj'
    "TGraphErrors" -> case obj of
        TGraph fptr -> let obj' = TGraphErrors (castForeignPtr fptr :: ForeignPtr RawTGraphErrors)
                        in  return . EGADTTGraph . GADTTGraphTGraphErrors $ obj'
    "TGraphPolar" -> case obj of
        TGraph fptr -> let obj' = TGraphPolar (castForeignPtr fptr :: ForeignPtr RawTGraphPolar)
                        in  return . EGADTTGraph . GADTTGraphTGraphPolar $ obj'
    "TGraphQQ" -> case obj of
        TGraph fptr -> let obj' = TGraphQQ (castForeignPtr fptr :: ForeignPtr RawTGraphQQ)
                        in  return . EGADTTGraph . GADTTGraphTGraphQQ $ obj'
    _         -> return . EGADTTGraph $ GADTTGraphBottom





instance GADTTypeable TF1 where
  data GADTType TF1 a where 
    GADTTF1TF1 :: TF1 -> GADTType TF1 TF1
    GADTTF1Bottom  :: GADTType TF1 BottomType
  data EGADTType TF1 = forall a. EGADTTF1 (GADTType TF1 a)

castTF1 :: Exist TF1 -> IO (EGADTType TF1)
castTF1 eobj = do 
  let obj = TF1 (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TF1" -> case obj of
        TF1 fptr -> let obj' = TF1 (castForeignPtr fptr :: ForeignPtr RawTF1)
                        in  return . EGADTTF1 . GADTTF1TF1 $ obj'
    _         -> return . EGADTTF1 $ GADTTF1Bottom





instance GADTTypeable THStack where
  data GADTType THStack a where 
    GADTTHStackTHStack :: THStack -> GADTType THStack THStack
    GADTTHStackBottom  :: GADTType THStack BottomType
  data EGADTType THStack = forall a. EGADTTHStack (GADTType THStack a)

castTHStack :: Exist THStack -> IO (EGADTType THStack)
castTHStack eobj = do 
  let obj = THStack (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "THStack" -> case obj of
        THStack fptr -> let obj' = THStack (castForeignPtr fptr :: ForeignPtr RawTHStack)
                        in  return . EGADTTHStack . GADTTHStackTHStack $ obj'
    _         -> return . EGADTTHStack $ GADTTHStackBottom





instance GADTTypeable TAttParticle where
  data GADTType TAttParticle a where 
    GADTTAttParticleTAttParticle :: TAttParticle -> GADTType TAttParticle TAttParticle
    GADTTAttParticleBottom  :: GADTType TAttParticle BottomType
  data EGADTType TAttParticle = forall a. EGADTTAttParticle (GADTType TAttParticle a)

castTAttParticle :: Exist TAttParticle -> IO (EGADTType TAttParticle)
castTAttParticle eobj = do 
  let obj = TAttParticle (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TAttParticle" -> case obj of
        TAttParticle fptr -> let obj' = TAttParticle (castForeignPtr fptr :: ForeignPtr RawTAttParticle)
                        in  return . EGADTTAttParticle . GADTTAttParticleTAttParticle $ obj'
    _         -> return . EGADTTAttParticle $ GADTTAttParticleBottom





instance GADTTypeable TFormula where
  data GADTType TFormula a where 
    GADTTFormulaTFormula :: TFormula -> GADTType TFormula TFormula
    GADTTFormulaTF1 :: TF1 -> GADTType TFormula TF1
    GADTTFormulaBottom  :: GADTType TFormula BottomType
  data EGADTType TFormula = forall a. EGADTTFormula (GADTType TFormula a)

castTFormula :: Exist TFormula -> IO (EGADTType TFormula)
castTFormula eobj = do 
  let obj = TFormula (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TFormula" -> case obj of
        TFormula fptr -> let obj' = TFormula (castForeignPtr fptr :: ForeignPtr RawTFormula)
                        in  return . EGADTTFormula . GADTTFormulaTFormula $ obj'
    "TF1" -> case obj of
        TFormula fptr -> let obj' = TF1 (castForeignPtr fptr :: ForeignPtr RawTF1)
                        in  return . EGADTTFormula . GADTTFormulaTF1 $ obj'
    _         -> return . EGADTTFormula $ GADTTFormulaBottom





instance GADTTypeable TClass where
  data GADTType TClass a where 
    GADTTClassTClass :: TClass -> GADTType TClass TClass
    GADTTClassBottom  :: GADTType TClass BottomType
  data EGADTType TClass = forall a. EGADTTClass (GADTType TClass a)

castTClass :: Exist TClass -> IO (EGADTType TClass)
castTClass eobj = do 
  let obj = TClass (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TClass" -> case obj of
        TClass fptr -> let obj' = TClass (castForeignPtr fptr :: ForeignPtr RawTClass)
                        in  return . EGADTTClass . GADTTClassTClass $ obj'
    _         -> return . EGADTTClass $ GADTTClassBottom





instance GADTTypeable TNamed where
  data GADTType TNamed a where 
    GADTTNamedTNamed :: TNamed -> GADTType TNamed TNamed
    GADTTNamedTClass :: TClass -> GADTType TNamed TClass
    GADTTNamedTFormula :: TFormula -> GADTType TNamed TFormula
    GADTTNamedTAttParticle :: TAttParticle -> GADTType TNamed TAttParticle
    GADTTNamedTHStack :: THStack -> GADTType TNamed THStack
    GADTTNamedTF1 :: TF1 -> GADTType TNamed TF1
    GADTTNamedTGraph :: TGraph -> GADTType TNamed TGraph
    GADTTNamedTGraphAsymmErrors :: TGraphAsymmErrors -> GADTType TNamed TGraphAsymmErrors
    GADTTNamedTCutG :: TCutG -> GADTType TNamed TCutG
    GADTTNamedTGraphBentErrors :: TGraphBentErrors -> GADTType TNamed TGraphBentErrors
    GADTTNamedTGraphErrors :: TGraphErrors -> GADTType TNamed TGraphErrors
    GADTTNamedTGraphPolar :: TGraphPolar -> GADTType TNamed TGraphPolar
    GADTTNamedTGraphQQ :: TGraphQQ -> GADTType TNamed TGraphQQ
    GADTTNamedTShape :: TShape -> GADTType TNamed TShape
    GADTTNamedTBRIK :: TBRIK -> GADTType TNamed TBRIK
    GADTTNamedTTUBE :: TTUBE -> GADTType TNamed TTUBE
    GADTTNamedTPCON :: TPCON -> GADTType TNamed TPCON
    GADTTNamedTSPHE :: TSPHE -> GADTType TNamed TSPHE
    GADTTNamedTXTRU :: TXTRU -> GADTType TNamed TXTRU
    GADTTNamedTTree :: TTree -> GADTType TNamed TTree
    GADTTNamedTChain :: TChain -> GADTType TNamed TChain
    GADTTNamedTNtuple :: TNtuple -> GADTType TNamed TNtuple
    GADTTNamedTNtupleD :: TNtupleD -> GADTType TNamed TNtupleD
    GADTTNamedTTreeSQL :: TTreeSQL -> GADTType TNamed TTreeSQL
    GADTTNamedTEfficiency :: TEfficiency -> GADTType TNamed TEfficiency
    GADTTNamedTAxis :: TAxis -> GADTType TNamed TAxis
    GADTTNamedTLatex :: TLatex -> GADTType TNamed TLatex
    GADTTNamedTText :: TText -> GADTType TNamed TText
    GADTTNamedTDirectory :: TDirectory -> GADTType TNamed TDirectory
    GADTTNamedTDirectoryFile :: TDirectoryFile -> GADTType TNamed TDirectoryFile
    GADTTNamedTFile :: TFile -> GADTType TNamed TFile
    GADTTNamedTBranch :: TBranch -> GADTType TNamed TBranch
    GADTTNamedTH1 :: TH1 -> GADTType TNamed TH1
    GADTTNamedTH2 :: TH2 -> GADTType TNamed TH2
    GADTTNamedTH3 :: TH3 -> GADTType TNamed TH3
    GADTTNamedTH1C :: TH1C -> GADTType TNamed TH1C
    GADTTNamedTH1D :: TH1D -> GADTType TNamed TH1D
    GADTTNamedTH1F :: TH1F -> GADTType TNamed TH1F
    GADTTNamedTH1I :: TH1I -> GADTType TNamed TH1I
    GADTTNamedTH1S :: TH1S -> GADTType TNamed TH1S
    GADTTNamedTH2C :: TH2C -> GADTType TNamed TH2C
    GADTTNamedTH2D :: TH2D -> GADTType TNamed TH2D
    GADTTNamedTH2F :: TH2F -> GADTType TNamed TH2F
    GADTTNamedTH2I :: TH2I -> GADTType TNamed TH2I
    GADTTNamedTH2Poly :: TH2Poly -> GADTType TNamed TH2Poly
    GADTTNamedTH2S :: TH2S -> GADTType TNamed TH2S
    GADTTNamedTH3C :: TH3C -> GADTType TNamed TH3C
    GADTTNamedTH3D :: TH3D -> GADTType TNamed TH3D
    GADTTNamedTH3F :: TH3F -> GADTType TNamed TH3F
    GADTTNamedTH3I :: TH3I -> GADTType TNamed TH3I
    GADTTNamedTH3S :: TH3S -> GADTType TNamed TH3S
    GADTTNamedTRandom :: TRandom -> GADTType TNamed TRandom
    GADTTNamedTKey :: TKey -> GADTType TNamed TKey
    GADTTNamedBottom  :: GADTType TNamed BottomType
  data EGADTType TNamed = forall a. EGADTTNamed (GADTType TNamed a)

castTNamed :: Exist TNamed -> IO (EGADTType TNamed)
castTNamed eobj = do 
  let obj = TNamed (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TNamed" -> case obj of
        TNamed fptr -> let obj' = TNamed (castForeignPtr fptr :: ForeignPtr RawTNamed)
                        in  return . EGADTTNamed . GADTTNamedTNamed $ obj'
    "TClass" -> case obj of
        TNamed fptr -> let obj' = TClass (castForeignPtr fptr :: ForeignPtr RawTClass)
                        in  return . EGADTTNamed . GADTTNamedTClass $ obj'
    "TFormula" -> case obj of
        TNamed fptr -> let obj' = TFormula (castForeignPtr fptr :: ForeignPtr RawTFormula)
                        in  return . EGADTTNamed . GADTTNamedTFormula $ obj'
    "TAttParticle" -> case obj of
        TNamed fptr -> let obj' = TAttParticle (castForeignPtr fptr :: ForeignPtr RawTAttParticle)
                        in  return . EGADTTNamed . GADTTNamedTAttParticle $ obj'
    "THStack" -> case obj of
        TNamed fptr -> let obj' = THStack (castForeignPtr fptr :: ForeignPtr RawTHStack)
                        in  return . EGADTTNamed . GADTTNamedTHStack $ obj'
    "TF1" -> case obj of
        TNamed fptr -> let obj' = TF1 (castForeignPtr fptr :: ForeignPtr RawTF1)
                        in  return . EGADTTNamed . GADTTNamedTF1 $ obj'
    "TGraph" -> case obj of
        TNamed fptr -> let obj' = TGraph (castForeignPtr fptr :: ForeignPtr RawTGraph)
                        in  return . EGADTTNamed . GADTTNamedTGraph $ obj'
    "TGraphAsymmErrors" -> case obj of
        TNamed fptr -> let obj' = TGraphAsymmErrors (castForeignPtr fptr :: ForeignPtr RawTGraphAsymmErrors)
                        in  return . EGADTTNamed . GADTTNamedTGraphAsymmErrors $ obj'
    "TCutG" -> case obj of
        TNamed fptr -> let obj' = TCutG (castForeignPtr fptr :: ForeignPtr RawTCutG)
                        in  return . EGADTTNamed . GADTTNamedTCutG $ obj'
    "TGraphBentErrors" -> case obj of
        TNamed fptr -> let obj' = TGraphBentErrors (castForeignPtr fptr :: ForeignPtr RawTGraphBentErrors)
                        in  return . EGADTTNamed . GADTTNamedTGraphBentErrors $ obj'
    "TGraphErrors" -> case obj of
        TNamed fptr -> let obj' = TGraphErrors (castForeignPtr fptr :: ForeignPtr RawTGraphErrors)
                        in  return . EGADTTNamed . GADTTNamedTGraphErrors $ obj'
    "TGraphPolar" -> case obj of
        TNamed fptr -> let obj' = TGraphPolar (castForeignPtr fptr :: ForeignPtr RawTGraphPolar)
                        in  return . EGADTTNamed . GADTTNamedTGraphPolar $ obj'
    "TGraphQQ" -> case obj of
        TNamed fptr -> let obj' = TGraphQQ (castForeignPtr fptr :: ForeignPtr RawTGraphQQ)
                        in  return . EGADTTNamed . GADTTNamedTGraphQQ $ obj'
    "TShape" -> case obj of
        TNamed fptr -> let obj' = TShape (castForeignPtr fptr :: ForeignPtr RawTShape)
                        in  return . EGADTTNamed . GADTTNamedTShape $ obj'
    "TBRIK" -> case obj of
        TNamed fptr -> let obj' = TBRIK (castForeignPtr fptr :: ForeignPtr RawTBRIK)
                        in  return . EGADTTNamed . GADTTNamedTBRIK $ obj'
    "TTUBE" -> case obj of
        TNamed fptr -> let obj' = TTUBE (castForeignPtr fptr :: ForeignPtr RawTTUBE)
                        in  return . EGADTTNamed . GADTTNamedTTUBE $ obj'
    "TPCON" -> case obj of
        TNamed fptr -> let obj' = TPCON (castForeignPtr fptr :: ForeignPtr RawTPCON)
                        in  return . EGADTTNamed . GADTTNamedTPCON $ obj'
    "TSPHE" -> case obj of
        TNamed fptr -> let obj' = TSPHE (castForeignPtr fptr :: ForeignPtr RawTSPHE)
                        in  return . EGADTTNamed . GADTTNamedTSPHE $ obj'
    "TXTRU" -> case obj of
        TNamed fptr -> let obj' = TXTRU (castForeignPtr fptr :: ForeignPtr RawTXTRU)
                        in  return . EGADTTNamed . GADTTNamedTXTRU $ obj'
    "TTree" -> case obj of
        TNamed fptr -> let obj' = TTree (castForeignPtr fptr :: ForeignPtr RawTTree)
                        in  return . EGADTTNamed . GADTTNamedTTree $ obj'
    "TChain" -> case obj of
        TNamed fptr -> let obj' = TChain (castForeignPtr fptr :: ForeignPtr RawTChain)
                        in  return . EGADTTNamed . GADTTNamedTChain $ obj'
    "TNtuple" -> case obj of
        TNamed fptr -> let obj' = TNtuple (castForeignPtr fptr :: ForeignPtr RawTNtuple)
                        in  return . EGADTTNamed . GADTTNamedTNtuple $ obj'
    "TNtupleD" -> case obj of
        TNamed fptr -> let obj' = TNtupleD (castForeignPtr fptr :: ForeignPtr RawTNtupleD)
                        in  return . EGADTTNamed . GADTTNamedTNtupleD $ obj'
    "TTreeSQL" -> case obj of
        TNamed fptr -> let obj' = TTreeSQL (castForeignPtr fptr :: ForeignPtr RawTTreeSQL)
                        in  return . EGADTTNamed . GADTTNamedTTreeSQL $ obj'
    "TEfficiency" -> case obj of
        TNamed fptr -> let obj' = TEfficiency (castForeignPtr fptr :: ForeignPtr RawTEfficiency)
                        in  return . EGADTTNamed . GADTTNamedTEfficiency $ obj'
    "TAxis" -> case obj of
        TNamed fptr -> let obj' = TAxis (castForeignPtr fptr :: ForeignPtr RawTAxis)
                        in  return . EGADTTNamed . GADTTNamedTAxis $ obj'
    "TLatex" -> case obj of
        TNamed fptr -> let obj' = TLatex (castForeignPtr fptr :: ForeignPtr RawTLatex)
                        in  return . EGADTTNamed . GADTTNamedTLatex $ obj'
    "TText" -> case obj of
        TNamed fptr -> let obj' = TText (castForeignPtr fptr :: ForeignPtr RawTText)
                        in  return . EGADTTNamed . GADTTNamedTText $ obj'
    "TDirectory" -> case obj of
        TNamed fptr -> let obj' = TDirectory (castForeignPtr fptr :: ForeignPtr RawTDirectory)
                        in  return . EGADTTNamed . GADTTNamedTDirectory $ obj'
    "TDirectoryFile" -> case obj of
        TNamed fptr -> let obj' = TDirectoryFile (castForeignPtr fptr :: ForeignPtr RawTDirectoryFile)
                        in  return . EGADTTNamed . GADTTNamedTDirectoryFile $ obj'
    "TFile" -> case obj of
        TNamed fptr -> let obj' = TFile (castForeignPtr fptr :: ForeignPtr RawTFile)
                        in  return . EGADTTNamed . GADTTNamedTFile $ obj'
    "TBranch" -> case obj of
        TNamed fptr -> let obj' = TBranch (castForeignPtr fptr :: ForeignPtr RawTBranch)
                        in  return . EGADTTNamed . GADTTNamedTBranch $ obj'
    "TH1" -> case obj of
        TNamed fptr -> let obj' = TH1 (castForeignPtr fptr :: ForeignPtr RawTH1)
                        in  return . EGADTTNamed . GADTTNamedTH1 $ obj'
    "TH2" -> case obj of
        TNamed fptr -> let obj' = TH2 (castForeignPtr fptr :: ForeignPtr RawTH2)
                        in  return . EGADTTNamed . GADTTNamedTH2 $ obj'
    "TH3" -> case obj of
        TNamed fptr -> let obj' = TH3 (castForeignPtr fptr :: ForeignPtr RawTH3)
                        in  return . EGADTTNamed . GADTTNamedTH3 $ obj'
    "TH1C" -> case obj of
        TNamed fptr -> let obj' = TH1C (castForeignPtr fptr :: ForeignPtr RawTH1C)
                        in  return . EGADTTNamed . GADTTNamedTH1C $ obj'
    "TH1D" -> case obj of
        TNamed fptr -> let obj' = TH1D (castForeignPtr fptr :: ForeignPtr RawTH1D)
                        in  return . EGADTTNamed . GADTTNamedTH1D $ obj'
    "TH1F" -> case obj of
        TNamed fptr -> let obj' = TH1F (castForeignPtr fptr :: ForeignPtr RawTH1F)
                        in  return . EGADTTNamed . GADTTNamedTH1F $ obj'
    "TH1I" -> case obj of
        TNamed fptr -> let obj' = TH1I (castForeignPtr fptr :: ForeignPtr RawTH1I)
                        in  return . EGADTTNamed . GADTTNamedTH1I $ obj'
    "TH1S" -> case obj of
        TNamed fptr -> let obj' = TH1S (castForeignPtr fptr :: ForeignPtr RawTH1S)
                        in  return . EGADTTNamed . GADTTNamedTH1S $ obj'
    "TH2C" -> case obj of
        TNamed fptr -> let obj' = TH2C (castForeignPtr fptr :: ForeignPtr RawTH2C)
                        in  return . EGADTTNamed . GADTTNamedTH2C $ obj'
    "TH2D" -> case obj of
        TNamed fptr -> let obj' = TH2D (castForeignPtr fptr :: ForeignPtr RawTH2D)
                        in  return . EGADTTNamed . GADTTNamedTH2D $ obj'
    "TH2F" -> case obj of
        TNamed fptr -> let obj' = TH2F (castForeignPtr fptr :: ForeignPtr RawTH2F)
                        in  return . EGADTTNamed . GADTTNamedTH2F $ obj'
    "TH2I" -> case obj of
        TNamed fptr -> let obj' = TH2I (castForeignPtr fptr :: ForeignPtr RawTH2I)
                        in  return . EGADTTNamed . GADTTNamedTH2I $ obj'
    "TH2Poly" -> case obj of
        TNamed fptr -> let obj' = TH2Poly (castForeignPtr fptr :: ForeignPtr RawTH2Poly)
                        in  return . EGADTTNamed . GADTTNamedTH2Poly $ obj'
    "TH2S" -> case obj of
        TNamed fptr -> let obj' = TH2S (castForeignPtr fptr :: ForeignPtr RawTH2S)
                        in  return . EGADTTNamed . GADTTNamedTH2S $ obj'
    "TH3C" -> case obj of
        TNamed fptr -> let obj' = TH3C (castForeignPtr fptr :: ForeignPtr RawTH3C)
                        in  return . EGADTTNamed . GADTTNamedTH3C $ obj'
    "TH3D" -> case obj of
        TNamed fptr -> let obj' = TH3D (castForeignPtr fptr :: ForeignPtr RawTH3D)
                        in  return . EGADTTNamed . GADTTNamedTH3D $ obj'
    "TH3F" -> case obj of
        TNamed fptr -> let obj' = TH3F (castForeignPtr fptr :: ForeignPtr RawTH3F)
                        in  return . EGADTTNamed . GADTTNamedTH3F $ obj'
    "TH3I" -> case obj of
        TNamed fptr -> let obj' = TH3I (castForeignPtr fptr :: ForeignPtr RawTH3I)
                        in  return . EGADTTNamed . GADTTNamedTH3I $ obj'
    "TH3S" -> case obj of
        TNamed fptr -> let obj' = TH3S (castForeignPtr fptr :: ForeignPtr RawTH3S)
                        in  return . EGADTTNamed . GADTTNamedTH3S $ obj'
    "TRandom" -> case obj of
        TNamed fptr -> let obj' = TRandom (castForeignPtr fptr :: ForeignPtr RawTRandom)
                        in  return . EGADTTNamed . GADTTNamedTRandom $ obj'
    "TKey" -> case obj of
        TNamed fptr -> let obj' = TKey (castForeignPtr fptr :: ForeignPtr RawTKey)
                        in  return . EGADTTNamed . GADTTNamedTKey $ obj'
    _         -> return . EGADTTNamed $ GADTTNamedBottom





instance GADTTypeable TObject where
  data GADTType TObject a where 
    GADTTObjectTObject :: TObject -> GADTType TObject TObject
    GADTTObjectTNamed :: TNamed -> GADTType TObject TNamed
    GADTTObjectTClass :: TClass -> GADTType TObject TClass
    GADTTObjectTFormula :: TFormula -> GADTType TObject TFormula
    GADTTObjectTAttParticle :: TAttParticle -> GADTType TObject TAttParticle
    GADTTObjectTHStack :: THStack -> GADTType TObject THStack
    GADTTObjectTF1 :: TF1 -> GADTType TObject TF1
    GADTTObjectTGraph :: TGraph -> GADTType TObject TGraph
    GADTTObjectTGraphAsymmErrors :: TGraphAsymmErrors -> GADTType TObject TGraphAsymmErrors
    GADTTObjectTCutG :: TCutG -> GADTType TObject TCutG
    GADTTObjectTGraphBentErrors :: TGraphBentErrors -> GADTType TObject TGraphBentErrors
    GADTTObjectTGraphErrors :: TGraphErrors -> GADTType TObject TGraphErrors
    GADTTObjectTGraphPolar :: TGraphPolar -> GADTType TObject TGraphPolar
    GADTTObjectTGraphQQ :: TGraphQQ -> GADTType TObject TGraphQQ
    GADTTObjectTEllipse :: TEllipse -> GADTType TObject TEllipse
    GADTTObjectTArc :: TArc -> GADTType TObject TArc
    GADTTObjectTCrown :: TCrown -> GADTType TObject TCrown
    GADTTObjectTLine :: TLine -> GADTType TObject TLine
    GADTTObjectTArrow :: TArrow -> GADTType TObject TArrow
    GADTTObjectTGaxis :: TGaxis -> GADTType TObject TGaxis
    GADTTObjectTShape :: TShape -> GADTType TObject TShape
    GADTTObjectTBRIK :: TBRIK -> GADTType TObject TBRIK
    GADTTObjectTTUBE :: TTUBE -> GADTType TObject TTUBE
    GADTTObjectTPCON :: TPCON -> GADTType TObject TPCON
    GADTTObjectTSPHE :: TSPHE -> GADTType TObject TSPHE
    GADTTObjectTXTRU :: TXTRU -> GADTType TObject TXTRU
    GADTTObjectTBox :: TBox -> GADTType TObject TBox
    GADTTObjectTPave :: TPave -> GADTType TObject TPave
    GADTTObjectTPaveText :: TPaveText -> GADTType TObject TPaveText
    GADTTObjectTDiamond :: TDiamond -> GADTType TObject TDiamond
    GADTTObjectTPaveStats :: TPaveStats -> GADTType TObject TPaveStats
    GADTTObjectTPavesText :: TPavesText -> GADTType TObject TPavesText
    GADTTObjectTLegend :: TLegend -> GADTType TObject TLegend
    GADTTObjectTLegendEntry :: TLegendEntry -> GADTType TObject TLegendEntry
    GADTTObjectTPaveLabel :: TPaveLabel -> GADTType TObject TPaveLabel
    GADTTObjectTPaveClass :: TPaveClass -> GADTType TObject TPaveClass
    GADTTObjectTWbox :: TWbox -> GADTType TObject TWbox
    GADTTObjectTFrame :: TFrame -> GADTType TObject TFrame
    GADTTObjectTSliderBox :: TSliderBox -> GADTType TObject TSliderBox
    GADTTObjectTTree :: TTree -> GADTType TObject TTree
    GADTTObjectTChain :: TChain -> GADTType TObject TChain
    GADTTObjectTNtuple :: TNtuple -> GADTType TObject TNtuple
    GADTTObjectTNtupleD :: TNtupleD -> GADTType TObject TNtupleD
    GADTTObjectTTreeSQL :: TTreeSQL -> GADTType TObject TTreeSQL
    GADTTObjectTPolyLine :: TPolyLine -> GADTType TObject TPolyLine
    GADTTObjectTCurlyLine :: TCurlyLine -> GADTType TObject TCurlyLine
    GADTTObjectTCurlyArc :: TCurlyArc -> GADTType TObject TCurlyArc
    GADTTObjectTEfficiency :: TEfficiency -> GADTType TObject TEfficiency
    GADTTObjectTAxis :: TAxis -> GADTType TObject TAxis
    GADTTObjectTLatex :: TLatex -> GADTType TObject TLatex
    GADTTObjectTText :: TText -> GADTType TObject TText
    GADTTObjectTDirectory :: TDirectory -> GADTType TObject TDirectory
    GADTTObjectTDirectoryFile :: TDirectoryFile -> GADTType TObject TDirectoryFile
    GADTTObjectTFile :: TFile -> GADTType TObject TFile
    GADTTObjectTBranch :: TBranch -> GADTType TObject TBranch
    GADTTObjectTVirtualTreePlayer :: TVirtualTreePlayer -> GADTType TObject TVirtualTreePlayer
    GADTTObjectTTreePlayer :: TTreePlayer -> GADTType TObject TTreePlayer
    GADTTObjectTH1 :: TH1 -> GADTType TObject TH1
    GADTTObjectTH2 :: TH2 -> GADTType TObject TH2
    GADTTObjectTH3 :: TH3 -> GADTType TObject TH3
    GADTTObjectTH1C :: TH1C -> GADTType TObject TH1C
    GADTTObjectTH1D :: TH1D -> GADTType TObject TH1D
    GADTTObjectTH1F :: TH1F -> GADTType TObject TH1F
    GADTTObjectTH1I :: TH1I -> GADTType TObject TH1I
    GADTTObjectTH1S :: TH1S -> GADTType TObject TH1S
    GADTTObjectTH2C :: TH2C -> GADTType TObject TH2C
    GADTTObjectTH2D :: TH2D -> GADTType TObject TH2D
    GADTTObjectTH2F :: TH2F -> GADTType TObject TH2F
    GADTTObjectTH2I :: TH2I -> GADTType TObject TH2I
    GADTTObjectTH2Poly :: TH2Poly -> GADTType TObject TH2Poly
    GADTTObjectTH2S :: TH2S -> GADTType TObject TH2S
    GADTTObjectTH3C :: TH3C -> GADTType TObject TH3C
    GADTTObjectTH3D :: TH3D -> GADTType TObject TH3D
    GADTTObjectTH3F :: TH3F -> GADTType TObject TH3F
    GADTTObjectTH3I :: TH3I -> GADTType TObject TH3I
    GADTTObjectTH3S :: TH3S -> GADTType TObject TH3S
    GADTTObjectTVirtualPad :: TVirtualPad -> GADTType TObject TVirtualPad
    GADTTObjectTPad :: TPad -> GADTType TObject TPad
    GADTTObjectTButton :: TButton -> GADTType TObject TButton
    GADTTObjectTGroupButton :: TGroupButton -> GADTType TObject TGroupButton
    GADTTObjectTCanvas :: TCanvas -> GADTType TObject TCanvas
    GADTTObjectTDialogCanvas :: TDialogCanvas -> GADTType TObject TDialogCanvas
    GADTTObjectTInspectCanvas :: TInspectCanvas -> GADTType TObject TInspectCanvas
    GADTTObjectTEvePad :: TEvePad -> GADTType TObject TEvePad
    GADTTObjectTSlider :: TSlider -> GADTType TObject TSlider
    GADTTObjectTApplication :: TApplication -> GADTType TObject TApplication
    GADTTObjectTRint :: TRint -> GADTType TObject TRint
    GADTTObjectTRandom :: TRandom -> GADTType TObject TRandom
    GADTTObjectTCollection :: TCollection -> GADTType TObject TCollection
    GADTTObjectTSeqCollection :: TSeqCollection -> GADTType TObject TSeqCollection
    GADTTObjectTObjArray :: TObjArray -> GADTType TObject TObjArray
    GADTTObjectTList :: TList -> GADTType TObject TList
    GADTTObjectTKey :: TKey -> GADTType TObject TKey
    GADTTObjectBottom  :: GADTType TObject BottomType
  data EGADTType TObject = forall a. EGADTTObject (GADTType TObject a)

castTObject :: Exist TObject -> IO (EGADTType TObject)
castTObject eobj = do 
  let obj = TObject (get_fptr eobj)
  etclass <- isA obj  
  cname <- case etclass of 
             ETClass tclass -> getName tclass
  case cname of 
    "TObject" -> case obj of
        TObject fptr -> let obj' = TObject (castForeignPtr fptr :: ForeignPtr RawTObject)
                        in  return . EGADTTObject . GADTTObjectTObject $ obj'
    "TNamed" -> case obj of
        TObject fptr -> let obj' = TNamed (castForeignPtr fptr :: ForeignPtr RawTNamed)
                        in  return . EGADTTObject . GADTTObjectTNamed $ obj'
    "TClass" -> case obj of
        TObject fptr -> let obj' = TClass (castForeignPtr fptr :: ForeignPtr RawTClass)
                        in  return . EGADTTObject . GADTTObjectTClass $ obj'
    "TFormula" -> case obj of
        TObject fptr -> let obj' = TFormula (castForeignPtr fptr :: ForeignPtr RawTFormula)
                        in  return . EGADTTObject . GADTTObjectTFormula $ obj'
    "TAttParticle" -> case obj of
        TObject fptr -> let obj' = TAttParticle (castForeignPtr fptr :: ForeignPtr RawTAttParticle)
                        in  return . EGADTTObject . GADTTObjectTAttParticle $ obj'
    "THStack" -> case obj of
        TObject fptr -> let obj' = THStack (castForeignPtr fptr :: ForeignPtr RawTHStack)
                        in  return . EGADTTObject . GADTTObjectTHStack $ obj'
    "TF1" -> case obj of
        TObject fptr -> let obj' = TF1 (castForeignPtr fptr :: ForeignPtr RawTF1)
                        in  return . EGADTTObject . GADTTObjectTF1 $ obj'
    "TGraph" -> case obj of
        TObject fptr -> let obj' = TGraph (castForeignPtr fptr :: ForeignPtr RawTGraph)
                        in  return . EGADTTObject . GADTTObjectTGraph $ obj'
    "TGraphAsymmErrors" -> case obj of
        TObject fptr -> let obj' = TGraphAsymmErrors (castForeignPtr fptr :: ForeignPtr RawTGraphAsymmErrors)
                        in  return . EGADTTObject . GADTTObjectTGraphAsymmErrors $ obj'
    "TCutG" -> case obj of
        TObject fptr -> let obj' = TCutG (castForeignPtr fptr :: ForeignPtr RawTCutG)
                        in  return . EGADTTObject . GADTTObjectTCutG $ obj'
    "TGraphBentErrors" -> case obj of
        TObject fptr -> let obj' = TGraphBentErrors (castForeignPtr fptr :: ForeignPtr RawTGraphBentErrors)
                        in  return . EGADTTObject . GADTTObjectTGraphBentErrors $ obj'
    "TGraphErrors" -> case obj of
        TObject fptr -> let obj' = TGraphErrors (castForeignPtr fptr :: ForeignPtr RawTGraphErrors)
                        in  return . EGADTTObject . GADTTObjectTGraphErrors $ obj'
    "TGraphPolar" -> case obj of
        TObject fptr -> let obj' = TGraphPolar (castForeignPtr fptr :: ForeignPtr RawTGraphPolar)
                        in  return . EGADTTObject . GADTTObjectTGraphPolar $ obj'
    "TGraphQQ" -> case obj of
        TObject fptr -> let obj' = TGraphQQ (castForeignPtr fptr :: ForeignPtr RawTGraphQQ)
                        in  return . EGADTTObject . GADTTObjectTGraphQQ $ obj'
    "TEllipse" -> case obj of
        TObject fptr -> let obj' = TEllipse (castForeignPtr fptr :: ForeignPtr RawTEllipse)
                        in  return . EGADTTObject . GADTTObjectTEllipse $ obj'
    "TArc" -> case obj of
        TObject fptr -> let obj' = TArc (castForeignPtr fptr :: ForeignPtr RawTArc)
                        in  return . EGADTTObject . GADTTObjectTArc $ obj'
    "TCrown" -> case obj of
        TObject fptr -> let obj' = TCrown (castForeignPtr fptr :: ForeignPtr RawTCrown)
                        in  return . EGADTTObject . GADTTObjectTCrown $ obj'
    "TLine" -> case obj of
        TObject fptr -> let obj' = TLine (castForeignPtr fptr :: ForeignPtr RawTLine)
                        in  return . EGADTTObject . GADTTObjectTLine $ obj'
    "TArrow" -> case obj of
        TObject fptr -> let obj' = TArrow (castForeignPtr fptr :: ForeignPtr RawTArrow)
                        in  return . EGADTTObject . GADTTObjectTArrow $ obj'
    "TGaxis" -> case obj of
        TObject fptr -> let obj' = TGaxis (castForeignPtr fptr :: ForeignPtr RawTGaxis)
                        in  return . EGADTTObject . GADTTObjectTGaxis $ obj'
    "TShape" -> case obj of
        TObject fptr -> let obj' = TShape (castForeignPtr fptr :: ForeignPtr RawTShape)
                        in  return . EGADTTObject . GADTTObjectTShape $ obj'
    "TBRIK" -> case obj of
        TObject fptr -> let obj' = TBRIK (castForeignPtr fptr :: ForeignPtr RawTBRIK)
                        in  return . EGADTTObject . GADTTObjectTBRIK $ obj'
    "TTUBE" -> case obj of
        TObject fptr -> let obj' = TTUBE (castForeignPtr fptr :: ForeignPtr RawTTUBE)
                        in  return . EGADTTObject . GADTTObjectTTUBE $ obj'
    "TPCON" -> case obj of
        TObject fptr -> let obj' = TPCON (castForeignPtr fptr :: ForeignPtr RawTPCON)
                        in  return . EGADTTObject . GADTTObjectTPCON $ obj'
    "TSPHE" -> case obj of
        TObject fptr -> let obj' = TSPHE (castForeignPtr fptr :: ForeignPtr RawTSPHE)
                        in  return . EGADTTObject . GADTTObjectTSPHE $ obj'
    "TXTRU" -> case obj of
        TObject fptr -> let obj' = TXTRU (castForeignPtr fptr :: ForeignPtr RawTXTRU)
                        in  return . EGADTTObject . GADTTObjectTXTRU $ obj'
    "TBox" -> case obj of
        TObject fptr -> let obj' = TBox (castForeignPtr fptr :: ForeignPtr RawTBox)
                        in  return . EGADTTObject . GADTTObjectTBox $ obj'
    "TPave" -> case obj of
        TObject fptr -> let obj' = TPave (castForeignPtr fptr :: ForeignPtr RawTPave)
                        in  return . EGADTTObject . GADTTObjectTPave $ obj'
    "TPaveText" -> case obj of
        TObject fptr -> let obj' = TPaveText (castForeignPtr fptr :: ForeignPtr RawTPaveText)
                        in  return . EGADTTObject . GADTTObjectTPaveText $ obj'
    "TDiamond" -> case obj of
        TObject fptr -> let obj' = TDiamond (castForeignPtr fptr :: ForeignPtr RawTDiamond)
                        in  return . EGADTTObject . GADTTObjectTDiamond $ obj'
    "TPaveStats" -> case obj of
        TObject fptr -> let obj' = TPaveStats (castForeignPtr fptr :: ForeignPtr RawTPaveStats)
                        in  return . EGADTTObject . GADTTObjectTPaveStats $ obj'
    "TPavesText" -> case obj of
        TObject fptr -> let obj' = TPavesText (castForeignPtr fptr :: ForeignPtr RawTPavesText)
                        in  return . EGADTTObject . GADTTObjectTPavesText $ obj'
    "TLegend" -> case obj of
        TObject fptr -> let obj' = TLegend (castForeignPtr fptr :: ForeignPtr RawTLegend)
                        in  return . EGADTTObject . GADTTObjectTLegend $ obj'
    "TLegendEntry" -> case obj of
        TObject fptr -> let obj' = TLegendEntry (castForeignPtr fptr :: ForeignPtr RawTLegendEntry)
                        in  return . EGADTTObject . GADTTObjectTLegendEntry $ obj'
    "TPaveLabel" -> case obj of
        TObject fptr -> let obj' = TPaveLabel (castForeignPtr fptr :: ForeignPtr RawTPaveLabel)
                        in  return . EGADTTObject . GADTTObjectTPaveLabel $ obj'
    "TPaveClass" -> case obj of
        TObject fptr -> let obj' = TPaveClass (castForeignPtr fptr :: ForeignPtr RawTPaveClass)
                        in  return . EGADTTObject . GADTTObjectTPaveClass $ obj'
    "TWbox" -> case obj of
        TObject fptr -> let obj' = TWbox (castForeignPtr fptr :: ForeignPtr RawTWbox)
                        in  return . EGADTTObject . GADTTObjectTWbox $ obj'
    "TFrame" -> case obj of
        TObject fptr -> let obj' = TFrame (castForeignPtr fptr :: ForeignPtr RawTFrame)
                        in  return . EGADTTObject . GADTTObjectTFrame $ obj'
    "TSliderBox" -> case obj of
        TObject fptr -> let obj' = TSliderBox (castForeignPtr fptr :: ForeignPtr RawTSliderBox)
                        in  return . EGADTTObject . GADTTObjectTSliderBox $ obj'
    "TTree" -> case obj of
        TObject fptr -> let obj' = TTree (castForeignPtr fptr :: ForeignPtr RawTTree)
                        in  return . EGADTTObject . GADTTObjectTTree $ obj'
    "TChain" -> case obj of
        TObject fptr -> let obj' = TChain (castForeignPtr fptr :: ForeignPtr RawTChain)
                        in  return . EGADTTObject . GADTTObjectTChain $ obj'
    "TNtuple" -> case obj of
        TObject fptr -> let obj' = TNtuple (castForeignPtr fptr :: ForeignPtr RawTNtuple)
                        in  return . EGADTTObject . GADTTObjectTNtuple $ obj'
    "TNtupleD" -> case obj of
        TObject fptr -> let obj' = TNtupleD (castForeignPtr fptr :: ForeignPtr RawTNtupleD)
                        in  return . EGADTTObject . GADTTObjectTNtupleD $ obj'
    "TTreeSQL" -> case obj of
        TObject fptr -> let obj' = TTreeSQL (castForeignPtr fptr :: ForeignPtr RawTTreeSQL)
                        in  return . EGADTTObject . GADTTObjectTTreeSQL $ obj'
    "TPolyLine" -> case obj of
        TObject fptr -> let obj' = TPolyLine (castForeignPtr fptr :: ForeignPtr RawTPolyLine)
                        in  return . EGADTTObject . GADTTObjectTPolyLine $ obj'
    "TCurlyLine" -> case obj of
        TObject fptr -> let obj' = TCurlyLine (castForeignPtr fptr :: ForeignPtr RawTCurlyLine)
                        in  return . EGADTTObject . GADTTObjectTCurlyLine $ obj'
    "TCurlyArc" -> case obj of
        TObject fptr -> let obj' = TCurlyArc (castForeignPtr fptr :: ForeignPtr RawTCurlyArc)
                        in  return . EGADTTObject . GADTTObjectTCurlyArc $ obj'
    "TEfficiency" -> case obj of
        TObject fptr -> let obj' = TEfficiency (castForeignPtr fptr :: ForeignPtr RawTEfficiency)
                        in  return . EGADTTObject . GADTTObjectTEfficiency $ obj'
    "TAxis" -> case obj of
        TObject fptr -> let obj' = TAxis (castForeignPtr fptr :: ForeignPtr RawTAxis)
                        in  return . EGADTTObject . GADTTObjectTAxis $ obj'
    "TLatex" -> case obj of
        TObject fptr -> let obj' = TLatex (castForeignPtr fptr :: ForeignPtr RawTLatex)
                        in  return . EGADTTObject . GADTTObjectTLatex $ obj'
    "TText" -> case obj of
        TObject fptr -> let obj' = TText (castForeignPtr fptr :: ForeignPtr RawTText)
                        in  return . EGADTTObject . GADTTObjectTText $ obj'
    "TDirectory" -> case obj of
        TObject fptr -> let obj' = TDirectory (castForeignPtr fptr :: ForeignPtr RawTDirectory)
                        in  return . EGADTTObject . GADTTObjectTDirectory $ obj'
    "TDirectoryFile" -> case obj of
        TObject fptr -> let obj' = TDirectoryFile (castForeignPtr fptr :: ForeignPtr RawTDirectoryFile)
                        in  return . EGADTTObject . GADTTObjectTDirectoryFile $ obj'
    "TFile" -> case obj of
        TObject fptr -> let obj' = TFile (castForeignPtr fptr :: ForeignPtr RawTFile)
                        in  return . EGADTTObject . GADTTObjectTFile $ obj'
    "TBranch" -> case obj of
        TObject fptr -> let obj' = TBranch (castForeignPtr fptr :: ForeignPtr RawTBranch)
                        in  return . EGADTTObject . GADTTObjectTBranch $ obj'
    "TVirtualTreePlayer" -> case obj of
        TObject fptr -> let obj' = TVirtualTreePlayer (castForeignPtr fptr :: ForeignPtr RawTVirtualTreePlayer)
                        in  return . EGADTTObject . GADTTObjectTVirtualTreePlayer $ obj'
    "TTreePlayer" -> case obj of
        TObject fptr -> let obj' = TTreePlayer (castForeignPtr fptr :: ForeignPtr RawTTreePlayer)
                        in  return . EGADTTObject . GADTTObjectTTreePlayer $ obj'
    "TH1" -> case obj of
        TObject fptr -> let obj' = TH1 (castForeignPtr fptr :: ForeignPtr RawTH1)
                        in  return . EGADTTObject . GADTTObjectTH1 $ obj'
    "TH2" -> case obj of
        TObject fptr -> let obj' = TH2 (castForeignPtr fptr :: ForeignPtr RawTH2)
                        in  return . EGADTTObject . GADTTObjectTH2 $ obj'
    "TH3" -> case obj of
        TObject fptr -> let obj' = TH3 (castForeignPtr fptr :: ForeignPtr RawTH3)
                        in  return . EGADTTObject . GADTTObjectTH3 $ obj'
    "TH1C" -> case obj of
        TObject fptr -> let obj' = TH1C (castForeignPtr fptr :: ForeignPtr RawTH1C)
                        in  return . EGADTTObject . GADTTObjectTH1C $ obj'
    "TH1D" -> case obj of
        TObject fptr -> let obj' = TH1D (castForeignPtr fptr :: ForeignPtr RawTH1D)
                        in  return . EGADTTObject . GADTTObjectTH1D $ obj'
    "TH1F" -> case obj of
        TObject fptr -> let obj' = TH1F (castForeignPtr fptr :: ForeignPtr RawTH1F)
                        in  return . EGADTTObject . GADTTObjectTH1F $ obj'
    "TH1I" -> case obj of
        TObject fptr -> let obj' = TH1I (castForeignPtr fptr :: ForeignPtr RawTH1I)
                        in  return . EGADTTObject . GADTTObjectTH1I $ obj'
    "TH1S" -> case obj of
        TObject fptr -> let obj' = TH1S (castForeignPtr fptr :: ForeignPtr RawTH1S)
                        in  return . EGADTTObject . GADTTObjectTH1S $ obj'
    "TH2C" -> case obj of
        TObject fptr -> let obj' = TH2C (castForeignPtr fptr :: ForeignPtr RawTH2C)
                        in  return . EGADTTObject . GADTTObjectTH2C $ obj'
    "TH2D" -> case obj of
        TObject fptr -> let obj' = TH2D (castForeignPtr fptr :: ForeignPtr RawTH2D)
                        in  return . EGADTTObject . GADTTObjectTH2D $ obj'
    "TH2F" -> case obj of
        TObject fptr -> let obj' = TH2F (castForeignPtr fptr :: ForeignPtr RawTH2F)
                        in  return . EGADTTObject . GADTTObjectTH2F $ obj'
    "TH2I" -> case obj of
        TObject fptr -> let obj' = TH2I (castForeignPtr fptr :: ForeignPtr RawTH2I)
                        in  return . EGADTTObject . GADTTObjectTH2I $ obj'
    "TH2Poly" -> case obj of
        TObject fptr -> let obj' = TH2Poly (castForeignPtr fptr :: ForeignPtr RawTH2Poly)
                        in  return . EGADTTObject . GADTTObjectTH2Poly $ obj'
    "TH2S" -> case obj of
        TObject fptr -> let obj' = TH2S (castForeignPtr fptr :: ForeignPtr RawTH2S)
                        in  return . EGADTTObject . GADTTObjectTH2S $ obj'
    "TH3C" -> case obj of
        TObject fptr -> let obj' = TH3C (castForeignPtr fptr :: ForeignPtr RawTH3C)
                        in  return . EGADTTObject . GADTTObjectTH3C $ obj'
    "TH3D" -> case obj of
        TObject fptr -> let obj' = TH3D (castForeignPtr fptr :: ForeignPtr RawTH3D)
                        in  return . EGADTTObject . GADTTObjectTH3D $ obj'
    "TH3F" -> case obj of
        TObject fptr -> let obj' = TH3F (castForeignPtr fptr :: ForeignPtr RawTH3F)
                        in  return . EGADTTObject . GADTTObjectTH3F $ obj'
    "TH3I" -> case obj of
        TObject fptr -> let obj' = TH3I (castForeignPtr fptr :: ForeignPtr RawTH3I)
                        in  return . EGADTTObject . GADTTObjectTH3I $ obj'
    "TH3S" -> case obj of
        TObject fptr -> let obj' = TH3S (castForeignPtr fptr :: ForeignPtr RawTH3S)
                        in  return . EGADTTObject . GADTTObjectTH3S $ obj'
    "TVirtualPad" -> case obj of
        TObject fptr -> let obj' = TVirtualPad (castForeignPtr fptr :: ForeignPtr RawTVirtualPad)
                        in  return . EGADTTObject . GADTTObjectTVirtualPad $ obj'
    "TPad" -> case obj of
        TObject fptr -> let obj' = TPad (castForeignPtr fptr :: ForeignPtr RawTPad)
                        in  return . EGADTTObject . GADTTObjectTPad $ obj'
    "TButton" -> case obj of
        TObject fptr -> let obj' = TButton (castForeignPtr fptr :: ForeignPtr RawTButton)
                        in  return . EGADTTObject . GADTTObjectTButton $ obj'
    "TGroupButton" -> case obj of
        TObject fptr -> let obj' = TGroupButton (castForeignPtr fptr :: ForeignPtr RawTGroupButton)
                        in  return . EGADTTObject . GADTTObjectTGroupButton $ obj'
    "TCanvas" -> case obj of
        TObject fptr -> let obj' = TCanvas (castForeignPtr fptr :: ForeignPtr RawTCanvas)
                        in  return . EGADTTObject . GADTTObjectTCanvas $ obj'
    "TDialogCanvas" -> case obj of
        TObject fptr -> let obj' = TDialogCanvas (castForeignPtr fptr :: ForeignPtr RawTDialogCanvas)
                        in  return . EGADTTObject . GADTTObjectTDialogCanvas $ obj'
    "TInspectCanvas" -> case obj of
        TObject fptr -> let obj' = TInspectCanvas (castForeignPtr fptr :: ForeignPtr RawTInspectCanvas)
                        in  return . EGADTTObject . GADTTObjectTInspectCanvas $ obj'
    "TEvePad" -> case obj of
        TObject fptr -> let obj' = TEvePad (castForeignPtr fptr :: ForeignPtr RawTEvePad)
                        in  return . EGADTTObject . GADTTObjectTEvePad $ obj'
    "TSlider" -> case obj of
        TObject fptr -> let obj' = TSlider (castForeignPtr fptr :: ForeignPtr RawTSlider)
                        in  return . EGADTTObject . GADTTObjectTSlider $ obj'
    "TApplication" -> case obj of
        TObject fptr -> let obj' = TApplication (castForeignPtr fptr :: ForeignPtr RawTApplication)
                        in  return . EGADTTObject . GADTTObjectTApplication $ obj'
    "TRint" -> case obj of
        TObject fptr -> let obj' = TRint (castForeignPtr fptr :: ForeignPtr RawTRint)
                        in  return . EGADTTObject . GADTTObjectTRint $ obj'
    "TRandom" -> case obj of
        TObject fptr -> let obj' = TRandom (castForeignPtr fptr :: ForeignPtr RawTRandom)
                        in  return . EGADTTObject . GADTTObjectTRandom $ obj'
    "TCollection" -> case obj of
        TObject fptr -> let obj' = TCollection (castForeignPtr fptr :: ForeignPtr RawTCollection)
                        in  return . EGADTTObject . GADTTObjectTCollection $ obj'
    "TSeqCollection" -> case obj of
        TObject fptr -> let obj' = TSeqCollection (castForeignPtr fptr :: ForeignPtr RawTSeqCollection)
                        in  return . EGADTTObject . GADTTObjectTSeqCollection $ obj'
    "TObjArray" -> case obj of
        TObject fptr -> let obj' = TObjArray (castForeignPtr fptr :: ForeignPtr RawTObjArray)
                        in  return . EGADTTObject . GADTTObjectTObjArray $ obj'
    "TList" -> case obj of
        TObject fptr -> let obj' = TList (castForeignPtr fptr :: ForeignPtr RawTList)
                        in  return . EGADTTObject . GADTTObjectTList $ obj'
    "TKey" -> case obj of
        TObject fptr -> let obj' = TKey (castForeignPtr fptr :: ForeignPtr RawTKey)
                        in  return . EGADTTObject . GADTTObjectTKey $ obj'
    _         -> return . EGADTTObject $ GADTTObjectBottom