-
-
Notifications
You must be signed in to change notification settings - Fork 503
/
MonadThrow.ts
72 lines (64 loc) · 1.74 KB
/
MonadThrow.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* The `MonadThrow` type class represents those monads which support errors via
* `throwError`, where `throwError(e)` halts, yielding the error `e`.
*
* Laws:
*
* - Left zero: `M.chain(M.throwError(e), f) = M.throwError(e)`
*
* @since 2.0.0
*/
import { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'
import { Monad, Monad1, Monad2, Monad2C, Monad3, Monad3C, Monad4 } from './Monad'
// -------------------------------------------------------------------------------------
// model
// -------------------------------------------------------------------------------------
/**
* @category model
* @since 2.0.0
*/
export interface MonadThrow<M> extends Monad<M> {
readonly throwError: <E, A>(e: E) => HKT<M, A>
}
/**
* @category model
* @since 2.0.0
*/
export interface MonadThrow1<M extends URIS> extends Monad1<M> {
readonly throwError: <E, A>(e: E) => Kind<M, A>
}
/**
* @category model
* @since 2.0.0
*/
export interface MonadThrow2<M extends URIS2> extends Monad2<M> {
readonly throwError: <E, A>(e: E) => Kind2<M, E, A>
}
/**
* @category model
* @since 2.0.0
*/
export interface MonadThrow2C<M extends URIS2, E> extends Monad2C<M, E> {
readonly throwError: <A>(e: E) => Kind2<M, E, A>
}
/**
* @category model
* @since 2.0.0
*/
export interface MonadThrow3<M extends URIS3> extends Monad3<M> {
readonly throwError: <R, E, A>(e: E) => Kind3<M, R, E, A>
}
/**
* @category model
* @since 2.2.0
*/
export interface MonadThrow3C<M extends URIS3, E> extends Monad3C<M, E> {
readonly throwError: <R, A>(e: E) => Kind3<M, R, E, A>
}
/**
* @category model
* @since 2.0.0
*/
export interface MonadThrow4<M extends URIS4> extends Monad4<M> {
readonly throwError: <S, R, E, A>(e: E) => Kind4<M, S, R, E, A>
}