Skip to content

Commit

Permalink
Merge pull request #298 from CodaFi/into-the-wild-blue-yonder
Browse files Browse the repository at this point in the history
Update to Swift 2.2
  • Loading branch information
CodaFi committed Mar 23, 2016
2 parents b556b74 + 2cfbc2f commit 78665a0
Show file tree
Hide file tree
Showing 25 changed files with 70 additions and 121 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
language: objective-c
osx_image: xcode7.2
osx_image: xcode7.3
env:
- TEST_CONFIG="RELEASE"
- TEST_CONFIG="PODS"

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
Expand Down
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/Operadics
Submodule Operadics updated 1 files
+4 −0 Package.swift
2 changes: 1 addition & 1 deletion Carthage/Checkouts/SwiftCheck
Submodule SwiftCheck updated 47 files
+25 −0 .github/CONTRIBUTING.md
+35 −0 .github/ISSUE_TEMPLATE.md
+24 −0 .github/PULL_REQUEST_TEMPLATE.md
+38 −11 .travis.yml
+11 −0 Package.swift
+2 −2 README.md
+90 −44 Sources/Arbitrary.swift
+38 −24 Sources/Check.swift
+34 −11 Sources/CoArbitrary.swift
+177 −166 Sources/Gen.swift
+0 −0 Sources/Info.plist
+20 −7 Sources/Lattice.swift
+101 −31 Sources/Modifiers.swift
+246 −0 Sources/Operators.swift
+154 −129 Sources/Property.swift
+69 −30 Sources/Random.swift
+60 −56 Sources/Rose.swift
+28 −14 Sources/State.swift
+0 −0 Sources/SwiftCheck.h
+354 −294 Sources/Test.swift
+28 −19 Sources/TestOperators.swift
+19 −10 Sources/Testable.swift
+34 −26 Sources/Witness.swift
+20 −40 Sources/WitnessedArbitrary.swift
+2 −2 SwiftCheck.podspec
+274 −249 SwiftCheck.xcodeproj/project.pbxproj
+6 −6 SwiftCheck.xcodeproj/xcshareddata/xcschemes/SwiftCheck-iOS.xcscheme
+0 −43 SwiftCheck/Equatable.swift
+0 −52 SwiftCheckTests/PropertySpec.swift
+1 −0 Tests/BooleanIdentitySpec.swift
+18 −23 Tests/ComplexSpec.swift
+1 −0 Tests/DiscardSpec.swift
+2 −1 Tests/FailureSpec.swift
+13 −6 Tests/GenSpec.swift
+0 −0 Tests/Info.plist
+192 −0 Tests/LambdaSpec.swift
+1 −0 Tests/ModifierSpec.swift
+101 −0 Tests/PathSpec.swift
+153 −0 Tests/PropertySpec.swift
+1 −0 Tests/ReplaySpec.swift
+63 −0 Tests/RoseSpec.swift
+1 −0 Tests/ShrinkSpec.swift
+20 −0 Tests/SimpleSpec.swift
+2 −1 Tests/TestSpec.swift
+81 −76 Tutorial.playground/Contents.swift
+0 −6 Tutorial.playground/timeline.xctimeline
+2 −2 script/cibuild
2 changes: 1 addition & 1 deletion Swiftz.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions Swiftz/Applicative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
/// 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<A -> B>
associatedtype FAB = K1<A -> B>

/// Applies the function encapsulated by the Functor to the value encapsulated by the receiver.
func ap(f : FAB) -> FB
}

/// Additional functions to be implemented by those types conforming to the Applicative protocol.
public protocol ApplicativeOps : Applicative {
typealias C
typealias FC = K1<C>
typealias D
typealias FD = K1<D>
associatedtype C
associatedtype FC = K1<C>
associatedtype D
associatedtype FD = K1<D>

/// Lift a function to a Functorial action.
static func liftA(f : A -> B) -> Self -> FB
Expand Down
32 changes: 16 additions & 16 deletions Swiftz/Arrow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<D, E>
associatedtype ADE = K2<D, E>
/// 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<A, D>
associatedtype ABD = K2<A, D>

/// Type of the result of &&&.
typealias FANOUT = K2<B, (B, D)>
associatedtype FANOUT = K2<B, (B, D)>

/// Lift a function to an arrow.
static func arr(_ : A -> B) -> Self
Expand Down Expand Up @@ -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<A, B>
associatedtype ABC = K2<A, B>

/// The identity arrow.
static func zeroArrow() -> ABC
Expand Down Expand Up @@ -132,17 +132,17 @@ public protocol ArrowPlus : ArrowZero {
///
public protocol ArrowChoice : Arrow {
/// The result of left
typealias LEFT = K2<Either<A, D>, Either<B, D>>
associatedtype LEFT = K2<Either<A, D>, Either<B, D>>
/// The result of right
typealias RIGHT = K2<Either<D, A>, Either<D, B>>
associatedtype RIGHT = K2<Either<D, A>, Either<D, B>>

/// The result of +++
typealias SPLAT = K2<Either<A, D>, Either<B, E>>
associatedtype SPLAT = K2<Either<A, D>, Either<B, E>>

/// Some arrow from a different source and target for fanin.
typealias ACD = K2<B, D>
associatedtype ACD = K2<B, D>
/// The result of |||
typealias FANIN = K2<Either<A, B>, D>
associatedtype FANIN = K2<Either<A, B>, D>

/// Feed marked inputs through the argument arrow, passing the rest through unchanged to the
/// output.
Expand All @@ -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
}

Expand All @@ -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
}
16 changes: 8 additions & 8 deletions Swiftz/Bifunctor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
/// FIXME: Something in swiftc doesn't like it when conforming instances use a generic <D> 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<L, R>
typealias PAD = K2<L, D>
typealias PBC = K2<B, R>
typealias PBD = K2<B, D>
associatedtype L
associatedtype B
associatedtype R
associatedtype D
associatedtype PAC = K2<L, R>
associatedtype PAD = K2<L, D>
associatedtype PBC = K2<B, R>
associatedtype PBD = K2<B, D>

/// Map two functions individually over both sides of the bifunctor at the same time.
func bimap(f : L -> B, _ g : R -> D) -> PBD
Expand Down
12 changes: 6 additions & 6 deletions Swiftz/Category.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<A, A>
associatedtype CAA = K2<A, A>
/// A Category we can compose with.
typealias CBC = K2<B, C>
associatedtype CBC = K2<B, C>
/// The composition of this Category with the Category above.
typealias CAC = K2<A, C>
associatedtype CAC = K2<A, C>

/// The identity morphism.
static func id() -> CAA
Expand Down
2 changes: 1 addition & 1 deletion Swiftz/Comonad.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
///
/// "A comonoid in the monoidal category of endofunctors"
public protocol Comonad : Copointed, Functor {
typealias FFA = K1<Self>
associatedtype FFA = K1<Self>

/// Duplicates the surrounding comonadic context and embeds the receiver in it.
func duplicate() -> FFA
Expand Down
2 changes: 1 addition & 1 deletion Swiftz/Copointed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

/// Functors equipped with a copoint that yields a value.
public protocol Copointed {
typealias A
associatedtype A
func extract() -> A
}
4 changes: 2 additions & 2 deletions Swiftz/Foldable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Swiftz/Functor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<B>
associatedtype FB = K1<B>

/// Map a function over the value encapsulated by the Functor.
func fmap(f : A -> B) -> FB
Expand Down
4 changes: 2 additions & 2 deletions Swiftz/HList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion Swiftz/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public struct List<Element> {
///
/// For infinite lists this function will diverge.
public func reverse() -> List<Element> {
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,
Expand Down
14 changes: 7 additions & 7 deletions Swiftz/Monad.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public protocol Monad : Applicative {
}

public protocol MonadOps : Monad {
typealias C
typealias FC = K1<C>
typealias D
typealias FD = K1<D>
associatedtype C
associatedtype FC = K1<C>
associatedtype D
associatedtype FD = K1<D>

/// Lift a function to a Monadic action.
static func liftM(f : A -> B) -> Self -> FB
Expand All @@ -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<C>
associatedtype FC = K1<C>

/// A Monad containing a zipped tuple.
typealias FTAB = K1<(A, B)>
associatedtype FTAB = K1<(A, B)>

/// Zip for monads.
func mzip(_ : FB) -> FTAB
Expand Down
2 changes: 1 addition & 1 deletion Swiftz/Pointed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion Swiftz/StringExt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
52 changes: 0 additions & 52 deletions Swiftz/TupleExt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 == <T:Equatable,U:Equatable>(lhs: (T,U), rhs: (T,U)) -> Bool {
let (l0,l1) = lhs
let (r0,r1) = rhs
return l0 == r0 && l1 == r1
}

public func != <T:Equatable,U:Equatable>(lhs: (T,U), rhs: (T,U)) -> Bool {
return !(lhs==rhs)
}

public func == <T:Equatable,U:Equatable,V:Equatable>(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 != <T:Equatable,U:Equatable,V:Equatable>(lhs: (T,U,V), rhs: (T,U,V)) -> Bool {
return !(lhs==rhs)
}

public func == <T:Equatable,U:Equatable,V:Equatable,W:Equatable>(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 != <T:Equatable,U:Equatable,V:Equatable,W:Equatable>(lhs: (T,U,V,W), rhs: (T,U,V,W)) -> Bool {
return !(lhs==rhs)
}

public func == <T:Equatable,U:Equatable,V:Equatable,W:Equatable,X:Equatable>(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 != <T:Equatable,U:Equatable,V:Equatable,W:Equatable,X:Equatable>(lhs: (T,U,V,W,X), rhs: (T,U,V,W,X)) -> Bool {
return !(lhs==rhs)
}

public func == <T:Equatable,U:Equatable,V:Equatable,W:Equatable,X:Equatable,Z:Equatable>(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 != <T:Equatable,U:Equatable,V:Equatable,W:Equatable,X:Equatable,Z:Equatable>(lhs: (T,U,V,W,X,Z), rhs: (T,U,V,W,X,Z)) -> Bool {
return !(lhs==rhs)
}
3 changes: 2 additions & 1 deletion Swiftz/Writer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public struct Writer<W : Monoid, T> {

/// Returns a `Writer` that applies the function to its current value and environment.
public func mapWriter<U, V : Monoid>(f : (T, W) -> (U, V)) -> Writer<V, U> {
return Writer<V, U>(f(self.runWriter))
let (t, w) = self.runWriter
return Writer<V, U>(f(t, w))
}

/// Extracts the current environment from the receiver.
Expand Down
2 changes: 1 addition & 1 deletion SwiftzTests/IdentitySpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension Identity where T : Arbitrary {
extension Identity : WitnessedArbitrary {
public typealias Param = T

public static func forAllWitnessed<A : Arbitrary>(wit : A -> T)(pf : (Identity<T> -> Testable)) -> Property {
public static func forAllWitnessed<A : Arbitrary>(wit : A -> T, pf : (Identity<T> -> Testable)) -> Property {
return forAllShrink(Identity<A>.arbitrary, shrinker: const([]), f: { bl in
return pf(bl.fmap(wit))
})
Expand Down
2 changes: 1 addition & 1 deletion SwiftzTests/ListSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension List where Element : Arbitrary {
extension List : WitnessedArbitrary {
public typealias Param = Element

public static func forAllWitnessed<A : Arbitrary>(wit : A -> Element)(pf : (List<Element> -> Testable)) -> Property {
public static func forAllWitnessed<A : Arbitrary>(wit : A -> Element, pf : (List<Element> -> Testable)) -> Property {
return forAllShrink(List<A>.arbitrary, shrinker: List<A>.shrink, f: { bl in
return pf(bl.map(wit))
})
Expand Down
Loading

0 comments on commit 78665a0

Please sign in to comment.