All Projects → fluture-js → concurrify

fluture-js / concurrify

Licence: MIT License
Turn non-concurrent FantasyLand Applicatives concurrent

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to concurrify

Fluture
🦋 Fantasy Land compliant (monadic) alternative to Promises
Stars: ✭ 2,249 (+9270.83%)
Mutual labels:  algebraic-data-types, fantasy-land
sum types.dart
A code generator enabling sum-types in Dart
Stars: ✭ 39 (+62.5%)
Mutual labels:  algebraic-data-types
Swift Enum Properties
🤝 Struct and enum data access in harmony.
Stars: ✭ 191 (+695.83%)
Mutual labels:  algebraic-data-types
heidi
heidi : tidy data in Haskell
Stars: ✭ 24 (+0%)
Mutual labels:  algebraic-data-types
Poica
🧮 A research programming language on top of C macros
Stars: ✭ 231 (+862.5%)
Mutual labels:  algebraic-data-types
mutoid
Reactive library for data fetching, caching, state management
Stars: ✭ 24 (+0%)
Mutual labels:  algebraic-data-types
Remote Data Ts
RemoteData type
Stars: ✭ 185 (+670.83%)
Mutual labels:  algebraic-data-types
sanctuary-either
🌈 Fantasy Land -compliant Either type
Stars: ✭ 44 (+83.33%)
Mutual labels:  fantasy-land
dart meta types
a code gen solution for defining sealed classes, data classes, and enum classes for dart.
Stars: ✭ 25 (+4.17%)
Mutual labels:  algebraic-data-types
sanctuary-maybe
🌈 Fantasy Land -compliant Maybe type
Stars: ✭ 95 (+295.83%)
Mutual labels:  fantasy-land
mir-core
Base software building blocks: Algebraic types (aka sumtype/tagged union/variant), universal reflection API, basic math, and more.
Stars: ✭ 23 (-4.17%)
Mutual labels:  algebraic-data-types
super-ts
🦸 λΔ providing super powers to Typescript.
Stars: ✭ 43 (+79.17%)
Mutual labels:  fantasy-land
vallang
Generic immutable recursive data representation API targeted at source code models and more.
Stars: ✭ 28 (+16.67%)
Mutual labels:  algebraic-data-types
Mlstyle.jl
Julia functional programming infrastructures and metaprogramming facilities
Stars: ✭ 223 (+829.17%)
Mutual labels:  algebraic-data-types
sanctuary-identity
🌈 Fantasy Land -compliant Identity type
Stars: ✭ 24 (+0%)
Mutual labels:  fantasy-land
typical
Data interchange with algebraic data types.
Stars: ✭ 114 (+375%)
Mutual labels:  algebraic-data-types
dotvariant
A type-safe and space-efficient sum type for C# (comparable to discriminated unions in C or C++)
Stars: ✭ 52 (+116.67%)
Mutual labels:  algebraic-data-types
aifad
AIFAD - Automated Induction of Functions over Algebraic Data Types
Stars: ✭ 27 (+12.5%)
Mutual labels:  algebraic-data-types
typy
A fragmentary bidirectional type system as a Python library
Stars: ✭ 51 (+112.5%)
Mutual labels:  algebraic-data-types
bitty
🗃 A mono-repository with functional programming helpers, algebraic data types, util functions, types and even some micro frameworks in TypeScript.
Stars: ✭ 27 (+12.5%)
Mutual labels:  algebraic-data-types

Concurrify

⚠️ Unmaintained

This library is no longer used by Fluture (7b6d9fd), and now fills a space I don't think is worth filling.

  1. It's overly opinionated as a result of having been part of Fluture.
  2. It does more than strictly necessary (inclusion of Alternative instance).
  3. It doesn't do any real work - it just takes all the needed functions as input and wires them up for Fantasy Land compliance. As such, it's not a lot of effort for users to do the wiring themselves.
  4. It used undocumented features from Sanctuary Type Identifiers to automatically generate new type identifiers, but these are no longer available in the latest version of Sanctuary Type Identifiers.

----

Introduction

Turn non-concurrent FantasyLand 3 Applicatives concurrent.

Most time-dependent applicatives are very useful as Monads, because it gives them the ability to run sequentially, where each step depends on the previous. However, they lose the ability to run concurrently. This library allows one to wrap a Monad (with sequential ap) in an Alternative (with parallel ap).

Usage

// The concurrify function takes four arguments, explained below.
const concurrify = require ('concurrify');

// The Type Representative of the Applicative we want to transform.
const Future = require ('fluture');

// A "zero" instance and an "alt" function for "Alternative".
const zero = Future (() => {});
const alt = Future.race;

// An override "ap" function that runs the Applicatives concurrently.
const ap = (mx, mf) => (Future.both (mx, mf)).map (([x, f]) => f (x));

// A new Type Representative created by concurrify.
const ConcurrentFuture = concurrify (Future, zero, alt, ap);

// We can use our type as such:
const par = ConcurrentFuture (Future.of (1));
const seq = par.sequential;
seq.fork (console.error, console.log);

Interoperability

API

concurrify :: (Applicative f, Alternative (m f)) => (TypeRep f, f a, (f a, f a) -⁠> f a, (f a, f (a -⁠> b)) -⁠> f b) -⁠> f c -⁠> m f c

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].