(forgot to CC the list)

On Jun 24, 2011, at 8:27 PM, Daniel Patterson wrote:

> It looks, from looking at the provided instances (not from having done it 
> myself), that you need to define safeConvert functions to and from your 
> value. Here is a partial list of conversions to and from String.
> instance Convertible String SqlValue where
>     safeConvert = return . SqlString
> instance Convertible SqlValue String where
>     safeConvert (SqlString x) = return x
>     safeConvert (SqlByteString x) = return . BUTF8.toString $ x
>     safeConvert (SqlInt32 x) = return . show $ x
>     safeConvert (SqlInt64 x) = return . show $ x
>     safeConvert (SqlWord32 x) = return . show $ x
>     safeConvert (SqlWord64 x) = return . show $ x
>     safeConvert (SqlInteger x) = return . show $ x
>     safeConvert (SqlChar x) = return [x]
>     safeConvert (SqlBool x) = return . show $ x
>     safeConvert (SqlDouble x) = return . show $ x
>     safeConvert (SqlRational x) = return . show $ x
> 
> On Jun 24, 2011, at 8:02 PM, Tom Murphy wrote:
> 
>> Hi *,
>>     The title is self-explanatory. I'd like to store information from
>> an algebraic data type in an SQL database, but the type signature of
>> toSql (toSql
>>  :: Data.Convertible.Base.Convertible a SqlValue => a -> SqlValue)
>> doesn't make sense to me.
>>     How is this done (how do I make an instance of a typeclass like that?)
>> 
>> Thanks for your time,
>> Tom
>> 
>> _______________________________________________
>> Haskell-Cafe mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to