Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,12 @@ jobs:
fail-fast: false
matrix:
image:
- swift:5.1-xenial
- swift:5.1-bionic
- swift:5.2-xenial
- swift:5.2-bionic
- swift:5.2-focal
- swift:5.2-centos8
- swift:5.2-amazonlinux2
- swift:5.3-xenial
- swift:5.3-bionic
- swift:5.3-focal
- swift:5.3-centos8
- swift:5.3-amazonlinux2
- swift:5.4-focal
- swift:5.5-focal
- swift:5.6-focal
- swift:5.7-jammy
- swift:6.0
- swift:6.1
container: ${{ matrix.image }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v5
- name: Run tests
run: swift test --enable-test-discovery
osx:
Expand All @@ -42,6 +28,6 @@ jobs:
uses: maxim-lobanov/setup-xcode@v1
with: { 'xcode-version': 'latest' }
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v5
- name: Run tests
run: swift test --enable-test-discovery
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// swift-tools-version:5.0
// swift-tools-version:6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Poly",
platforms: [.macOS(.v10_10),
.iOS(.v10)],
platforms: [.macOS(.v10_15),
.iOS(.v13)],
products: [
.library(
name: "Poly",
Expand All @@ -21,5 +21,5 @@ let package = Package(
name: "PolyTests",
dependencies: ["Poly"]),
],
swiftLanguageVersions: [.v4_2, .v5]
swiftLanguageModes: [.v5, .v6]
)
138 changes: 0 additions & 138 deletions Poly.podspec

This file was deleted.

16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
# Poly
[![MIT license](http://img.shields.io/badge/license-MIT-lightgrey.svg)](http://opensource.org/licenses/MIT) [![Swift 4.2](http://img.shields.io/badge/Swift-4.2-blue.svg)](https://swift.org) [![Swift 5.0-5.3](http://img.shields.io/badge/Swift-5.x-blue.svg)](https://swift.org) [![Build Status](https://app.bitrise.io/app/e46602b5a7b267d7/status.svg?token=u4El0Z-Ew_9QrR-Fk7Byug&branch=main)](https://app.bitrise.io/app/e46602b5a7b267d7)
[![MIT license](http://img.shields.io/badge/license-MIT-lightgrey.svg)](http://opensource.org/licenses/MIT) [![Swift 6.0+](http://img.shields.io/badge/Swift-6.x-blue.svg)](https://swift.org)

Poly is a small library to provide an alternative to rolling your own type-erasure when a value has one of a small set of Types. The Poly library contains the Types `Poly1`, `Poly2`, `Poly3`, etc. for representing increasingly larger pools of possible Types. `Poly2` is isomorphic to `Either` (a common generic functional programming Type).

## Dev Environment
### Prerequisites
1. Swift 4.2+
2. Swift Package Manager 5.0 *OR* Cocoapods

### CocoaPods
To use this framework in your project via Cocoapods instead of Swift Package Manager, add the following dependency to your Podfile.
```
pod 'Poly', :git => 'https://github.com/mattpolzin/Poly.git'
```

### Xcode project
To create an Xcode project for Poly, run
`swift package generate-xcodeproj`
1. Swift 6.0+
2. Swift Package Manager

## Usage

Expand Down
17 changes: 16 additions & 1 deletion Sources/Poly/Poly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public struct Poly0: _Poly0 {
public var value: Any { return () }
}

extension Poly0: Equatable, Hashable {}
extension Poly0: Equatable, Hashable, Sendable {}

// MARK: - 1 type
public protocol _Poly1: _Poly0 {
Expand Down Expand Up @@ -99,6 +99,7 @@ public enum Poly1<A>: _Poly1 {

extension Poly1: Equatable where A: Equatable {}
extension Poly1: Hashable where A: Hashable {}
extension Poly1: Sendable where A: Sendable {}

// MARK: - 2 types
public protocol _Poly2: _Poly1 {
Expand Down Expand Up @@ -152,6 +153,7 @@ public enum Poly2<A, B>: _Poly2 {

extension Poly2: Equatable where A: Equatable, B: Equatable {}
extension Poly2: Hashable where A: Hashable, B: Hashable {}
extension Poly2: Sendable where A: Sendable, B: Sendable {}

// MARK: - 3 types
public protocol _Poly3: _Poly2 {
Expand Down Expand Up @@ -213,6 +215,7 @@ public enum Poly3<A, B, C>: _Poly3 {

extension Poly3: Equatable where A: Equatable, B: Equatable, C: Equatable {}
extension Poly3: Hashable where A: Hashable, B: Hashable, C: Hashable {}
extension Poly3: Sendable where A: Sendable, B: Sendable, C: Sendable {}

// MARK: - 4 types
public protocol _Poly4: _Poly3 {
Expand Down Expand Up @@ -285,6 +288,7 @@ public enum Poly4<A, B, C, D>: _Poly4 {

extension Poly4: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable {}
extension Poly4: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable {}
extension Poly4: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable {}

// MARK: - 5 types
public protocol _Poly5: _Poly4 {
Expand Down Expand Up @@ -368,6 +372,7 @@ public enum Poly5<A, B, C, D, E>: _Poly5 {

extension Poly5: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable {}
extension Poly5: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable {}
extension Poly5: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable {}

// MARK: - 6 types
public protocol _Poly6: _Poly5 {
Expand Down Expand Up @@ -462,6 +467,7 @@ public enum Poly6<A, B, C, D, E, F>: _Poly6 {

extension Poly6: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable, F: Equatable {}
extension Poly6: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable, F: Hashable {}
extension Poly6: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable, F: Sendable {}

// MARK: - 7 types
public protocol _Poly7: _Poly6 {
Expand Down Expand Up @@ -567,6 +573,7 @@ public enum Poly7<A, B, C, D, E, F, G>: _Poly7 {

extension Poly7: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable, F: Equatable, G: Equatable {}
extension Poly7: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable, F: Hashable, G: Hashable {}
extension Poly7: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable, F: Sendable, G: Sendable {}

// MARK: - 8 types
public protocol _Poly8: _Poly7 {
Expand Down Expand Up @@ -683,6 +690,7 @@ public enum Poly8<A, B, C, D, E, F, G, H>: _Poly8 {

extension Poly8: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable, F: Equatable, G: Equatable, H: Equatable {}
extension Poly8: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable, F: Hashable, G: Hashable, H: Hashable {}
extension Poly8: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable, F: Sendable, G: Sendable, H: Sendable {}

// MARK: - 9 types
public protocol _Poly9: _Poly8 {
Expand Down Expand Up @@ -810,6 +818,7 @@ public enum Poly9<A, B, C, D, E, F, G, H, I>: _Poly9 {

extension Poly9: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable, F: Equatable, G: Equatable, H: Equatable, I: Equatable {}
extension Poly9: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable, F: Hashable, G: Hashable, H: Hashable, I: Hashable {}
extension Poly9: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable, F: Sendable, G: Sendable, H: Sendable, I: Sendable {}

// MARK: - 10 types
public protocol _Poly10: _Poly9 {
Expand Down Expand Up @@ -948,6 +957,7 @@ public enum Poly10<A, B, C, D, E, F, G, H, I, J>: _Poly10 {

extension Poly10: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable, F: Equatable, G: Equatable, H: Equatable, I: Equatable, J: Equatable {}
extension Poly10: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable, F: Hashable, G: Hashable, H: Hashable, I: Hashable, J: Hashable {}
extension Poly10: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable, F: Sendable, G: Sendable, H: Sendable, I: Sendable, J: Sendable {}

// MARK: - 11 types
public protocol _Poly11: _Poly10 {
Expand Down Expand Up @@ -1097,6 +1107,7 @@ public enum Poly11<A, B, C, D, E, F, G, H, I, J, K>: _Poly11 {

extension Poly11: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable, F: Equatable, G: Equatable, H: Equatable, I: Equatable, J: Equatable, K: Equatable {}
extension Poly11: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable, F: Hashable, G: Hashable, H: Hashable, I: Hashable, J: Hashable, K: Hashable {}
extension Poly11: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable, F: Sendable, G: Sendable, H: Sendable, I: Sendable, J: Sendable, K: Sendable {}

// MARK: - 12 types
public protocol _Poly12: _Poly11 {
Expand Down Expand Up @@ -1257,6 +1268,7 @@ public enum Poly12<A, B, C, D, E, F, G, H, I, J, K, L>: _Poly12 {

extension Poly12: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable, F: Equatable, G: Equatable, H: Equatable, I: Equatable, J: Equatable, K: Equatable, L: Equatable {}
extension Poly12: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable, F: Hashable, G: Hashable, H: Hashable, I: Hashable, J: Hashable, K: Hashable, L: Hashable {}
extension Poly12: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable, F: Sendable, G: Sendable, H: Sendable, I: Sendable, J: Sendable, K: Sendable, L: Sendable {}

// MARK: - 13 types
public protocol _Poly13: _Poly12 {
Expand Down Expand Up @@ -1428,6 +1440,7 @@ public enum Poly13<A, B, C, D, E, F, G, H, I, J, K, L, M>: _Poly13 {

extension Poly13: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable, F: Equatable, G: Equatable, H: Equatable, I: Equatable, J: Equatable, K: Equatable, L: Equatable, M: Equatable {}
extension Poly13: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable, F: Hashable, G: Hashable, H: Hashable, I: Hashable, J: Hashable, K: Hashable, L: Hashable, M: Hashable {}
extension Poly13: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable, F: Sendable, G: Sendable, H: Sendable, I: Sendable, J: Sendable, K: Sendable, L: Sendable, M: Sendable {}

// MARK: - 14 types
public protocol _Poly14: _Poly13 {
Expand Down Expand Up @@ -1609,6 +1622,7 @@ public enum Poly14<A, B, C, D, E, F, G, H, I, J, K, L, M, N>: _Poly14 {

extension Poly14: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable, F: Equatable, G: Equatable, H: Equatable, I: Equatable, J: Equatable, K: Equatable, L: Equatable, M: Equatable, N: Equatable {}
extension Poly14: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable, F: Hashable, G: Hashable, H: Hashable, I: Hashable, J: Hashable, K: Hashable, L: Hashable, M: Hashable, N: Hashable {}
extension Poly14: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable, F: Sendable, G: Sendable, H: Sendable, I: Sendable, J: Sendable, K: Sendable, L: Sendable, M: Sendable, N: Sendable {}

// MARK: - 15 types
public protocol _Poly15: _Poly14 {
Expand Down Expand Up @@ -1801,3 +1815,4 @@ public enum Poly15<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>: _Poly15 {

extension Poly15: Equatable where A: Equatable, B: Equatable, C: Equatable, D: Equatable, E: Equatable, F: Equatable, G: Equatable, H: Equatable, I: Equatable, J: Equatable, K: Equatable, L: Equatable, M: Equatable, N: Equatable, O: Equatable {}
extension Poly15: Hashable where A: Hashable, B: Hashable, C: Hashable, D: Hashable, E: Hashable, F: Hashable, G: Hashable, H: Hashable, I: Hashable, J: Hashable, K: Hashable, L: Hashable, M: Hashable, N: Hashable, O: Hashable {}
extension Poly15: Sendable where A: Sendable, B: Sendable, C: Sendable, D: Sendable, E: Sendable, F: Sendable, G: Sendable, H: Sendable, I: Sendable, J: Sendable, K: Sendable, L: Sendable, M: Sendable, N: Sendable, O: Sendable {}