Source file
test/typeparam/issue50264.go
1
2
3
4
5
6
7 package main
8
9 type hello struct{}
10
11 func main() {
12 _ = Some(hello{})
13 res := Applicative2(func(a int, b int) int {
14 return 0
15 })
16 _ = res
17 }
18
19 type NoneType[T any] struct{}
20
21 func (r NoneType[T]) Recover() any {
22 return nil
23 }
24
25 type Func2[A1, A2, R any] func(a1 A1, a2 A2) R
26
27 func Some[T any](v T) any {
28 _ = Some2[T](v)
29 return NoneType[T]{}.Recover()
30 }
31
32
33 func Some2[T any](v T) any {
34 return v
35 }
36
37 type Nil struct{}
38
39 type ApplicativeFunctor2[H, HT, A1, A2, R any] struct {
40 h any
41 }
42
43 func Applicative2[A1, A2, R any](fn Func2[A1, A2, R]) ApplicativeFunctor2[Nil, Nil, A1, A2, R] {
44 return ApplicativeFunctor2[Nil, Nil, A1, A2, R]{Some(Nil{})}
45 }
46
View as plain text