Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
|
pp:class [2021/04/11 15:16] lfa |
pp:class [2021/04/11 22:15] (current) lfa |
||
|---|---|---|---|
| Line 86: | Line 86: | ||
| As you can see, now we can add our data types in the new class, but also Haskell's types. The only requirement is that the enrolled type must implement our method. | As you can see, now we can add our data types in the new class, but also Haskell's types. The only requirement is that the enrolled type must implement our method. | ||
| - | 5. Create a class ''Contains b a'' that will require a ''contains :: b -> a -> Bool'' method which will return True if ''a'' is in ''b''. | + | 5. Create a class ''Contains b a'' that will require a ''contains :: b -> a -> Bool'' method which will return True if ''a'' is in ''b''. Add ''[a]'', ''List a'' and ''BTree a'' to this class. |
| <note tip>Do we need any additional restrictions for a or b? You can still add restrictions: | <note tip>Do we need any additional restrictions for a or b? You can still add restrictions: | ||
| <code haskell> | <code haskell> | ||
| Line 92: | Line 92: | ||
| </code></note> | </code></note> | ||
| - | 6. Create the ''class Size a'' which will require the methods ''size'' and ''uniqueSize'' | + | 6. Create the ''class Size a'' which will require the methods ''size'' and ''uniqueSize''. Add ''[a]'', ''List a'' and ''BTree a'' to this class. |
| - //size// = the numbers of elements in **a** | - //size// = the numbers of elements in **a** | ||
| - //uniqueSize// = the number of uniqueElements in **a** | - //uniqueSize// = the number of uniqueElements in **a** | ||