Skip to content

Commit c65e635

Browse files
committed
Align precedence marks with runes
1 parent a5897e8 commit c65e635

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Operators.swift

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
// Copyright (c) 2015 TypeLift. All rights reserved.
77
// Released under the MIT License.
88
//
9+
// Precedence marks for certain symbols aligned with Runes
10+
// ~( https://github.com/thoughtbot/Runes/blob/master/Source/Runes.swift ) until Swift gets a proper
11+
// resolver.
912

1013
// MARK: Combinators
1114

@@ -18,19 +21,19 @@ infix operator • {
1821
/// Apply | Applies an argument to a function.
1922
infix operator § {
2023
associativity right
21-
precedence 0
24+
precedence 95
2225
}
2326

2427
/// Pipe Backward | Applies the function to its left to an argument on its right.
2528
infix operator <| {
2629
associativity right
27-
precedence 0
30+
precedence 95
2831
}
2932

3033
/// Pipe forward | Applies an argument on the left to a function on the right.
3134
infix operator |> {
3235
associativity left
33-
precedence 0
36+
precedence 95
3437
}
3538

3639
/// On | Given a "combining" function and a function that converts arguments to the target of the
@@ -47,7 +50,8 @@ infix operator |*| {
4750
/// Fmap | Maps a function over the value encapsulated by a functor.
4851
infix operator <^> {
4952
associativity left
50-
precedence 140
53+
// https://github.com/thoughtbot/Runes/blob/master/Source/Runes.swift
54+
precedence 130
5155
}
5256

5357
/// Replace | Maps all the values encapsulated by a functor to a user-specified constant.
@@ -66,7 +70,8 @@ infix operator ^> {
6670
/// Ap | Applies a function encapsulated by a functor to the value encapsulated by another functor.
6771
infix operator <*> {
6872
associativity left
69-
precedence 140
73+
// https://github.com/thoughtbot/Runes/blob/master/Source/Runes.swift
74+
precedence 130
7075
}
7176

7277
/// Sequence Right | Disregards the Functor on the Left.
@@ -91,14 +96,16 @@ infix operator <* {
9196
/// left to a function on the right yielding a new monad.
9297
infix operator >>- {
9398
associativity left
94-
precedence 110
99+
// https://github.com/thoughtbot/Runes/blob/master/Source/Runes.swift
100+
precedence 100
95101
}
96102

97103
/// Bind Backwards | Composes two monadic actions by passing the value inside the monad on the
98104
/// right to the funciton on the left.
99105
infix operator -<< {
100106
associativity right
101-
precedence 110
107+
// https://github.com/thoughtbot/Runes/blob/master/Source/Runes.swift
108+
precedence 100
102109
}
103110

104111
/// Left-to-Right Kleisli | Composition for monads.

0 commit comments

Comments
 (0)