Skip to content

Commit d40c8e1

Browse files
a shed full of bikes
Now Xcode knows better. :)
1 parent 5ac1635 commit d40c8e1

File tree

5 files changed

+156
-156
lines changed

5 files changed

+156
-156
lines changed

Swiftz.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
84A88FBB1A71DFA0003D53CF /* JSONSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONSpec.swift; sourceTree = "<group>"; };
115115
84A88FBC1A71DFA0003D53CF /* ListSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListSpec.swift; sourceTree = "<group>"; };
116116
84A88FBD1A71DFA0003D53CF /* MaybeSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaybeSpec.swift; sourceTree = "<group>"; };
117-
84A88FBE1A71DFA0003D53CF /* MonoidSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MonoidSpec.swift; sourceTree = "<group>"; };
117+
84A88FBE1A71DFA0003D53CF /* MonoidSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MonoidSpec.swift; sourceTree = "<group>"; usesTabs = 1; };
118118
84A88FBF1A71DFA0003D53CF /* MVarSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MVarSpec.swift; sourceTree = "<group>"; };
119119
84A88FC01A71DFA0003D53CF /* OptionalExtSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OptionalExtSpec.swift; sourceTree = "<group>"; };
120120
84A88FC11A71DFA0003D53CF /* PartyExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartyExample.swift; sourceTree = "<group>"; };
@@ -155,18 +155,18 @@
155155
84A88FF91A71DFC5003D53CF /* List.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = List.swift; sourceTree = "<group>"; };
156156
84A88FFA1A71DFC5003D53CF /* Maybe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Maybe.swift; sourceTree = "<group>"; };
157157
84A88FFB1A71DFC5003D53CF /* Monad.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Monad.swift; sourceTree = "<group>"; };
158-
84A88FFC1A71DFC5003D53CF /* Monoid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Monoid.swift; sourceTree = "<group>"; };
158+
84A88FFC1A71DFC5003D53CF /* Monoid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Monoid.swift; sourceTree = "<group>"; usesTabs = 1; };
159159
84A88FFD1A71DFC5003D53CF /* MVar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MVar.swift; sourceTree = "<group>"; };
160160
84A88FFE1A71DFC5003D53CF /* NonEmptyList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NonEmptyList.swift; sourceTree = "<group>"; };
161161
84A88FFF1A71DFC5003D53CF /* NSArrayExt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSArrayExt.swift; sourceTree = "<group>"; };
162162
84A890001A71DFC5003D53CF /* NSDictionaryExt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDictionaryExt.swift; sourceTree = "<group>"; };
163-
84A890011A71DFC5003D53CF /* Num.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Num.swift; sourceTree = "<group>"; };
163+
84A890011A71DFC5003D53CF /* Num.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Num.swift; sourceTree = "<group>"; usesTabs = 1; };
164164
84A890021A71DFC5003D53CF /* Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operators.swift; sourceTree = "<group>"; };
165165
84A890031A71DFC5003D53CF /* OptionalExt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OptionalExt.swift; sourceTree = "<group>"; };
166166
84A890041A71DFC5003D53CF /* Pointed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Pointed.swift; sourceTree = "<group>"; };
167167
84A890051A71DFC5003D53CF /* Prism.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Prism.swift; sourceTree = "<group>"; };
168168
84A890061A71DFC5003D53CF /* Sections.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Sections.swift; sourceTree = "<group>"; };
169-
84A890071A71DFC5003D53CF /* Semigroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Semigroup.swift; sourceTree = "<group>"; };
169+
84A890071A71DFC5003D53CF /* Semigroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Semigroup.swift; sourceTree = "<group>"; usesTabs = 1; };
170170
84A890081A71DFC5003D53CF /* Set.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Set.swift; sourceTree = "<group>"; };
171171
84A890091A71DFC5003D53CF /* StringExt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExt.swift; sourceTree = "<group>"; };
172172
84A8900A1A71DFC5003D53CF /* SYB.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SYB.swift; sourceTree = "<group>"; };

Swiftz/Monoid.swift

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -8,112 +8,112 @@
88

99
/// A Monoid is a Semigroup that distinguishes an identity element.
1010
public protocol Monoid : Semigroup {
11-
/// The identity element of the Monoid.
12-
class var mzero : Self { get }
11+
/// The identity element of the Monoid.
12+
class var mzero : Self { get }
1313
}
1414

1515
public func mconcat<S : Monoid>(t : [S]) -> S {
16-
return sconcat(S.mzero, t)
16+
return sconcat(S.mzero, t)
1717
}
1818

1919
/// The Monoid of numeric types under addition.
2020
public struct Sum<N : Num> : Monoid {
21-
public let value : () -> N
21+
public let value : () -> N
2222

23-
public init(_ x : @autoclosure () -> N) {
24-
value = x
25-
}
23+
public init(_ x : @autoclosure () -> N) {
24+
value = x
25+
}
2626

27-
public static var mzero : Sum<N> {
28-
return Sum(N.zero)
29-
}
27+
public static var mzero : Sum<N> {
28+
return Sum(N.zero)
29+
}
3030

31-
public func op(other : Sum<N>) -> Sum<N> {
32-
return Sum(value().plus(other.value()))
33-
}
31+
public func op(other : Sum<N>) -> Sum<N> {
32+
return Sum(value().plus(other.value()))
33+
}
3434
}
3535

3636
/// The Monoid of numeric types under multiplication.
3737
public struct Product<N : Num> : Monoid {
38-
public let value : () -> N
38+
public let value : () -> N
3939

40-
public init(_ x : @autoclosure () -> N) {
41-
value = x
42-
}
40+
public init(_ x : @autoclosure () -> N) {
41+
value = x
42+
}
4343

44-
public static var mzero : Product<N> {
45-
return Product(N.one)
46-
}
44+
public static var mzero : Product<N> {
45+
return Product(N.one)
46+
}
4747

48-
public func op(other : Product<N>) -> Product<N> {
49-
return Product(value().times(other.value()))
50-
}
48+
public func op(other : Product<N>) -> Product<N> {
49+
return Product(value().times(other.value()))
50+
}
5151
}
5252

5353
/// The Semigroup-lifting Maybe Monoid
5454
public struct AdjoinNil<A : Semigroup> : Monoid {
55-
public let value : () -> Maybe<A>
56-
57-
public init(_ x : @autoclosure () -> Maybe<A>) {
58-
value = x
59-
}
60-
61-
public static var mzero : AdjoinNil<A> {
62-
return AdjoinNil(Maybe.none())
63-
}
64-
65-
public func op(other : AdjoinNil<A>) -> AdjoinNil<A> {
66-
if let x = value().value {
67-
if let y = other.value().value {
68-
return AdjoinNil(Maybe(x.op(y)))
69-
} else {
70-
return self
71-
}
72-
} else {
73-
return other
74-
}
75-
}
55+
public let value : () -> Maybe<A>
56+
57+
public init(_ x : @autoclosure () -> Maybe<A>) {
58+
value = x
59+
}
60+
61+
public static var mzero : AdjoinNil<A> {
62+
return AdjoinNil(Maybe.none())
63+
}
64+
65+
public func op(other : AdjoinNil<A>) -> AdjoinNil<A> {
66+
if let x = value().value {
67+
if let y = other.value().value {
68+
return AdjoinNil(Maybe(x.op(y)))
69+
} else {
70+
return self
71+
}
72+
} else {
73+
return other
74+
}
75+
}
7676
}
7777

7878
/// The left-biased Maybe Monoid.
7979
public struct First<A : Comparable> : Monoid {
80-
public let value : () -> Maybe<A>
81-
82-
public init(_ x : @autoclosure () -> Maybe<A>) {
83-
value = x
84-
}
85-
86-
public static var mzero : First<A> {
87-
return First(Maybe.none())
88-
}
89-
90-
public func op(other : First<A>) -> First<A> {
91-
if value().isJust() {
92-
return self
93-
} else {
94-
return other
95-
}
96-
}
80+
public let value : () -> Maybe<A>
81+
82+
public init(_ x : @autoclosure () -> Maybe<A>) {
83+
value = x
84+
}
85+
86+
public static var mzero : First<A> {
87+
return First(Maybe.none())
88+
}
89+
90+
public func op(other : First<A>) -> First<A> {
91+
if value().isJust() {
92+
return self
93+
} else {
94+
return other
95+
}
96+
}
9797
}
9898

9999
/// The right-biased Maybe Monoid.
100100
public struct Last<A : Comparable> : Monoid {
101-
public let value : () -> Maybe<A>
102-
103-
public init(_ x : @autoclosure () -> Maybe<A>) {
104-
value = x
105-
}
106-
107-
public static var mzero : Last<A> {
108-
return Last(Maybe.none())
109-
}
110-
111-
public func op(other : Last<A>) -> Last<A> {
112-
if other.value().isJust() {
113-
return other
114-
} else {
115-
return self
116-
}
117-
}
101+
public let value : () -> Maybe<A>
102+
103+
public init(_ x : @autoclosure () -> Maybe<A>) {
104+
value = x
105+
}
106+
107+
public static var mzero : Last<A> {
108+
return Last(Maybe.none())
109+
}
110+
111+
public func op(other : Last<A>) -> Last<A> {
112+
if other.value().isJust() {
113+
return other
114+
} else {
115+
return self
116+
}
117+
}
118118
}
119119

Swiftz/Num.swift

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,64 +10,64 @@
1010
// Num 'typeclass'
1111

1212
public protocol Num {
13-
class var zero: Self { get }
14-
class var one: Self { get }
15-
func plus(other: Self) -> Self
16-
func times(other: Self) -> Self
13+
class var zero: Self { get }
14+
class var one: Self { get }
15+
func plus(other: Self) -> Self
16+
func times(other: Self) -> Self
1717
}
1818

1919
extension Int8 : Num {
20-
public static var zero: Int8 { return 0 }
21-
public static var one: Int8 { return 1 }
22-
public func plus(other: Int8) -> Int8 { return self + other }
23-
public func times(other: Int8) -> Int8 { return self * other }
20+
public static var zero: Int8 { return 0 }
21+
public static var one: Int8 { return 1 }
22+
public func plus(other: Int8) -> Int8 { return self + other }
23+
public func times(other: Int8) -> Int8 { return self * other }
2424
}
2525

2626
extension Int16 : Num {
27-
public static var zero: Int16 { return 0 }
28-
public static var one: Int16 { return 1 }
29-
public func plus(other: Int16) -> Int16 { return self + other }
30-
public func times(other: Int16) -> Int16 { return self * other }
27+
public static var zero: Int16 { return 0 }
28+
public static var one: Int16 { return 1 }
29+
public func plus(other: Int16) -> Int16 { return self + other }
30+
public func times(other: Int16) -> Int16 { return self * other }
3131
}
3232

3333
extension Int32 : Num {
34-
public static var zero: Int32 { return 0 }
35-
public static var one: Int32 { return 1 }
36-
public func plus(other: Int32) -> Int32 { return self + other }
37-
public func times(other: Int32) -> Int32 { return self * other }
34+
public static var zero: Int32 { return 0 }
35+
public static var one: Int32 { return 1 }
36+
public func plus(other: Int32) -> Int32 { return self + other }
37+
public func times(other: Int32) -> Int32 { return self * other }
3838
}
3939

4040
extension Int64 : Num {
41-
public static var zero: Int64 { return 0 }
42-
public static var one: Int64 { return 1 }
43-
public func plus(other: Int64) -> Int64 { return self + other }
44-
public func times(other: Int64) -> Int64 { return self * other }
41+
public static var zero: Int64 { return 0 }
42+
public static var one: Int64 { return 1 }
43+
public func plus(other: Int64) -> Int64 { return self + other }
44+
public func times(other: Int64) -> Int64 { return self * other }
4545
}
4646

4747
extension UInt8 : Num {
48-
public static var zero: UInt8 { return 0 }
49-
public static var one: UInt8 { return 1 }
50-
public func plus(other: UInt8) -> UInt8 { return self + other }
51-
public func times(other: UInt8) -> UInt8 { return self * other }
48+
public static var zero: UInt8 { return 0 }
49+
public static var one: UInt8 { return 1 }
50+
public func plus(other: UInt8) -> UInt8 { return self + other }
51+
public func times(other: UInt8) -> UInt8 { return self * other }
5252
}
5353

5454
extension UInt16 : Num {
55-
public static var zero: UInt16 { return 0 }
56-
public static var one: UInt16 { return 1 }
57-
public func plus(other: UInt16) -> UInt16 { return self + other }
58-
public func times(other: UInt16) -> UInt16 { return self * other }
55+
public static var zero: UInt16 { return 0 }
56+
public static var one: UInt16 { return 1 }
57+
public func plus(other: UInt16) -> UInt16 { return self + other }
58+
public func times(other: UInt16) -> UInt16 { return self * other }
5959
}
6060

6161
extension UInt32 : Num {
62-
public static var zero: UInt32 { return 0 }
63-
public static var one: UInt32 { return 1 }
64-
public func plus(other: UInt32) -> UInt32 { return self + other }
65-
public func times(other: UInt32) -> UInt32 { return self * other }
62+
public static var zero: UInt32 { return 0 }
63+
public static var one: UInt32 { return 1 }
64+
public func plus(other: UInt32) -> UInt32 { return self + other }
65+
public func times(other: UInt32) -> UInt32 { return self * other }
6666
}
6767

6868
extension UInt64 : Num {
69-
public static var zero: UInt64 { return 0 }
70-
public static var one: UInt64 { return 1 }
71-
public func plus(other: UInt64) -> UInt64 { return self + other }
72-
public func times(other: UInt64) -> UInt64 { return self * other }
69+
public static var zero: UInt64 { return 0 }
70+
public static var one: UInt64 { return 1 }
71+
public func plus(other: UInt64) -> UInt64 { return self + other }
72+
public func times(other: UInt64) -> UInt64 { return self * other }
7373
}

Swiftz/Semigroup.swift

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,44 @@
99
/// A Semigroup is a type with a closed, associative, binary operator.
1010
public protocol Semigroup {
1111

12-
/// An associative binary operator.
13-
func op(other : Self) -> Self
12+
/// An associative binary operator.
13+
func op(other : Self) -> Self
1414
}
1515

1616
public func sconcat<S: Semigroup>(h : S, t : [S]) -> S {
17-
return t.reduce(h) { $0.op($1) }
17+
return t.reduce(h) { $0.op($1) }
1818
}
1919

2020
/// The Semigroup of comparable values under MIN().
2121
public struct Min<A: Comparable>: Semigroup {
22-
public let value: () -> A
23-
24-
public init(_ x: @autoclosure () -> A) {
25-
value = x
26-
}
27-
28-
public func op(other : Min<A>) -> Min<A> {
29-
if value() < other.value() {
30-
return self
31-
} else {
32-
return other
33-
}
34-
}
22+
public let value: () -> A
23+
24+
public init(_ x: @autoclosure () -> A) {
25+
value = x
26+
}
27+
28+
public func op(other : Min<A>) -> Min<A> {
29+
if value() < other.value() {
30+
return self
31+
} else {
32+
return other
33+
}
34+
}
3535
}
3636

3737
/// The Semigroup of comparable values under MAX().
3838
public struct Max<A: Comparable> : Semigroup {
39-
public let value: () -> A
40-
41-
public init(_ x: @autoclosure () -> A) {
42-
value = x
43-
}
44-
45-
public func op(other : Max<A>) -> Max<A> {
46-
if other.value() < value() {
47-
return self
48-
} else {
49-
return other
50-
}
51-
}
39+
public let value: () -> A
40+
41+
public init(_ x: @autoclosure () -> A) {
42+
value = x
43+
}
44+
45+
public func op(other : Max<A>) -> Max<A> {
46+
if other.value() < value() {
47+
return self
48+
} else {
49+
return other
50+
}
51+
}
5252
}

0 commit comments

Comments
 (0)