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

research.microsoft.com
from research.microsoft.com More from this publisher
27.12.2013 Views

Extensiblity Like OOP, one can add new data types “later”. E.g. QuickCheck works for your new data types (provided you make them instances of Arby) ...but also not like OOP

Type-based dispatch class Num a where (+) :: a -> a -> a negate :: a -> a fromInteger :: Integer -> a ... A bit like OOP, except that method suite passed separately? double :: Num a => a -> a double x = x+x No: type classes implement type-based dispatch, not value-based dispatch

Type-based dispatch<br />

class Num a where<br />

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

negate :: a -> a<br />

fromInteger :: Integer -> a<br />

...<br />

A bit like OOP, except that method suite<br />

passed separately?<br />

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

double x = x+x<br />

No: type classes implement type-based<br />

dispatch, not value-based dispatch

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

Saved successfully!

Ooh no, something went wrong!