[Haskell-cafe] Re: Type classes and definite types

Bryn Keller xoltar at xoltar.org
Thu May 5 16:52:44 EDT 2005



Max Vasin wrote:

>Bryn Keller <xoltar at xoltar.org> writes:
>
>  
>
>>Hi folks,
>>    
>>
>Hello,
>[skip]
>  
>
>>The problem is that getFieldValue returns a value of type (SqlBind a)
>>=> a. That is, there's no type information associated with this return
>>value other than it's a valid  SQL value. There are no operations in
>>the SqlBind class, it's just a marker as near as I can tell. 
>>    
>>
>As of HSQL 1.4 this class has method 
>toSqlValue :: a -> String
>which probably can help you (I really don't know).
>
>Some RTFSing shows that in most cases toSqlValue is implemented with show.
>  
>
Hi Max,

Thanks for pointing this out. It's odd that I don't see that anywhere in 
the docs at the HToolkit site: 
http://htoolkit.sourceforge.net/doc/hsql/Database.HSQL.html but GHC 
certainly believes it exists. However, this doesn't actually solve the 
problem. Substituting toSqlValue for show in printRow' gives the same 
compile error:

Main.hs:22:18:
    Ambiguous type variable `a' in the constraint:
      `SqlBind a' arising from use of `getFieldValue' at Main.hs:22:18-30
    Probable fix: add a type signature that fixes these type variable(s)

So, like with (show (read s)), we still can't use the function until 
we've established a definite type for the value, not just a type class.

Bryn



More information about the Haskell-Cafe mailing list