-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
io.go
109 lines (91 loc) · 3.09 KB
/
io.go
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package mo
// NewIO instanciates a new IO.
func NewIO[R any](f f0[R]) IO[R] {
return IO[R]{
unsafePerform: f,
}
}
// IO represents a non-deterministic synchronous computation that
// can cause side effects, yields a value of type `R` and never fails.
type IO[R any] struct {
unsafePerform f0[R]
}
// Run execute the non-deterministic synchronous computation, with side effect.
func (io IO[R]) Run() R {
return io.unsafePerform()
}
// NewIO1 instanciates a new IO1.
func NewIO1[R any, A any](f f1[R, A]) IO1[R, A] {
return IO1[R, A]{
unsafePerform: f,
}
}
// IO1 represents a non-deterministic synchronous computation that
// can cause side effects, yields a value of type `R` and never fails.
type IO1[R any, A any] struct {
unsafePerform f1[R, A]
}
// Run execute the non-deterministic synchronous computation, with side effect.
func (io IO1[R, A]) Run(a A) R {
return io.unsafePerform(a)
}
// NewIO2 instanciates a new IO2.
func NewIO2[R any, A any, B any](f f2[R, A, B]) IO2[R, A, B] {
return IO2[R, A, B]{
unsafePerform: f,
}
}
// IO2 represents a non-deterministic synchronous computation that
// can cause side effects, yields a value of type `R` and never fails.
type IO2[R any, A any, B any] struct {
unsafePerform f2[R, A, B]
}
// Run execute the non-deterministic synchronous computation, with side effect.
func (io IO2[R, A, B]) Run(a A, b B) R {
return io.unsafePerform(a, b)
}
// NewIO3 instanciates a new IO3.
func NewIO3[R any, A any, B any, C any](f f3[R, A, B, C]) IO3[R, A, B, C] {
return IO3[R, A, B, C]{
unsafePerform: f,
}
}
// IO3 represents a non-deterministic synchronous computation that
// can cause side effects, yields a value of type `R` and never fails.
type IO3[R any, A any, B any, C any] struct {
unsafePerform f3[R, A, B, C]
}
// Run execute the non-deterministic synchronous computation, with side effect.
func (io IO3[R, A, B, C]) Run(a A, b B, c C) R {
return io.unsafePerform(a, b, c)
}
// NewIO4 instanciates a new IO4.
func NewIO4[R any, A any, B any, C any, D any](f f4[R, A, B, C, D]) IO4[R, A, B, C, D] {
return IO4[R, A, B, C, D]{
unsafePerform: f,
}
}
// IO4 represents a non-deterministic synchronous computation that
// can cause side effects, yields a value of type `R` and never fails.
type IO4[R any, A any, B any, C any, D any] struct {
unsafePerform f4[R, A, B, C, D]
}
// Run execute the non-deterministic synchronous computation, with side effect.
func (io IO4[R, A, B, C, D]) Run(a A, b B, c C, d D) R {
return io.unsafePerform(a, b, c, d)
}
// NewIO5 instanciates a new IO5.
func NewIO5[R any, A any, B any, C any, D any, E any](f f5[R, A, B, C, D, E]) IO5[R, A, B, C, D, E] {
return IO5[R, A, B, C, D, E]{
unsafePerform: f,
}
}
// IO5 represents a non-deterministic synchronous computation that
// can cause side effects, yields a value of type `R` and never fails.
type IO5[R any, A any, B any, C any, D any, E any] struct {
unsafePerform f5[R, A, B, C, D, E]
}
// Run execute the non-deterministic synchronous computation, with side effect.
func (io IO5[R, A, B, C, D, E]) Run(a A, b B, c C, d D, e E) R {
return io.unsafePerform(a, b, c, d, e)
}