typeclasses / haskell-phrasebook

The Haskell Phrasebook: a quick intro to Haskell via small annotated example programs
https://typeclasses.com/phrasebook
210 stars 22 forks source link

Type classes #26

Open BenBals opened 5 years ago

BenBals commented 5 years ago

I think the main aspect of typeclasses is defining common behavior for a set of types. In this playful example we have a set of character type belonging to the class Playable. Players have a healing power so the class reflects that. The example illustrates that the class instances can work differently from each other (warriors have a constant healing power, mages not).

I hope you like the example.

In reference to issue #10.