codesnippets:typeclasses
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| codesnippets:typeclasses [2021/04/10 17:23] – [Deriving mechanism] f2b216 | codesnippets:typeclasses [2025/10/08 00:48] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Type classes and its instances, and the deriving mechanism ====== | ====== Type classes and its instances, and the deriving mechanism ====== | ||
| - | ~~DISCUSSION~~ | ||
| * A type class (keyword: '' | * A type class (keyword: '' | ||
| Line 6: | Line 5: | ||
| * have instances (keyword: '' | * have instances (keyword: '' | ||
| * module '' | * module '' | ||
| - | * {{:codesnippets: | + | * {{:modules: |
| + | * picture from: Dirk Hünniger | ||
| + | * source: [[https:// | ||
| * type '' | * type '' | ||
| * below all types that have implemented instances | * below all types that have implemented instances | ||
| Line 14: | Line 15: | ||
| *'' | *'' | ||
| * '' | * '' | ||
| + | * additionally, | ||
| + | * {{: | ||
| + | * source: [[https:// | ||
| * example, implementing an '' | * example, implementing an '' | ||
| * functions '' | * functions '' | ||
| Line 97: | Line 101: | ||
| ===== Deriving mechanism ===== | ===== Deriving mechanism ===== | ||
| - | Looking to the examples above you may wonder, whether there is a better | + | Looking to the examples above you may wonder, whether there an easier |
| - | * example, data type applies '' | + | * example, |
| * to implement all function of typeclass '' | * to implement all function of typeclass '' | ||
| * code:< | * code:< | ||
| Line 116: | Line 120: | ||
| ===== Advanced type classes ===== | ===== Advanced type classes ===== | ||
| - | * example, implementing a '' | + | * example, implementing a '' |
| + | * code:<code Haskell> | ||
| import Prelude hiding (Maybe(..), Functor(..)) | import Prelude hiding (Maybe(..), Functor(..)) | ||
| Line 140: | Line 145: | ||
| </ | </ | ||
| + | |||
| + | ===== ✎ ===== | ||
| + | ~~DISCUSSION~~ | ||
codesnippets/typeclasses.1618068233.txt.gz · Last modified: (external edit)
