-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEither.spec.ts
43 lines (41 loc) · 1.01 KB
/
Either.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/** Typeclass law tests for the `Either` datatype. */
import {
Applicative,
Bicovariant,
Monad,
SemiAlternative,
Traversable,
} from '@effect/typeclass/data/Either'
import {Either as EI, String as STR} from 'effect'
import {
either,
LiftArbitrary,
LiftEquivalence,
monoEquivalence,
} from 'effect-ts-laws'
import {testTypeclassLaws} from 'effect-ts-laws/vitest'
import {EitherTypeLambda} from 'effect/Either'
import fc from 'fast-check'
describe('@effect/typeclass/data/Either', () => {
const getEquivalence: LiftEquivalence<
EitherTypeLambda,
never,
unknown,
string
> = equivalenceO =>
EI.getEquivalence({left: STR.Equivalence, right: equivalenceO})
const getArbitrary: LiftArbitrary<
EitherTypeLambda,
never,
unknown,
string
> = arbitraryA => either(fc.string(), arbitraryA)
testTypeclassLaws({getEquivalence, getArbitrary})({
Applicative,
Bicovariant,
Equivalence: getEquivalence(monoEquivalence),
Monad,
SemiAlternative,
Traversable,
})
})