@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | { |
22 | 22 | public static function concat(): Closure |
23 | 23 | { |
24 | - return static fn (callable $xs): Closure => static fn (callable $ys): Closure => self::foldr()(self::cons())($ys)($xs); |
|
24 | + return static fn(callable $xs): Closure => static fn(callable $ys): Closure => self::foldr()(self::cons())($ys)($xs); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public static function cons(): Closure |
28 | 28 | { |
29 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => Pair::of()(Boolean::CFalse())(Pair::of()($a)($b)); |
|
29 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => Pair::of()(Boolean::CFalse())(Pair::of()($a)($b)); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public static function foldl() |
36 | 36 | { |
37 | - return static fn (callable $f): Closure => static fn ($a): Closure => static fn (callable $xs) => self::foldr()( |
|
38 | - static fn (callable $x): Closure => static fn (callable $g): Closure => static fn ($y) => $g($f($y)($x)) |
|
37 | + return static fn(callable $f): Closure => static fn($a): Closure => static fn(callable $xs) => self::foldr()( |
|
38 | + static fn(callable $x): Closure => static fn(callable $g): Closure => static fn($y) => $g($f($y)($x)) |
|
39 | 39 | )(Combinators::I())($xs)($a); |
40 | 40 | } |
41 | 41 | |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | public static function foldr() |
46 | 46 | { |
47 | 47 | return Combinators::Y()( |
48 | - static fn (callable $r): Closure => static fn (callable $f): Closure => static fn ($a): Closure => static fn (callable $xs) => Boolean::CIf()(self::isNil()($xs))(static fn () => $a)(static fn () => $f(self::head()($xs))($r($f)($a)(self::tail()($xs))))() |
|
48 | + static fn(callable $r): Closure => static fn(callable $f): Closure => static fn($a): Closure => static fn(callable $xs) => Boolean::CIf()(self::isNil()($xs))(static fn() => $a)(static fn() => $f(self::head()($xs))($r($f)($a)(self::tail()($xs))))() |
|
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | 52 | public static function head(): Closure |
53 | 53 | { |
54 | - return static fn (callable $a): Closure => Pair::first()(Pair::second()($a)); |
|
54 | + return static fn(callable $a): Closure => Pair::first()(Pair::second()($a)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function isNil(): Closure |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public static function length(): Closure |
63 | 63 | { |
64 | - return self::foldl()(static fn (callable $a): Closure => static fn (callable $b): Closure => Numeral::succ()($a))(Numeral::zero()); |
|
64 | + return self::foldl()(static fn(callable $a): Closure => static fn(callable $b): Closure => Numeral::succ()($a))(Numeral::zero()); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public static function nil(): Closure |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | |
72 | 72 | public static function range(): Closure |
73 | 73 | { |
74 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => Numeral::minus()(Numeral::succ()($b))($a)(static fn (callable $c): Closure => CList::cons()(Numeral::minus()($b)(CList::length()($c)))($c))(CList::nil()); |
|
74 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => Numeral::minus()(Numeral::succ()($b))($a)(static fn(callable $c): Closure => CList::cons()(Numeral::minus()($b)(CList::length()($c)))($c))(CList::nil()); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | public static function repeat(): Closure |
78 | 78 | { |
79 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => $b( |
|
80 | - static fn ($c): Closure => CList::cons()($a)($c) |
|
79 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => $b( |
|
80 | + static fn($c): Closure => CList::cons()($a)($c) |
|
81 | 81 | )(CList::nil()); |
82 | 82 | } |
83 | 83 | |
@@ -88,6 +88,6 @@ discard block |
||
88 | 88 | |
89 | 89 | public static function tail(): Closure |
90 | 90 | { |
91 | - return static fn (callable $a): Closure => Pair::second()(Pair::second()($a)); |
|
91 | + return static fn(callable $a): Closure => Pair::second()(Pair::second()($a)); |
|
92 | 92 | } |
93 | 93 | } |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | |
62 | 62 | public static function plus(): Closure |
63 | 63 | { |
64 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => static fn (callable $c): Closure => Combinators::B()($a($c))($b($c)); |
|
64 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => static fn(callable $c): Closure => Combinators::B()($a($c))($b($c)); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public static function pred(): Closure |
68 | 68 | { |
69 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => static fn ($c) => $a(static fn (callable $d): Closure => static fn (callable $e) => $e($d($b)))(static fn () => $c)(Combinators::I()); |
|
69 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => static fn($c) => $a(static fn(callable $d): Closure => static fn(callable $e) => $e($d($b)))(static fn() => $c)(Combinators::I()); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public static function seven(): Closure |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | public static function succ(): Closure |
83 | 83 | { |
84 | - return static fn (callable $n): Closure => static fn (callable $f): Closure => Combinators::B()($f)($n($f)); |
|
84 | + return static fn(callable $n): Closure => static fn(callable $f): Closure => Combinators::B()($f)($n($f)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public static function three(): Closure |
@@ -91,14 +91,13 @@ discard block |
||
91 | 91 | |
92 | 92 | public static function toInt(callable $numeral): int |
93 | 93 | { |
94 | - return $numeral(static fn (int $n): int => $n + 1)(0); |
|
94 | + return $numeral(static fn(int $n): int => $n + 1)(0); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | public static function toNumeral(int $n): Closure |
98 | 98 | { |
99 | 99 | return 0 === $n ? |
100 | - Numeral::zero() : |
|
101 | - Numeral::succ()(Numeral::toNumeral($n - 1)); |
|
100 | + Numeral::zero() : Numeral::succ()(Numeral::toNumeral($n - 1)); |
|
102 | 101 | } |
103 | 102 | |
104 | 103 | public static function two(): Closure |
@@ -108,6 +107,6 @@ discard block |
||
108 | 107 | |
109 | 108 | public static function zero(): Closure |
110 | 109 | { |
111 | - return static fn (): Closure => Combinators::I(); |
|
110 | + return static fn(): Closure => Combinators::I(); |
|
112 | 111 | } |
113 | 112 | } |