Giter Site home page Giter Site logo

hobwekiva / leibniz Goto Github PK

View Code? Open in Web Editor NEW
36.0 6.0 4.0 195 KB

Leibniz equivalence and Liskov substitutability library for Scala.

License: MIT License

Scala 94.63% Java 5.32% Makefile 0.05%
scala witnesses equality gadt leibniz liskov-substitution-principle liskov-subsititution subtyping existential-types variance

leibniz's Introduction

Leibniz Scala Library

The Leibniz’ equality law states that if a and b are identical then they must have identical properties. Leibniz’ original definition reads as follows:

a ≡ b = ∀ f .f a ⇔ f b

and can be proven to be equivalent to:

a ≡ b = ∀ f .f a → f b

This library provides an encoding of Leibniz' equality and other related concepts in Scala. See my impromptu LC 2018 presentation for an overview.

Witnesses

  • Is[A, B] (with a type alias to A === B) witnesses that types A and B are exactly the same.
  • Similarly, IsK[A, B] (with a type alias to A =~= B) witnesses that types A[_] and B[_] are exactly the same. Combinators exist that allow you to prove that F[A] === F[B] for any F[_[_]] or that A[X] === B[X] for any X.
  • Leibniz[L, H, A, B] witnesses that types A and B are the same and that they both are in between types L and H.
  • Is[F, A, B] witnesses type-equality for F-Bounded types.
  • As[A, B] witnesses that A is a subtype of B.
  • As1[A, B] witnesses that A is a subtype of B using existential types.
  • Liskov[L, H, A, B] is a bounded counterpart to As[A, B].
  • Constant[F] witnesses that HKT F is a constant type lambda.
  • Injective[F] witnesses that HKT F is injective (not a constant type lambda 😃).
  • Covariant[F] witnesses that HKT F is covariant (constant or strictly covariant).
  • Ditto other typeclasses / propositional types in variance package.
  • See my impromptu LC 2018 presentation for an overview.

Quick Start

resolvers += Resolver.bintrayRepo("alexknvl", "maven")
libraryDependencies += "com.alexknvl"  %%  "leibniz" % "0.10.0"

License

Code is provided under the MIT license available at https://opensource.org/licenses/MIT, as well as in the LICENSE file.

leibniz's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

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.