{-# LANGUAGE ForeignFunctionInterface, TypeFamilies, MultiParamTypeClasses, 
             FlexibleInstances, TypeSynonymInstances, 
             EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}

-- module HROOT.Class.Interface where

module HROOT.Class.TKey.Interface where


import Data.Word
import Foreign.ForeignPtr
import HROOT.TypeCast

import HROOT.Class.TKey.RawType

import HROOT.Class.TNamed.Interface


class (ITNamed a) => ITKey a where

instance Existable TKey where
  data Exist TKey = forall a. (FPtr a, ITKey a) => ETKey a

upcastTKey :: (FPtr a, ITKey a) => a -> TKey
upcastTKey h = let fh = get_fptr h
                   fh2 :: ForeignPtr RawTKey = castForeignPtr fh
               in cast_fptr_to_obj fh2