All Projects → propensive → mercator

propensive / mercator

Licence: Apache-2.0 license
Automatic typeclass-based abstraction over monad-like types

Programming Languages

scala
5932 projects
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to mercator

Fp Resources
Functional programming great resources
Stars: ✭ 369 (+583.33%)
Mutual labels:  monad, category-theory
Bow
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift
Stars: ✭ 538 (+896.3%)
Mutual labels:  monad, category-theory
free-arrow
Implementation of the Free Arrow in Scala and other helpful tools for working with Arrows
Stars: ✭ 14 (-74.07%)
Mutual labels:  monad, category-theory
Category Theory
An axiom-free formalization of category theory in Coq for personal study and practical work
Stars: ✭ 562 (+940.74%)
Mutual labels:  monad, category-theory
Functional Examples
Examples with Functional JavaScript, following Professor Frisby's course
Stars: ✭ 179 (+231.48%)
Mutual labels:  monad, category-theory
functional-structures-refactoring-kata
Starting code and proposed solution for Functional Structures Refactoring Kata
Stars: ✭ 31 (-42.59%)
Mutual labels:  monad, category-theory
Fluokitten
Category theory concepts in Clojure - Functors, Applicatives, Monads, Monoids and more.
Stars: ✭ 408 (+655.56%)
Mutual labels:  monad, category-theory
Ltupatternfactory
Lambda the ultimate Pattern Factory: FP, Haskell, Typeclassopedia vs Software Design Patterns
Stars: ✭ 735 (+1261.11%)
Mutual labels:  monad, category-theory
Fp Core.rs
A library for functional programming in Rust
Stars: ✭ 772 (+1329.63%)
Mutual labels:  monad, category-theory
Bastet
A ReasonML/Ocaml library for category theory and abstract algebra
Stars: ✭ 200 (+270.37%)
Mutual labels:  monad, category-theory
LLVM-JVM
[W.I.P] A Just-In-Time Java Virtual Machine written in Haskell
Stars: ✭ 22 (-59.26%)
Mutual labels:  monad, monadic
fpEs
Functional Programming for EcmaScript(Javascript)
Stars: ✭ 40 (-25.93%)
Mutual labels:  monad
ansible-role-dns
Install and configure dns on your system.
Stars: ✭ 39 (-27.78%)
Mutual labels:  bind
FluentSimulator
A fluent syntax .NET REST/HTTP API simulator for automated unit and UI testing.
Stars: ✭ 23 (-57.41%)
Mutual labels:  unit
RCE-python-oneliner-payload
Python bind shell single line code for both Unix and Windows, used to find and exploit RCE (ImageMagick, Ghostscript, ...)
Stars: ✭ 23 (-57.41%)
Mutual labels:  bind
ad-lens
Automatic Differentiation using Pseudo Lenses. Neat.
Stars: ✭ 16 (-70.37%)
Mutual labels:  category-theory
preface
Preface is an opinionated library designed to facilitate the handling of recurring functional programming idioms in OCaml.
Stars: ✭ 116 (+114.81%)
Mutual labels:  category-theory
open-pos
Open Source Point of Sale System.
Stars: ✭ 52 (-3.7%)
Mutual labels:  point
alea
Coq library for reasoning on randomized algorithms [maintainers=@anton-trunov,@volodeyka]
Stars: ✭ 20 (-62.96%)
Mutual labels:  monad
maybe-baby
Minimize defensive coding. A JavaScript implementation of the Maybe monad.
Stars: ✭ 42 (-22.22%)
Mutual labels:  monad

GitHub Workflow

Mercator

Mercator is a macro for automatically constructing evidence that a known type may be used in a for-comprehension, for abstracting over monad-like types with no impact on performance. This allows us to write code against generic type constructors which can assume that they are usable in a for-comprehension, without having the evidence that they are until the application point when the type constructor is known, at which point, Mercator will construct it.

Features

  • abstracts over monad-like types
  • constructs a monad typeclass instance for any type with flatMap, map and a "point" constructor
  • makes intelligent guesses about identifying the "point" constructor for a type
  • constructs a functor instance if only map and "point" are available

Getting Started

It is not possible to write code such as,

// does not compile
def increment[F[_]](xs: F[Int]) = for(x <- xs) yield x + 1

because the compiler is not able to enforce the constraint that the type constructor F[_] provides the methods map and flatMap (with the correct signatures) which are necessary for the for-comprehension to compile.

With Mercator, it is possible to demand an implicit instance of Monadic[F] to enforce this constraint. Mercator will automatically instantiate such an instance at the use-site for any type which has the required methods, like so,

import mercator._
def increment[F[_]: Monadic](xs: F[Int]) = for(x <- xs) yield x + 1

The methods flatMap and map will be provided to the instance of F[_] as extension methods, using an implicit value class in the mercator package. This incurs no allocations at runtime, and the performance overhead should be zero or negligible.

Point

An instance of Monadic[F] will generate an implementation of point, which constructs a new instance of the type from a single value. This implementation assumes the existence of an apply method on the type's companion object, and that applying the value to it will produce a result of the correct type.

If this is not the case, Mercator will try to find a unique subtype of F[_] whose companion object has an apply method taking a single value and returning the correct type. In the case of Either or Scalaz's \/, this will do the right thing.

Status

Mercator is classified as fledgling. Propensive defines the following five stability levels for open-source projects:

  • embryonic: for experimental or demonstrative purposes only, without guarantee of longevity
  • fledgling: of proven utility, seeking contributions, but liable to significant redesigns
  • maturescent: major design decisions broady settled, seeking probatory adoption and refinement of designs
  • dependable: production-ready, subject to controlled ongoing maintenance and enhancement; tagged as version 1.0 or later
  • adamantine: proven, reliable and production-ready, with no further breaking changes ever anticipated

Availability

Mercator’s source is available on GitHub, and may be built with Fury by cloning the layer propensive/mercator.

fury layer clone -i propensive/mercator

or imported into an existing layer with,

fury layer import -i propensive/mercator

A binary is available on Maven Central as com.propensive:mercator-core_<scala-version>:0.4.0. This may be added to an sbt build with:

libraryDependencies += "com.propensive" %% "mercator-core" % "0.4.0"

Contributing

Contributors to Mercator are welcome and encouraged. New contributors may like to look for issues marked label: good first issue.

We suggest that all contributors read the Contributing Guide to make the process of contributing to Mercator easier.

Please do not contact project maintainers privately with questions, as other users cannot then benefit from the answers.

Author

Mercator was designed and developed by Jon Pretty, and commercial support and training is available from Propensive OÜ.

License

Mercator is copyright © 2018-20 Jon Pretty & Propensive OÜ, and is made available under the Apache 2.0 License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].