---
# System prepended metadata

title: Scala Lab 8

---

# Scala Lab 8

## Task 1 – 20%

The laws of `PartialEquality` and `Equality` instances for `Int` and `Long` are already covered by property tests. Extend these tests to include laws of `PartialOrd` and `Ord`. Add an `Equality[String]` instance and cover it by relevant tests, too.

You could do this by introducing additional base abstract classes with only the new properties, and then additional object for each type class instance inheriting the new abstract class. Another way is to copy the abstract class with all previous laws and make the object inherit only the new abstract class. The choice of implementation does not matter.

## Task 2 – 30%

Complete definitions of the monoid type class hierarchy to match the definitions from the slides. You can find the complete definitions of ordering and equality type classes in the file `Ord.scala`, and the monoid type classes should be defined in the file `Monoid.scala`.

The type class definitions should have correct methods, as well as companion objects with summoners and instances for types: `Int`, `Long`, `Float`, `Double`, `[T] => List[T]`, `[K, V: Semigroup] => Map[K, V]`.

## Task 3 – 30%

Complete the monoid-based syntax extensions in the package `dogs.syntax.monoid`. Use already completed syntax extensions in `dogs.syntax.ord` for inspiration.

All extension methods should be total and safe to use, particularly the `reduce` method should be safe to call on an empty list.

## Task 4 – 20%

In packages `dogs.syntax.option` and `dogs.syntax.either` define syntax extensions which provide following methods on arbitrary types:
- `a.some` returns `Option[a.type]`
- `a.right` returns `Either[Nothing, a.type]`
- `a.left` returns `Either[a.type, Nothing]`
