Skip to content

Commit

Permalink
fix semigroup mixed answers (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
5z3wczykj4kub authored Jan 14, 2023
1 parent 9344c01 commit d741a9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/quiz-answers/semigroup-first.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Is the following semigroup instance lawful (does it respect semigroup laws)?
```ts
import { Semigroup } from 'fp-ts/Semigroup'

/** Always return the second argument */
const last = <A>(): Semigroup<A> => ({
concat: (_first, second) => second
/** Always return the first argument */
const first = <A>(): Semigroup<A> => ({
concat: (first, _second) => first
})
```

Expand All @@ -17,5 +17,5 @@ Yes:

- `first`, `second` and the result of `concat` (which is `first`) are all of the same type `A`
- `concat` is associative:
- `concat(concat(first, second), third)` evaluates to `concat(second, third)` which then evaluates to `third`
- `concat(first, concat(second, third))` evaluates to `concat(first, third)` which then evaluates to `third`
- `concat(concat(first, second), third)` evaluates to `concat(first, third)` which then evaluates to `first`
- `concat(first, concat(second, third))` evaluates to `concat(first, second)` which then evaluates to `first`
6 changes: 3 additions & 3 deletions src/quiz-answers/semigroup-second.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const last = <A>(): Semigroup<A> => ({

Yes:

- `first`, `second` and the result of `concat` (which is `first`) are all of the same type `A`
- `first`, `second` and the result of `concat` (which is `second`) are all of the same type `A`
- `concat` is associative:
- `concat(concat(first, second), third)` evaluates to `concat(first, third)` which then evaluates to `first`
- `concat(first, concat(second, third))` evaluates to `concat(first, second)` which then evaluates to `first`
- `concat(concat(first, second), third)` evaluates to `concat(second, third)` which then evaluates to `third`
- `concat(first, concat(second, third))` evaluates to `concat(first, third)` which then evaluates to `third`

0 comments on commit d741a9d

Please sign in to comment.