
15 Dec
2004
15 Dec
'04
6:41 a.m.
On Wed, 15 Dec 2004, William Lee Irwin III wrote:
On Wed, Dec 15, 2004 at 10:28:18AM +0000, Ross Paterson wrote:
abs :: Num a => a -> a, whereas you want something that returns a Double. You could define class Norm a where norm :: a -> Double instance Norm Float where norm = realToFrac . abs instance Norm Double where norm = abs instance RealFloat a => Norm (Complex a) where norm = realToFrac . magnitude and use norm instead of abs.
Thanks; this appears to do the trick for me. Something of this kind would be useful to have in the std. libraries, at least for me.
http://cvs.haskell.org/darcs/numericprelude/physunit/Normalization.hs