[Haskell-cafe] custom SQL-to-Haskell type conversion in HDBC

Brandon Allbery allbery.b at gmail.com
Fri Aug 19 16:44:22 CEST 2011


On Fri, Aug 19, 2011 at 10:09, Henry House <hajhouse at hajhouse.org> wrote:

> I'm not sure I understand the distinction --- to my way of thinking,
> getting the value at the right precision means getting the correct
> number of significant decimal digits, which both your example and mine
> fail to provide.
>

So you want display format data instead of something that you can do
computations with?  HDBC is giving you the latter; the precision is correct
for computation, although it could be argued that a Fixed type would be
better if you intend to propagate exact precision through operations.  (That
said, I believe Fixed obeys exact mathematical precision instead of
replicating your SQL backend's limitations, so you'd be unhappy again in
case of multiplication or division.)

I would suggest that if you want SQL formatted string output, you describe
that in the query instead of expecting HDBC to convert numeric data to
string while duplicating your SQL backend's formatting.  Otherwise, perhaps
you'd be better suited to a language with a looser type system, so you can
pretend string and numeric values are the same thing and usually get
something resembling the right result.

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110819/95f961bb/attachment.htm>


More information about the Haskell-Cafe mailing list