module Database.HDBC.Tuple where
import Database.HDBC
import Data.Typical
import Data.Convertible
instance Convertible HNil [SqlValue] where
safeConvert HNil = Right []
instance Convertible [SqlValue] HNil where
safeConvert [] = Right HNil
safeConvert _ = Left (ConvertError "[..]" "[SqlValue]" "HNil" "source list too long.")
instance (Convertible a SqlValue, Convertible b [SqlValue]) => Convertible (a :#: b) [SqlValue] where
safeConvert (a :#: b) = Right (convert a : convert b)
instance (Convertible SqlValue a, Convertible [SqlValue] b) => Convertible [SqlValue] (a :#: b) where
safeConvert (a:b) = Right (convert a :#: convert b)
safeConvert [] = Left (ConvertError "[]" "[Sqlvalue]" "a :#: b" "source list too short")