Skip to content

Commit

Permalink
Merge pull request #255 from CodaFi/forward-march
Browse files Browse the repository at this point in the history
Swift 2.0 Support
  • Loading branch information
CodaFi committed Sep 16, 2015
2 parents 2c173ef + c49be8b commit 2105329
Show file tree
Hide file tree
Showing 91 changed files with 4,338 additions and 3,089 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
*.xcscmblueprint
*.resolved
Carthage/Build
Carthage/Checkouts

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "Carthage/Checkouts/SwiftCheck"]
path = Carthage/Checkouts/SwiftCheck
url = https://github.com/typelift/SwiftCheck.git
[submodule "Carthage/Checkouts/Operadics"]
path = Carthage/Checkouts/Operadics
url = https://github.com/typelift/Operadics.git
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
language: objective-c
osx_image: beta-xcode6.3
osx_image: xcode7

install:
before_install:
- gem install xcpretty-travis-formatter --no-rdoc --no-ri --no-document --quiet

install:
- git submodule update -i --recursive

script:
- xctool -project Swiftz.xcodeproj -scheme Swiftz -sdk macosx ONLY_ACTIVE_ARCH=NO clean build test
- xctool -project Swiftz.xcodeproj -scheme Swiftz-iOS -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO clean build test

- set -o pipefail && xcodebuild -project Swiftz.xcodeproj -scheme Swiftz -sdk macosx ONLY_ACTIVE_ARCH=NO clean build test | xcpretty -c -f `xcpretty-travis-formatter`
- set -o pipefail && xcodebuild -project Swiftz.xcodeproj -scheme Swiftz-iOS -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO clean build test | xcpretty -c -f `xcpretty-travis-formatter`
2 changes: 2 additions & 0 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github "typelift/Swiftx"
github "typelift/SwiftCheck"
github "typelift/Operadics"

5 changes: 3 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
github "typelift/SwiftCheck" "v0.2.6"
github "typelift/Swiftx" "v0.2.1"
github "typelift/Operadics" "0.1.4"
github "typelift/SwiftCheck" "v0.3.1"
github "typelift/Swiftx" "v0.3.0"
1 change: 1 addition & 0 deletions Carthage/Checkouts/Operadics
Submodule Operadics added at c65e63
2 changes: 1 addition & 1 deletion Carthage/Checkouts/SwiftCheck
Submodule SwiftCheck updated 46 files
+5 −1 .gitignore
+3 −0 .gitmodules
+6 −4 .travis.yml
+1 −0 Cartfile.private
+1 −0 Cartfile.resolved
+1 −0 Carthage/Checkouts/Operadics
+21 −0 LICENSE
+62 −20 README.md
+39 −0 SwiftCheck.podspec
+82 −36 SwiftCheck.xcodeproj/project.pbxproj
+4 −1 SwiftCheck.xcodeproj/xcshareddata/xcschemes/SwiftCheck-iOS.xcscheme
+4 −1 SwiftCheck.xcodeproj/xcshareddata/xcschemes/SwiftCheck.xcscheme
+490 −104 SwiftCheck/Arbitrary.swift
+95 −30 SwiftCheck/Check.swift
+0 −73 SwiftCheck/Combinators.swift
+248 −70 SwiftCheck/Gen.swift
+1 −1 SwiftCheck/Info.plist
+21 −0 SwiftCheck/Lattice.swift
+225 −185 SwiftCheck/Modifiers.swift
+338 −263 SwiftCheck/Property.swift
+82 −58 SwiftCheck/Random.swift
+31 −20 SwiftCheck/Rose.swift
+60 −27 SwiftCheck/State.swift
+0 −10 SwiftCheck/SwiftCheck.h
+0 −122 SwiftCheck/SwiftCheck.playground/Contents.swift
+0 −3 SwiftCheck/SwiftCheck.playground/Sources/SupportCode.swift
+0 −4 SwiftCheck/SwiftCheck.playground/contents.xcplayground
+392 −298 SwiftCheck/Test.swift
+47 −9 SwiftCheck/TestOperators.swift
+32 −17 SwiftCheck/Testable.swift
+61 −0 SwiftCheck/Witness.swift
+10 −10 SwiftCheckTests/BooleanIdentitySpec.swift
+79 −0 SwiftCheckTests/ComplexSpec.swift
+12 −2 SwiftCheckTests/DiscardSpec.swift
+42 −34 SwiftCheckTests/GenSpec.swift
+1 −1 SwiftCheckTests/Info.plist
+19 −12 SwiftCheckTests/ModifierSpec.swift
+33 −0 SwiftCheckTests/PropertySpec.swift
+9 −9 SwiftCheckTests/ShrinkSpec.swift
+12 −21 SwiftCheckTests/SimpleSpec.swift
+54 −0 SwiftCheckTests/TestSpec.swift
+715 −0 Tutorial.playground/Contents.swift
+4 −0 Tutorial.playground/contents.xcplayground
+1 −1 Tutorial.playground/playground.xcworkspace/contents.xcworkspacedata
+0 −0 Tutorial.playground/timeline.xctimeline
+10 −0 Tutorial.xcworkspace/contents.xcworkspacedata
57 changes: 2 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ the library rely on their combinatorial semantics to allow declarative ideas to
be expressed more clearly in Swift.

Swiftz is a proper superset of [Swiftx](https://github.com/typelift/Swiftx) that
implements higher-level data types like Lenses, Zippers, HLists, and a number of
implements higher-level data types like Arrows, Lists, HLists, and a number of
typeclasses integral to programming with the maximum amount of support from the
type system.

Expand Down Expand Up @@ -112,11 +112,6 @@ public class User : JSONDecodable {
<*> x <? "tweets"
<*> x <? "attrs" <> "one" // A nested keypath
}

// lens example
public class func luserName() -> Lens<User, User, String, String> {
return Lens { user in IxStore(user.name) { User($0, user.age, user.tweets, user.attr) } }
}
}

public func ==(lhs : User, rhs : User) -> Bool {
Expand All @@ -129,55 +124,7 @@ let userjs = "{\"name\": \"max\", \"age\": 10, \"tweets\": [\"hello\"], \"attrs\
//: the user would be nil.
let user : User? = JSONValue.decode(userjs) >>- User.fromJSON // .Some( User("max", 10, ["hello"], "1") )
```

**Lenses**

```swift
import struct Swiftz.Lens
import struct Swiftz.IxStore

//: A party has a host, who is a user.
final class Party {
let host : User

init(h : User) {
host = h
}

class func lpartyHost() -> Lens<Party, Party, User, User> {
let getter = { (party : Party) -> User in
party.host
}

let setter = { (party : Party, host : User) -> Party in
Party(h: host)
}

return Lens(get: getter, set: setter)
}
}

//: A Lens for the User's name.
extension User {
public class func luserName() -> Lens<User, User, String, String> {
return Lens { user in IxStore(user.name) { User($0, user.age, user.tweets, user.attrs) } }
}
}

//: Let's throw a party now.
let party = Party(h: User("max", 1, [], Dictionary()))

//: A lens for a party host's name.
let hostnameLens = Party.lpartyHost() User.luserName()

//: Retrieve our gracious host's name.
let name = hostnameLens.get(party) // "max"

//: Our party seems to be lacking in proper nouns.
let updatedParty = (Party.lpartyHost() User.luserName()).set(party, "Max")
let properName = hostnameLens.get(updatedParty) // "Max"
```


**Semigroups and Monoids**

```swift
Expand Down
5 changes: 2 additions & 3 deletions Swiftz.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Swiftz"
s.version = "0.2.4"
s.version = "0.3.0"
s.summary = "Swiftz is a Swift library for functional programming."
s.homepage = "https://github.com/typelift/Swiftz"
s.license = { :type => "BSD" }
Expand All @@ -10,6 +10,5 @@ Pod::Spec.new do |s|
s.osx.deployment_target = "10.9"
s.ios.deployment_target = "8.0"
s.source = { :git => "https://github.com/typelift/Swiftz.git", :tag => "v#{s.version}", :submodules => true }
s.source_files = "Swiftz/*.swift", "**/Swiftx/*.swift"
s.exclude_files = "**/Swiftx/Operators.swift"
s.source_files = "Swiftz/*.swift", "**/Swiftx/*.swift", "**/Operadics/*.swift"
end
Loading

0 comments on commit 2105329

Please sign in to comment.