module Database.HaskellDB.FieldType
(FieldDesc, FieldType(..), toHaskellType) where
import Data.Dynamic
import System.Time
import Database.HaskellDB.BoundedString
type FieldDesc = (FieldType, Bool)
data FieldType =
StringT
| IntT
| IntegerT
| DoubleT
| BoolT
| CalendarTimeT
| BStrT Int
deriving (Eq,Ord,Show,Read)
toHaskellType :: FieldType -> String
toHaskellType StringT = "String"
toHaskellType IntT = "Int"
toHaskellType IntegerT = "Integer"
toHaskellType DoubleT = "Double"
toHaskellType BoolT = "Bool"
toHaskellType CalendarTimeT = "CalendarTime"
toHaskellType (BStrT a) = "BStr" ++ show a
instance Typeable CalendarTime where
typeOf _ = mkTyConApp (mkTyCon "System.Time.CalendarTime") []
instance Typeable (BoundedString n) where
typeOf _ = mkTyConApp (mkTyCon "Database.HaskellDB.BoundedString") []