27.12.2013 Views

Wearing the hair shirt Wearing the hair shirt - Microsoft Research

Wearing the hair shirt Wearing the hair shirt - Microsoft Research

Wearing the hair shirt Wearing the hair shirt - Microsoft Research

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Type-based dispatch<br />

class Num a where<br />

(+) :: a -> a -> a<br />

negate :: a -> a<br />

fromInteger :: Integer -> a<br />

...<br />

double :: Num a => a -> a<br />

double x = 2*x<br />

means<br />

double :: Num a -> a -> a<br />

double d x = mul d (fromInteger d 2) x<br />

The overloaded value is returned by<br />

fromInteger, not passed to it. It is <strong>the</strong><br />

dictionary (and type) that are passed as<br />

argument to fromInteger

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!