Swiftz
Swiftz is a Swift library for functional programming.
It defines functional data structures, functions, idioms, and extensions that augment
the Swift standard library.
For a small, simpler way to introduce functional primitives into any codebase,
see Swiftx.
Introduction
Swiftz draws inspiration from a number of functional libraries
and languages. Chief among them are Scalaz,
Prelude/Base, SML
Basis, and the OCaml Standard
Library. Elements of
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 that
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.
To illustrate use of these abstractions, take these few examples:
Lists
Semigroups and Monoids
Arrows
Operators
See Operators for a list of supported operators.
Setup
To add Swiftz to your application:
Using Carthage
- Add Swiftz to your Cartfile
- Run
carthage update
- Drag the relevant copy of Swiftz into your project.
- Expand the Link Binary With Libraries phase
- Click the + and add Swiftz
- Click the + at the top left corner to add a Copy Files build phase
- Set the directory to
Frameworks
- Click the + and add Swiftz
Using Git Submodules
- Clone Swiftz as a submodule into the directory of your choice
- Run
git submodule init -i --recursive
- Drag
Swiftz.xcodeproj
orSwiftz-iOS.xcodeproj
into your project tree as a subproject - Under your project's Build Phases, expand Target Dependencies
- Click the + and add Swiftz
- Expand the Link Binary With Libraries phase
- Click the + and add Swiftz
- Click the + at the top left corner to add a Copy Files build phase
- Set the directory to
Frameworks
- Click the + and add Swiftz
Using Swift Package Manager
- Add Swiftz to your
Package.swift
within your project'sPackage
definition:
System Requirements
Swiftz supports OS X 10.9+ and iOS 8.0+.
License
Swiftz is released under the BSD license.