You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,14 @@ Homework to practice advanced work with typeclasses
8
8
* First, implement instances of `Validable` for each shape type with function `valid` that says if given shape is valid (its attributes are acceptable, i.e., not negative, forming a triangle).
9
9
* Then, design on your own the `Shape2D` typeclass which is a subclass of `Validable`, define `area` and `circumference` (remove dummy ones). During the design consider using `valid` - for invalid shape, both functions should return zero.
10
10
* Finally, implement instances of `Shape2D` for each shape type.
11
-
2.*Data.SortedList* = implement all necessary functions to make data type `SortedList` to be an instance of `Semigroup`, `Monoid`, `Functor`, `Applicative`, `Monad`. After applying `(<>)` the resulting list must be sorted. Sadly, `Functor`, `Applicative`, and `Monad` won't allow you to use `Ord` constaint so the result won't be sorted. Implement some sort function if you want to... It is **forbidden** to just delegate to list and use `fromList` and `toList`.
11
+
2.*Data.ResultList* = implement all necessary functions to make data type `ResultList` to be an instance of `Semigroup`, `Monoid`, `Functor`, `Applicative`, `Monad` (expectations should be clear from tests).
12
12
3. The final (and also the most interesting) task is to implement functions and instances for next data type to represent integers - the `RomanNumeral` (from `Data.RomanNumeral`)! It is a representation of an integer as Roman numeral, for example, `125` is `"CXXV"`.
13
13
* The biggest challenge is to implement functions `integral2RomanNumeral` and `romanNumeral2Integral` (related with `pack` and `unpack`). There is something already prepared in `Data.RomanNumeral.Helpers`. Take a look and feel free to edit as you need.
14
14
* After having `pack` and `unpack` working, it will be very easy to make instances of `Bounded`, `Eq`, `Ord`, `Num`, `Enum`, and `Integral` (*you might need some more due to dependencies*) for the `RomanNumeral`.
15
15
16
16
Hints & general requirements:
17
17
18
18
* You should not hardcode any string or character in `Data.RomanNumeral` - use only those defined in `Data.RomanNumeral.Helpers` or enhance it.
19
-
* Being [DRY](https://cs.wikipedia.org/wiki/Don%27t_repeat_yourself) is essential, do not repeat code. Name expressions to reuse then, introduce helper functions.
20
19
* Local names (via `where` or `let-in`) in functions should be introduced to make the code more readable. Creating very simple helper functions in module scope is not nice. If you need some complicated functions create separate "private" module.
21
20
* Make your code as clean as possible. Prefer pattern matching and syntactic sugar everywhere it is reasonable.
0 commit comments