<commit_before>[![Build Status](https://travis-ci.org/typelift/swiftz.svg)](https://travis-ci.org/typelift/swiftz)

Swiftz
======

Swiftz is a Swift library for functional programming.

It defines purely functional data structure, functions, and extensions that augment the Swift standard library.

Setup
-----

Swiftz comes in two distinct flavors: Core and Full.  Swiftz_Core is
a smaller and simpler way to introduce pure functional datatypes into any
codebase.  It also provides a few of the more popular typeclasses and conformances
for Swiftz types.  It can be included one of two ways:

**Framework**

- Drag `swiftz_core.xcodeproj` into your project tree as a subproject
- Under your project's Build Phases, expand Target Dependencies
- Click the + and add swiftz_core
- Expand the Link Binary With Libraries phase
- Click the + and add swiftz_core
- Click the + at the top left corner to add a Copy Files build phase
- Set the directory to `Frameworks`
- Click the + and add swiftz_core

**Standalone**

- Copy the swift files under `swiftz/swiftz_core/swiftz_core` into your
  project.

Using the full Swiftz framework works in much the same way:

- Drag `swiftz.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 *and* swiftz_core

Examples
--------

**Data abstractions:**

```swift
let xs: [Int8] = [1, 2, 0, 3, 4]

// we can use the Min semigroup to find the minimal element in xs
sconcat(Min(), 2, xs) // 0

// we can use the Sum monoid to find the sum of xs
mconcat(Sum<Int8, NInt8>(i: { return nint8 }), xs) // 10
```

**Either and Result:**

```swift
// Result represents something that could work or be an NSError.
// Say we have 2 functions, the first fetches from a web services,
// the second decodes the string into a User.
// Both *could* fail with an NSError, so we use a Result<A>.<commit_msg>Update to reflect recent events<commit_after>[![Build Status](https://travis-ci.org/typelift/swiftz.svg)](https://travis-ci.org/typelift/swiftz)

Swiftz
======

Swiftz is a Swift library for functional programming.

It defines purely functional data structure, functions, and extensions that augment the Swift standard library.

Setup
-----

Swiftz comes in two distinct flavors: Core and Full.  Swiftz_Core is
a smaller and simpler way to introduce pure functional datatypes into any
codebase.  It can be included one of two ways:

**Framework**

- Drag `swiftz_core.xcodeproj` into your project tree as a subproject
- Under your project's Build Phases, expand Target Dependencies
- Click the + and add swiftz_core
- Expand the Link Binary With Libraries phase
- Click the + and add swiftz_core
- Click the + at the top left corner to add a Copy Files build phase
- Set the directory to `Frameworks`
- Click the + and add swiftz_core

**Standalone**

- Copy the swift files under `swiftz/swiftz_core/swiftz_core` into your
  project.

Using the full Swiftz framework works in much the same way:

- Drag `swiftz.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

Examples
--------

**Data abstractions:**

```swift
let xs: [Int8] = [1, 2, 0, 3, 4]

// we can use the Min semigroup to find the minimal element in xs
sconcat(Min(), 2, xs) // 0

// we can use the Sum monoid to find the sum of xs
mconcat(Sum<Int8, NInt8>(i: { return nint8 }), xs) // 10
```

**Either and Result:**

```swift
// Result represents something that could work or be an NSError.
// Say we have 2 functions, the first fetches from a web services,
// the second decodes the string into a User.
// Both *could* fail with an NSError, so we use a Result<A>.
{'fraction_non_alphanumeric': 0.0869669959046013, 'fraction_numerical': 0.006745362563237774, 'mean_word_length': 3.783410138248848, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '392440', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1218, 'n_words': 598}