[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6984":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":16,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":19,"hasPages":19,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":16,"starSnapshotCount":16,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},6984,"Swiftz","typelift\u002FSwiftz","typelift","Functional programming in Swift","",null,"Swift",3320,229,125,9,0,59.09,"BSD 3-Clause \"New\" or \"Revised\" License",false,"master",[22,23],"functional-programming","swift","2026-06-12 04:00:31","[![Carthage compatible](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FCarthage-compatible-4BC51D.svg?style=flat)](https:\u002F\u002Fgithub.com\u002FCarthage\u002FCarthage)\n[![Build Status](https:\u002F\u002Ftravis-ci.org\u002Ftypelift\u002FSwiftz.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002Ftypelift\u002FSwiftz)\n[![Gitter chat](https:\u002F\u002Fbadges.gitter.im\u002FDPVN\u002Fchat.png)](https:\u002F\u002Fgitter.im\u002Ftypelift\u002Fgeneral?utm_source=share-link&utm_medium=link&utm_campaign=share-link)\n \nSwiftz\n======\n\nSwiftz is a Swift library for functional programming.\n\nIt defines functional data structures, functions, idioms, and extensions that augment \nthe Swift standard library.\n\nFor a small, simpler way to introduce functional primitives into any codebase,\nsee [Swiftx](https:\u002F\u002Fgithub.com\u002Ftypelift\u002FSwiftx). \n\nIntroduction\n------------\n\nSwiftz draws inspiration from a number of functional libraries \nand languages.  Chief among them are [Scalaz](https:\u002F\u002Fgithub.com\u002Fscalaz\u002Fscalaz),\n[Prelude\u002FBase](https:\u002F\u002Fhackage.haskell.org\u002Fpackage\u002Fbase), [SML\nBasis](http:\u002F\u002Fsml-family.org\u002FBasis\u002F), and the [OCaml Standard\nLibrary](http:\u002F\u002Fcaml.inria.fr\u002Fpub\u002Fdocs\u002Fmanual-ocaml\u002Fstdlib.html).  Elements of\nthe library rely on their combinatorial semantics to allow declarative ideas to\nbe expressed more clearly in Swift.\n\nSwiftz is a proper superset of [Swiftx](https:\u002F\u002Fgithub.com\u002Ftypelift\u002FSwiftx) that\nimplements higher-level data types like Arrows, Lists, HLists, and a number of\ntypeclasses integral to programming with the maximum amount of support from the\ntype system.\n\nTo illustrate use of these abstractions, take these few examples:\n\n**Lists**\n\n```swift\nimport struct Swiftz.List\n\n\u002F\u002F: Cycles a finite list of numbers into an infinite list.\nlet finite : List\u003CUInt> = [1, 2, 3, 4, 5]\nlet infiniteCycle = finite.cycle()\n\n\u002F\u002F: Lists also support the standard map, filter, and reduce operators.\nlet l : List\u003CInt> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\nlet twoToEleven = l.map(+1) \u002F\u002F [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\nlet even = l.filter((==0) • (%2)) \u002F\u002F [2, 4, 6, 8, 10]\nlet sum = l.reduce(curry(+), initial: 0) \u002F\u002F 55\n\n\u002F\u002F: Plus a few more.\nlet partialSums = l.scanl(curry(+), initial: 0) \u002F\u002F [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55]\nlet firstHalf = l.take(5) \u002F\u002F [1, 2, 3, 4, 5]\nlet lastHalf = l.drop(5) \u002F\u002F [6, 7, 8, 9, 10]\n```\n\n**Semigroups and Monoids**\n\n```swift\nlet xs = [1, 2, 0, 3, 4]\n\nimport protocol Swiftz.Semigroup\nimport func Swiftz.sconcat\nimport struct Swiftz.Min\n\n\u002F\u002F: The least element of a list can be had with the Min Semigroup.\nlet smallestElement = sconcat(Min(2), t: xs.map { Min($0) }).value() \u002F\u002F 0\n \nimport protocol Swiftz.Monoid\nimport func Swiftz.mconcat\nimport struct Swiftz.Sum\n\n\u002F\u002F: Or the sum of a list with the Sum Monoid.\nlet sum = mconcat(xs.map { Sum($0) }).value() \u002F\u002F 10\n\nimport struct Swiftz.Product\n\n\u002F\u002F: Or the product of a list with the Product Monoid.\nlet product = mconcat(xs.map { Product($0) }).value() \u002F\u002F 0\n```\n\n**Arrows**\n\n```swift\nimport struct Swiftz.Function\nimport struct Swiftz.Either\n\n\u002F\u002F: An Arrow is a function just like any other.  Only this time around we\n\u002F\u002F: can treat them like a full algebraic structure and introduce a number\n\u002F\u002F: of operators to augment them.\nlet comp = Function.arr(+3) • Function.arr(*6) • Function.arr(\u002F2)\nlet both = comp.apply(10) \u002F\u002F 33\n\n\u002F\u002F: An Arrow that runs both operations on its input and combines both\n\u002F\u002F: results into a tuple.\nlet add5AndMultiply2 = Function.arr(+5) &&& Function.arr(*2)\nlet both = add5AndMultiply2.apply(10) \u002F\u002F (15, 20)\n\n\u002F\u002F: Produces an Arrow that chooses a particular function to apply\n\u002F\u002F: when presented with the side of an Either.\nlet divideLeftMultiplyRight = Function.arr(\u002F2) ||| Function.arr(*2)\nlet left = divideLeftMultiplyRight.apply(.Left(4)) \u002F\u002F 2\nlet right = divideLeftMultiplyRight.apply(.Right(7)) \u002F\u002F 14\n``` \n\n**Operators**\n\nSee [Operators](https:\u002F\u002Fgithub.com\u002Ftypelift\u002FOperadics#operators) for a list of supported operators.\n\nSetup\n-----\n\nTo add Swiftz to your application:\n\n**Using Carthage**\n\n- Add Swiftz to your Cartfile\n- Run `carthage update`\n- Drag the relevant copy of Swiftz into your project.\n- Expand the Link Binary With Libraries phase\n- Click the + and add Swiftz\n- Click the + at the top left corner to add a Copy Files build phase\n- Set the directory to `Frameworks`\n- Click the + and add Swiftz\n\n**Using Git Submodules**\n\n- Clone Swiftz as a submodule into the directory of your choice\n- Run `git submodule init -i --recursive`\n- Drag `Swiftz.xcodeproj` or `Swiftz-iOS.xcodeproj` into your project tree as a subproject\n- Under your project's Build Phases, expand Target Dependencies\n- Click the + and add Swiftz\n- Expand the Link Binary With Libraries phase\n- Click the + and add Swiftz\n- Click the + at the top left corner to add a Copy Files build phase\n- Set the directory to `Frameworks`\n- Click the + and add Swiftz\n \n**Using Swift Package Manager**\n\n- Add Swiftz to your `Package.swift` within your project's `Package` definition:\n\n```swift\nlet package = Package(\n\tname: \"MyProject\",\n\t...\n\tdependencies: [\n\t\t.package(url: \"https:\u002F\u002Fgithub.com\u002Ftypelift\u002FSwiftz.git\", from: \"0.0.0\")\n\t\t...\n\t],\n\ttargets: [\n\t\t.target(\n            name: \"MyProject\",\n            dependencies: [\"Swiftz\"]),\n        ...\n\t]\n)\n```\n\nSystem Requirements\n===================\n\nSwiftz supports OS X 10.9+ and iOS 8.0+.\n\nLicense\n=======\n\nSwiftz is released under the BSD license.\n\n","Swiftz 是一个用于 Swift 语言的功能编程库。它定义了功能数据结构、函数、惯用法以及扩展，以增强 Swift 标准库。该项目实现了如箭头（Arrows）、列表（Lists）、HLists 等高级数据类型，并引入了包括半群（Semigroups）和幺半群（Monoids）在内的多种类型类，从而充分利用类型系统来支持编程。Swiftz 适用于希望在 Swift 项目中采用更纯粹的功能编程模式的开发者，特别是在需要处理复杂的数据转换或算法实现时，能够提供强大的抽象能力和简洁的代码表达方式。",2,"2026-06-11 03:09:59","top_language"]