-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsl.go
39 lines (32 loc) · 765 Bytes
/
dsl.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
package hy_go_function
type operation string
const (
filter = operation("filter")
maps = operation("map")
flatMap = operation("flatmap")
)
type DSL struct {
function []interface{}
value interface{}
operations []operation
}
func Of(value interface{}) DSL {
return DSL{
value: value,
}
}
func (d DSL) Filter(predicate interface{}) DSL {
d.operations = append(d.operations, filter)
d.function = append(d.function, predicate)
return d
}
func (d DSL) FlatMap(function interface{}) DSL {
d.operations = append(d.operations, flatMap)
d.function = append(d.function, function)
return d
}
func (d DSL) Map(function interface{}) DSL {
d.operations = append(d.operations, maps)
d.function = append(d.function, function)
return d
}