GithubHelp home page GithubHelp logo

structures's Introduction

The Scala Structures Library

Gitter

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.

FAQ

Is this a fork of Scalaz?

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:

  • Structures defines type classes (and a minimal set of types needed for the implementation of those type classes), whereas Scalaz encompasses much more functionality, including data types (e.g., 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.
  • Structures attempts to fit in with the Scala standard library when possible, even when the standard library provides unsafe functionality. This is contrary to Scalaz, which often provides safe alternatives to standard library constructs. For instance, 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.
  • Structures defines a small subset of the type classes defined by Scalaz. For example, Structures does not provide abstractions for modeling categories, arrows, or adjoint functors.
  • Structures does not provide special syntax support for working with implicit type class instances of odd shapes. Scalaz provides the 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.

Why is minimizing API footprint desirable? Can't I just ignore stuff I don't use?

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.

Will this force library authors to choose between Scalaz and Structures?

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.

OK, but what about cats?

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.

Acknowledgements

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.

structures's People

Contributors

mpilquist avatar stew avatar gitter-badger avatar

Stargazers

Alexander Litvinenko avatar Nhat Pham avatar  avatar Nacho Castillo avatar Danny L avatar w3lldo avatar Kamil Adam avatar  avatar Kodai Takihara avatar zilong avatar  avatar James A avatar Henri Cook avatar Courtney Robinson avatar Victoria Petite avatar Michael Browning avatar Sofia Tania avatar Doogie Min avatar David Przybilla avatar Abdhesh Kumar avatar Chandu avatar XXX YYY avatar  avatar  avatar BlancosWay avatar Aedan Smith avatar Grigory avatar Zenhue Song avatar Steven Chen avatar Igal Tabachnik avatar Filippo Mariotti avatar Dmitry avatar Yad avatar  Alexey Terekhin avatar Maher Gamal avatar Takeru Sato avatar Nikita avatar László Andrási avatar Alexander Shelemin avatar Danny Navarro avatar bistaumanga avatar Shane Delmore avatar Viacheslav Blinov avatar  avatar Zeno Wu avatar Ilia Murzinov avatar Matthew Kettlewell avatar Yan avatar Yuji Ueki avatar Shohei Shimomura avatar  avatar Eliza Weisman avatar Pedro Larroy avatar  avatar Konstantin Läufer avatar scalway avatar Marcin avatar Max P. avatar  avatar Albert Serrallé Ríos avatar Andrea avatar Jits avatar  avatar Daniil Migachev avatar Anton Karamanov avatar Ilya avatar Povilas Skruibis avatar Phillip Ressler avatar Ivan Luzyanin avatar Angus H. avatar Joseph Price avatar Owain Lewis avatar William Harvey avatar Raghava Nellaturu avatar Stas Ilinskiy avatar Sergii Golyshev avatar komlow avatar yawnt avatar Sean Vieira avatar Montree avatar Allen Nie avatar Oleg Kovalenko avatar Luis Alfonso Higuera Gamboa avatar abdul dakkak avatar Karol Chmist avatar Jaap ter Woerds avatar Merlijn Boogerd avatar Eran Medan avatar 5hun Yanaura avatar Chris Frohoff avatar Piotr Limanowski avatar Bay Raktar avatar  avatar Martin Krasser avatar David Cromberge avatar Peter Petersson avatar Adam Smith avatar Jürgen Keck avatar Phil Andrew avatar Joost de Vries avatar

Watchers

Chirag Dadia avatar chris vale avatar  avatar  avatar Tom Switzer avatar Frank Thomas avatar Matt Hughes avatar Joe Zulli avatar ven avatar Eduardo Pareja Tobes avatar Erik Osheim avatar Timothy Perrigo avatar Jan Erik Svendsen avatar kenji yoshida avatar  avatar Steve Buzzard avatar James Cloos avatar Jack Rudnick avatar Cody Allen avatar Dominik Zajkowski avatar edwardttril avatar Adam Smith avatar Allen Nie avatar  avatar

structures's Issues

Compatibility with non/algebra

Hi @mpilquist,

there is already a project underway to create algebraic structures in common between algebird and spire. There is overlap with Structures in the Semigroup/Monoid departement.

Just wanted you to know.

Add scala.js support

Not sure exactly what's involved in doing this. Ideally, new releases of scala.js should not require re-releasing Structures. If the tooling allows for that, let's configure this project for scala.js publishing. If not, then let's create a companion project that builds Structures for scala.js.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.