The Scala Structures library is a zero-dependency Scala library that defines commonly used type classes for functional programming.
There are two modules, core and laws. The former provides the API of the library and the latter provides Discipline based laws for each of the type classes. The laws project is intended to be used in test scope, to verify that instances of the type classes are law abiding.
Yes and no. This is a reimplementation of the core type classes which borrows heavily from the ideas in Scalaz. It differs in a number of significant ways though:
NonEmptyList, Validation, \/), replacements for standard library types (e.g., Order), and monad transformers (e.g., Reader / Kleisli). Structures has a much smaller focus than Scalaz.Maybe is equivalent to Option but omits the unsafe get operation, and Order is equivalent to scala.math.Ordering, but defines the result of a comparison to be an enumerated type rather than an integer. There is great value in using safe alternatives, but providing those alternatives is not in scope of Structures.Unapply type for dealing with odd shapes.In summary, Structures models a very small subset of what is provided by Scalaz, and does so in a different way, with a different goal.
One very real cost of a large API is that there is more stuff to change over time. These changes tend to be organized in to versioned releases, with some claim of binary compatibility or incompatibility. Tooling may enforce the binary compatibility claim. However, tooling typically operates on versioned releases rather than individual artifacts like types and methods. As a result, even if you use the stablest part of a large library, you have to ensure the version of the library you use is binary compatible with the version used by all other libraries in your application, or otherwise risk linkage errors resulting from no tool checked binary compatibility.
Structures aims to be a small, stable library, with binary incompatible releases occurring at the same frequency as major Scala releases.
Structures is an experiment. It is focused on minimizing the number of type classes and integrating them closely with Scala language features and the standard library. It is entirely possible that this experiment fails in the sense that it no longer should exist as a library. In which case, the overall effort would still be valuable by demonstrating why a smaller subset of type classes is not useful.
The Typelevel cats project is similar in many ways to Structures. However, cats is more ambitious in what it is attempting. Eventually, cats will grow in to a number of modules that together have similar scope to Scalaz. The focus of Structures is to provide a minimal subset of common FP type classes. As an example of how this goal results in differences, cats will likely include something like Scalaz's Unapply syntax, whereas that is out of scope for Structures.
In short, we believe that there is room for multiple libraries in this space.
This project is influenced by a number of other projects. Notably:
This project is also influenced by a number of individuals, who will be added here with their agreement.
Scala
99.5%
The Scala Structures library is a zero-dependency Scala library that defines commonly used type classes for functional programming.
There are two modules, core and laws. The former provides the API of the library and the latter provides Discipline based laws for each of the type classes. The laws project is intended to be used in test scope, to verify that instances of the type classes are law abiding.
Yes and no. This is a reimplementation of the core type classes which borrows heavily from the ideas in Scalaz. It differs in a number of significant ways though:
NonEmptyList, Validation, \/), replacements for standard library types (e.g., Order), and monad transformers (e.g., Reader / Kleisli). Structures has a much smaller focus than Scalaz.Maybe is equivalent to Option but omits the unsafe get operation, and Order is equivalent to scala.math.Ordering, but defines the result of a comparison to be an enumerated type rather than an integer. There is great value in using safe alternatives, but providing those alternatives is not in scope of Structures.Unapply type for dealing with odd shapes.In summary, Structures models a very small subset of what is provided by Scalaz, and does so in a different way, with a different goal.
One very real cost of a large API is that there is more stuff to change over time. These changes tend to be organized in to versioned releases, with some claim of binary compatibility or incompatibility. Tooling may enforce the binary compatibility claim. However, tooling typically operates on versioned releases rather than individual artifacts like types and methods. As a result, even if you use the stablest part of a large library, you have to ensure the version of the library you use is binary compatible with the version used by all other libraries in your application, or otherwise risk linkage errors resulting from no tool checked binary compatibility.
Structures aims to be a small, stable library, with binary incompatible releases occurring at the same frequency as major Scala releases.
Structures is an experiment. It is focused on minimizing the number of type classes and integrating them closely with Scala language features and the standard library. It is entirely possible that this experiment fails in the sense that it no longer should exist as a library. In which case, the overall effort would still be valuable by demonstrating why a smaller subset of type classes is not useful.
The Typelevel cats project is similar in many ways to Structures. However, cats is more ambitious in what it is attempting. Eventually, cats will grow in to a number of modules that together have similar scope to Scalaz. The focus of Structures is to provide a minimal subset of common FP type classes. As an example of how this goal results in differences, cats will likely include something like Scalaz's Unapply syntax, whereas that is out of scope for Structures.
In short, we believe that there is room for multiple libraries in this space.
This project is influenced by a number of other projects. Notably:
This project is also influenced by a number of individuals, who will be added here with their agreement.
Scala
99.5%