diff --git a/.travis.yml b/.travis.yml
index 1844a8f..96b64cd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,5 @@
language: objective-c
-osx_image: xcode7.2
+osx_image: xcode7.3
env:
- TEST_CONFIG="RELEASE"
- TEST_CONFIG="PODS"
@@ -7,7 +7,7 @@ env:
before_install: true
install: true
script:
- - if [[ "$TEST_CONFIG" == "RELEASE" ]]; then script/cibuild Swiftz Swiftz-iOS ; fi
+ - if [[ "$TEST_CONFIG" == "RELEASE" ]]; then script/cibuild Swiftz ; fi
- if [[ "$TEST_CONFIG" == "RELEASE" ]]; then xcodebuild test -scheme Swiftz-tvOS -destination 'platform=tvOS Simulator,name=Apple TV 1080p' ; fi
- if [[ "$TEST_CONFIG" == "RELEASE" ]]; then xcodebuild build -scheme Swiftz-watchOS -destination 'platform=watchOS Simulator,name=Apple Watch - 42mm' ; fi
- if [[ "$TEST_CONFIG" == "PODS" ]]; then pod lib lint; fi
diff --git a/Cartfile.resolved b/Cartfile.resolved
index a76cdfc..74af92e 100644
--- a/Cartfile.resolved
+++ b/Cartfile.resolved
@@ -1,3 +1,3 @@
-github "typelift/Operadics" "e21d7edbe02c7e34ae6a33ba59d278b613b2ce44"
-github "typelift/SwiftCheck" "v0.4.4"
-github "typelift/Swiftx" "v0.3.2"
+github "typelift/Operadics" "8117a84bb4111814c35af80285f3f9baff290d7e"
+github "typelift/SwiftCheck" "v0.6.0"
+github "typelift/Swiftx" "v0.4.0"
diff --git a/Carthage/Checkouts/Operadics b/Carthage/Checkouts/Operadics
index e21d7ed..8117a84 160000
--- a/Carthage/Checkouts/Operadics
+++ b/Carthage/Checkouts/Operadics
@@ -1 +1 @@
-Subproject commit e21d7edbe02c7e34ae6a33ba59d278b613b2ce44
+Subproject commit 8117a84bb4111814c35af80285f3f9baff290d7e
diff --git a/Carthage/Checkouts/SwiftCheck b/Carthage/Checkouts/SwiftCheck
index 118d474..f214146 160000
--- a/Carthage/Checkouts/SwiftCheck
+++ b/Carthage/Checkouts/SwiftCheck
@@ -1 +1 @@
-Subproject commit 118d47429bef32296e2f663ae72d8aa24d4c9a66
+Subproject commit f2141461f015315cc583222f0bb30ae07da8aad8
diff --git a/Carthage/Checkouts/Swiftx b/Carthage/Checkouts/Swiftx
index baeda0d..95b8978 160000
--- a/Carthage/Checkouts/Swiftx
+++ b/Carthage/Checkouts/Swiftx
@@ -1 +1 @@
-Subproject commit baeda0db436708521bd3fc5d8c81b29c9dbe3b63
+Subproject commit 95b897833340206b5c2f531a22dd5ab235c1194c
diff --git a/Swiftz.podspec b/Swiftz.podspec
index ed5d0c3..b076351 100644
--- a/Swiftz.podspec
+++ b/Swiftz.podspec
@@ -12,5 +12,5 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = "9.1"
s.watchos.deployment_target = "2.1"
s.source = { :git => "https://github.com/typelift/Swiftz.git", :tag => "v#{s.version}", :submodules => true }
- s.source_files = "Swiftz/*.swift", "**/Swiftx/*.swift", "Carthage/Checkouts/Operadics/*.swift"
+ s.source_files = "Swiftz/*.swift", "**/Swiftx/*.swift", "Carthage/Checkouts/Operadics/Operators.swift"
end
diff --git a/Swiftz/Applicative.swift b/Swiftz/Applicative.swift
index 37889a7..5b4cd2e 100644
--- a/Swiftz/Applicative.swift
+++ b/Swiftz/Applicative.swift
@@ -13,7 +13,7 @@
/// needing to unwrap or map over their contents.
public protocol Applicative : Pointed, Functor {
/// Type of Functors containing morphisms from our objects to a target.
- typealias FAB = K1 B>
+ associatedtype FAB = K1 B>
/// Applies the function encapsulated by the Functor to the value encapsulated by the receiver.
func ap(f : FAB) -> FB
@@ -21,10 +21,10 @@ public protocol Applicative : Pointed, Functor {
/// Additional functions to be implemented by those types conforming to the Applicative protocol.
public protocol ApplicativeOps : Applicative {
- typealias C
- typealias FC = K1
- typealias D
- typealias FD = K1
+ associatedtype C
+ associatedtype FC = K1
+ associatedtype D
+ associatedtype FD = K1
/// Lift a function to a Functorial action.
static func liftA(f : A -> B) -> Self -> FB
diff --git a/Swiftz/Arrow.swift b/Swiftz/Arrow.swift
index d747e9b..1e2015b 100644
--- a/Swiftz/Arrow.swift
+++ b/Swiftz/Arrow.swift
@@ -44,25 +44,25 @@
/// Arrows inherit from Category so we can get Composition For Free™.
public protocol Arrow : Category {
/// Some arbitrary target our arrow can compose with.
- typealias D
+ associatedtype D
/// Some arbitrary target our arrow can compose with.
- typealias E
+ associatedtype E
/// Type of the result of first().
- typealias FIRST = K2<(A, D), (B, D)>
+ associatedtype FIRST = K2<(A, D), (B, D)>
/// Type of the result of second().
- typealias SECOND = K2<(D, A), (D, B)>
+ associatedtype SECOND = K2<(D, A), (D, B)>
/// Some arrow with an arbitrary target and source. Used in split().
- typealias ADE = K2
+ associatedtype ADE = K2
/// Type of the result of ***.
- typealias SPLIT = K2<(A, D), (B, E)>
+ associatedtype SPLIT = K2<(A, D), (B, E)>
/// Some arrow from our target to some other arbitrary target. Used in fanout().
- typealias ABD = K2
+ associatedtype ABD = K2
/// Type of the result of &&&.
- typealias FANOUT = K2
+ associatedtype FANOUT = K2
/// Lift a function to an arrow.
static func arr(_ : A -> B) -> Self
@@ -92,7 +92,7 @@ public protocol Arrow : Category {
/// Arrows that can produce an identity arrow.
public protocol ArrowZero : Arrow {
/// An arrow from A -> B. Colloquially, the "zero arrow".
- typealias ABC = K2
+ associatedtype ABC = K2
/// The identity arrow.
static func zeroArrow() -> ABC
@@ -132,17 +132,17 @@ public protocol ArrowPlus : ArrowZero {
///
public protocol ArrowChoice : Arrow {
/// The result of left
- typealias LEFT = K2, Either>
+ associatedtype LEFT = K2, Either>
/// The result of right
- typealias RIGHT = K2, Either>
+ associatedtype RIGHT = K2, Either>
/// The result of +++
- typealias SPLAT = K2, Either>
+ associatedtype SPLAT = K2, Either>
/// Some arrow from a different source and target for fanin.
- typealias ACD = K2
+ associatedtype ACD = K2
/// The result of |||
- typealias FANIN = K2, D>
+ associatedtype FANIN = K2, D>
/// Feed marked inputs through the argument arrow, passing the rest through unchanged to the
/// output.
@@ -169,7 +169,7 @@ public protocol ArrowChoice : Arrow {
/// a -------> a - •
///
public protocol ArrowApply : Arrow {
- typealias APP = K2<(Self, A), B>
+ associatedtype APP = K2<(Self, A), B>
static func app() -> APP
}
@@ -185,7 +185,7 @@ public protocol ArrowApply : Arrow {
/// d-------•
///
public protocol ArrowLoop : Arrow {
- typealias LOOP = K2<(A, D), (B, D)>
+ associatedtype LOOP = K2<(A, D), (B, D)>
static func loop(_ : LOOP) -> Self
}
diff --git a/Swiftz/Bifunctor.swift b/Swiftz/Bifunctor.swift
index cd2eb69..1ff093c 100644
--- a/Swiftz/Bifunctor.swift
+++ b/Swiftz/Bifunctor.swift
@@ -11,14 +11,14 @@
/// FIXME: Something in swiftc doesn't like it when conforming instances use a generic in
/// definitions of rightMap. It has been removed in all instances for now.
public protocol Bifunctor {
- typealias L
- typealias B
- typealias R
- typealias D
- typealias PAC = K2
- typealias PAD = K2
- typealias PBC = K2
- typealias PBD = K2
+ associatedtype L
+ associatedtype B
+ associatedtype R
+ associatedtype D
+ associatedtype PAC = K2
+ associatedtype PAD = K2
+ associatedtype PBC = K2
+ associatedtype PBD = K2
/// Map two functions individually over both sides of the bifunctor at the same time.
func bimap(f : L -> B, _ g : R -> D) -> PBD
diff --git a/Swiftz/Category.swift b/Swiftz/Category.swift
index 438f87b..0c3ad5a 100644
--- a/Swiftz/Category.swift
+++ b/Swiftz/Category.swift
@@ -16,18 +16,18 @@
/// function is also called >>>.
public protocol Category {
/// Source
- typealias A
+ associatedtype A
/// Target
- typealias B
+ associatedtype B
/// Other Target; Usually Any.
- typealias C
+ associatedtype C
/// The identity category
- typealias CAA = K2
+ associatedtype CAA = K2
/// A Category we can compose with.
- typealias CBC = K2
+ associatedtype CBC = K2
/// The composition of this Category with the Category above.
- typealias CAC = K2
+ associatedtype CAC = K2
/// The identity morphism.
static func id() -> CAA
diff --git a/Swiftz/Comonad.swift b/Swiftz/Comonad.swift
index 40b20e3..ad685ed 100644
--- a/Swiftz/Comonad.swift
+++ b/Swiftz/Comonad.swift
@@ -10,7 +10,7 @@
///
/// "A comonoid in the monoidal category of endofunctors"
public protocol Comonad : Copointed, Functor {
- typealias FFA = K1
+ associatedtype FFA = K1
/// Duplicates the surrounding comonadic context and embeds the receiver in it.
func duplicate() -> FFA
diff --git a/Swiftz/Copointed.swift b/Swiftz/Copointed.swift
index de56310..1c81688 100644
--- a/Swiftz/Copointed.swift
+++ b/Swiftz/Copointed.swift
@@ -8,6 +8,6 @@
/// Functors equipped with a copoint that yields a value.
public protocol Copointed {
- typealias A
+ associatedtype A
func extract() -> A
}
diff --git a/Swiftz/Foldable.swift b/Swiftz/Foldable.swift
index 8251524..53ba3eb 100644
--- a/Swiftz/Foldable.swift
+++ b/Swiftz/Foldable.swift
@@ -8,8 +8,8 @@
/// A `Foldable` type admits a way of "summarizing" its entire structure.
public protocol Foldable {
- typealias A
- typealias B
+ associatedtype A
+ associatedtype B
/// Summarizes the receiver right-associatively.
func foldr(folder : A -> B -> B, _ initial : B) -> B
diff --git a/Swiftz/Functor.swift b/Swiftz/Functor.swift
index 8d0b8c8..ead9c19 100644
--- a/Swiftz/Functor.swift
+++ b/Swiftz/Functor.swift
@@ -10,11 +10,11 @@
/// in another set.
public protocol Functor {
/// Source
- typealias A
+ associatedtype A
/// Target
- typealias B
+ associatedtype B
/// A Target Functor
- typealias FB = K1
+ associatedtype FB = K1
/// Map a function over the value encapsulated by the Functor.
func fmap(f : A -> B) -> FB
diff --git a/Swiftz/HList.swift b/Swiftz/HList.swift
index 10539ac..3c16598 100644
--- a/Swiftz/HList.swift
+++ b/Swiftz/HList.swift
@@ -14,8 +14,8 @@
/// element, and compatible operations on said elements exist fully at compile time. HLists, like
/// regular lists, support folds, maps, and appends, only at the type rather than term level.
public protocol HList {
- typealias Head
- typealias Tail
+ associatedtype Head
+ associatedtype Tail
static var isNil : Bool { get }
static var length : Int { get }
diff --git a/Swiftz/List.swift b/Swiftz/List.swift
index 9427f41..7e871f3 100644
--- a/Swiftz/List.swift
+++ b/Swiftz/List.swift
@@ -395,7 +395,7 @@ public struct List {
///
/// For infinite lists this function will diverge.
public func reverse() -> List {
- return self.reduce(flip(List.cons), initial: [])
+ return self.reduce(flip(curry(List.cons)), initial: [])
}
/// Given a predicate, searches the list until it find the first match, and returns that,
diff --git a/Swiftz/Monad.swift b/Swiftz/Monad.swift
index 7d3ba7f..bed2b01 100644
--- a/Swiftz/Monad.swift
+++ b/Swiftz/Monad.swift
@@ -14,10 +14,10 @@ public protocol Monad : Applicative {
}
public protocol MonadOps : Monad {
- typealias C
- typealias FC = K1
- typealias D
- typealias FD = K1
+ associatedtype C
+ associatedtype FC = K1
+ associatedtype D
+ associatedtype FD = K1
/// Lift a function to a Monadic action.
static func liftM(f : A -> B) -> Self -> FB
@@ -35,12 +35,12 @@ public protocol MonadOps : Monad {
/// Monads that allow zipping.
public protocol MonadZip : Monad {
/// An arbitrary domain. Usually Any.
- typealias C
+ associatedtype C
/// A monad with an arbitrary domain.
- typealias FC = K1
+ associatedtype FC = K1
/// A Monad containing a zipped tuple.
- typealias FTAB = K1<(A, B)>
+ associatedtype FTAB = K1<(A, B)>
/// Zip for monads.
func mzip(_ : FB) -> FTAB
diff --git a/Swiftz/Pointed.swift b/Swiftz/Pointed.swift
index f59b7c6..9902bf4 100644
--- a/Swiftz/Pointed.swift
+++ b/Swiftz/Pointed.swift
@@ -8,6 +8,6 @@
/// Functors equipped with a point taking values to instances of themselves.
public protocol Pointed {
- typealias A
+ associatedtype A
static func pure(_ : A) -> Self
}
diff --git a/Swiftz/StringExt.swift b/Swiftz/StringExt.swift
index b1c8c01..84f4145 100644
--- a/Swiftz/StringExt.swift
+++ b/Swiftz/StringExt.swift
@@ -57,7 +57,7 @@ extension String {
/// Returns a string containing the characters of the receiver in reverse order.
public func reverse() -> String {
- return self.reduce(flip(String.cons), initial: "")
+ return self.reduce(flip(curry(String.cons)), initial: "")
}
/// Maps a function over the characters of a string and returns a new string of those values.
diff --git a/Swiftz/TupleExt.swift b/Swiftz/TupleExt.swift
index 2225ed9..4fcf085 100644
--- a/Swiftz/TupleExt.swift
+++ b/Swiftz/TupleExt.swift
@@ -26,55 +26,3 @@ public func ==(lhs: (), rhs: ()) -> Bool {
}
public func !=(lhs: (), rhs: ()) -> Bool { return false }
-
-// Unlike Python a 1-tuple is just it's contained element.
-
-public func == (lhs: (T,U), rhs: (T,U)) -> Bool {
- let (l0,l1) = lhs
- let (r0,r1) = rhs
- return l0 == r0 && l1 == r1
-}
-
-public func != (lhs: (T,U), rhs: (T,U)) -> Bool {
- return !(lhs==rhs)
-}
-
-public func == (lhs: (T,U,V), rhs: (T,U,V)) -> Bool {
- let (l0,l1,l2) = lhs
- let (r0,r1,r2) = rhs
- return l0 == r0 && l1 == r1 && l2 == r2
-}
-
-public func != (lhs: (T,U,V), rhs: (T,U,V)) -> Bool {
- return !(lhs==rhs)
-}
-
-public func == (lhs: (T,U,V,W), rhs: (T,U,V,W)) -> Bool {
- let (l0,l1,l2,l3) = lhs
- let (r0,r1,r2,r3) = rhs
- return l0 == r0 && l1 == r1 && l2 == r2 && l3 == r3
-}
-
-public func != (lhs: (T,U,V,W), rhs: (T,U,V,W)) -> Bool {
- return !(lhs==rhs)
-}
-
-public func == (lhs: (T,U,V,W,X), rhs: (T,U,V,W,X)) -> Bool {
- let (l0,l1,l2,l3,l4) = lhs
- let (r0,r1,r2,r3,r4) = rhs
- return l0 == r0 && l1 == r1 && l2 == r2 && l3 == r3 && l4 == r4
-}
-
-public func != (lhs: (T,U,V,W,X), rhs: (T,U,V,W,X)) -> Bool {
- return !(lhs==rhs)
-}
-
-public func == (lhs: (T,U,V,W,X,Z), rhs: (T,U,V,W,X,Z)) -> Bool {
- let (l0,l1,l2,l3,l4,l5) = lhs
- let (r0,r1,r2,r3,r4,r5) = rhs
- return l0 == r0 && l1 == r1 && l2 == r2 && l3 == r3 && l4 == r4 && l5 == r5
-}
-
-public func != (lhs: (T,U,V,W,X,Z), rhs: (T,U,V,W,X,Z)) -> Bool {
- return !(lhs==rhs)
-}
diff --git a/Swiftz/Writer.swift b/Swiftz/Writer.swift
index 26e0ab2..f2ecc0c 100644
--- a/Swiftz/Writer.swift
+++ b/Swiftz/Writer.swift
@@ -20,7 +20,8 @@ public struct Writer {
/// Returns a `Writer` that applies the function to its current value and environment.
public func mapWriter(f : (T, W) -> (U, V)) -> Writer {
- return Writer(f(self.runWriter))
+ let (t, w) = self.runWriter
+ return Writer(f(t, w))
}
/// Extracts the current environment from the receiver.
diff --git a/SwiftzTests/IdentitySpec.swift b/SwiftzTests/IdentitySpec.swift
index ff41811..de76a77 100644
--- a/SwiftzTests/IdentitySpec.swift
+++ b/SwiftzTests/IdentitySpec.swift
@@ -19,7 +19,7 @@ extension Identity where T : Arbitrary {
extension Identity : WitnessedArbitrary {
public typealias Param = T
- public static func forAllWitnessed(wit : A -> T)(pf : (Identity -> Testable)) -> Property {
+ public static func forAllWitnessed(wit : A -> T, pf : (Identity -> Testable)) -> Property {
return forAllShrink(Identity.arbitrary, shrinker: const([]), f: { bl in
return pf(bl.fmap(wit))
})
diff --git a/SwiftzTests/ListSpec.swift b/SwiftzTests/ListSpec.swift
index fd5c740..45adcdc 100644
--- a/SwiftzTests/ListSpec.swift
+++ b/SwiftzTests/ListSpec.swift
@@ -24,7 +24,7 @@ extension List where Element : Arbitrary {
extension List : WitnessedArbitrary {
public typealias Param = Element
- public static func forAllWitnessed(wit : A -> Element)(pf : (List -> Testable)) -> Property {
+ public static func forAllWitnessed(wit : A -> Element, pf : (List -> Testable)) -> Property {
return forAllShrink(List.arbitrary, shrinker: List.shrink, f: { bl in
return pf(bl.map(wit))
})
diff --git a/SwiftzTests/NonEmptyListSpec.swift b/SwiftzTests/NonEmptyListSpec.swift
index 71ded77..152cb0e 100644
--- a/SwiftzTests/NonEmptyListSpec.swift
+++ b/SwiftzTests/NonEmptyListSpec.swift
@@ -12,7 +12,7 @@ import SwiftCheck
extension NonEmptyList where Element : Arbitrary {
public static var arbitrary : Gen> {
- return [Element].arbitrary.suchThat({ !$0.isEmpty }).fmap { NonEmptyList(List(fromArray: $0))! }
+ return [Element].arbitrary.suchThat({ !$0.isEmpty }).map { NonEmptyList(List(fromArray: $0))! }
}
public static func shrink(xs : NonEmptyList) -> [NonEmptyList] {
@@ -25,7 +25,7 @@ extension NonEmptyList where Element : Arbitrary {
extension NonEmptyList : WitnessedArbitrary {
public typealias Param = Element
- public static func forAllWitnessed(wit : A -> Element)(pf : (NonEmptyList -> Testable)) -> Property {
+ public static func forAllWitnessed(wit : A -> Element, pf : (NonEmptyList -> Testable)) -> Property {
return forAllShrink(NonEmptyList.arbitrary, shrinker: NonEmptyList.shrink, f: { bl in
return pf(bl.fmap(wit))
})
diff --git a/SwiftzTests/WriterSpec.swift b/SwiftzTests/WriterSpec.swift
index 65d5fe8..26ca1b9 100644
--- a/SwiftzTests/WriterSpec.swift
+++ b/SwiftzTests/WriterSpec.swift
@@ -24,7 +24,7 @@ extension Writer where T : Arbitrary {
extension Writer : WitnessedArbitrary {
public typealias Param = T
- public static func forAllWitnessed(wit : A -> T)(pf : (Writer -> Testable)) -> Property {
+ public static func forAllWitnessed(wit : A -> T, pf : (Writer -> Testable)) -> Property {
return forAllShrink(Writer.arbitrary, shrinker: Writer.shrink, f: { bl in
return pf(bl.fmap(wit))
})