[Haskell-cafe] Generic typeclass for converting between types

John Goerzen jgoerzen at complete.org
Fri Jan 23 11:06:23 EST 2009


Magnus Therning wrote:
> On Fri, Jan 23, 2009 at 3:01 PM, John Goerzen <jgoerzen at complete.org> wrote:
>> Hi folks,
>>
>> I've been thinking today that I frequently need to convert data beween
>> types:
>>
>>  * Between various numeric types
>>
>>  * Between various calendar types (both within the new calendar
>>   system, and between the old and new)
>>
>>  * Marshalling data back and forth to a database in HDBC
>>
>> It's hard to remember all the functions to use to do these.  I often
>> resort to a chart I made for numeric conversions.
> 
> Not the type of response you want, but would you publish that chart
> somewhere, please ;-)

Sure :-)

http://book.realworldhaskell.org/read/using-typeclasses.html#numerictypes.conversion

You might also find these useful:

Typeclass instances for numeric types:
http://book.realworldhaskell.org/read/using-typeclasses.html#numerictypes.typeclasses

Chart of numeric functions:
http://book.realworldhaskell.org/read/using-typeclasses.html#numerictypes.funcs

-- John

> 
> /M
> 



More information about the Haskell-Cafe mailing list