[Haskell-cafe] multi type addition

Henning Thielemann lemming at henning-thielemann.de
Wed Dec 29 13:17:08 CET 2010


On Tue, 28 Dec 2010, aditya siram wrote:

> The problem here is that unfortunately the Haskell type system cannot
> do coercion.

I'd omit the "unfortunately". For me it is a good thing that Haskell does 
not silently apply lossy number conversions, as e.g. MatLab does.


'realToFrac' allows conversion to Float. It requires 'Real' constraint. 
Your 'Num' constraint is too weak, since 'Complex' is also in 'Num' type 
class.

http://www.haskell.org/haskellwiki/Converting_numbers
http://www.haskell.org/haskellwiki/Generic_number_type




More information about the Haskell-Cafe mailing list