[ create a new paste ] login | about

Link: http://codepad.org/nMpiA3Ze    [ raw code | fork ]

Plain Text, pasted on Sep 2:
module CType where

import Language.Haskell.TH

ctype :: String -> Q Type
ctype name = (reify . mkName $ name) >>= (\x -> return $ getCType x)

ctype1 name = (reify name) >>= (\x -> return $ getCType x)

{-
*Main Foreign.Storable Language.Haskell.TH Text.Groom U1IR>
 putStrLn ($((=<<) (stringE . groom) (reify . mkName $ "p'U1IR")) )
VarI U1IR.p'U1IR
  (AppT (ConT GHC.Ptr.Ptr) (ConT Foreign.C.Types.CUInt))
  Nothing
  (Fixity 9 InfixL)
it :: ()
(0.04 secs, 4748164 bytes) -}

getCType :: Info -> Type
--getCType (VarI _ (AppT (ConT _) (ConT cType)) _ _) = show cType
getCType (VarI _ (AppT (ConT _) cType) _ _) = cType
getCType x = error $ "unknow c type: getCType: " ++ show x




Create a new paste based on this one


Comments: