From e33448eb97b255cd70f19ea4163909afdda35dbe Mon Sep 17 00:00:00 2001 From: Aldwin Vlasblom Date: Thu, 19 Jul 2018 11:25:03 +0200 Subject: [PATCH] Version 1.1.0 --- LICENSE | 2 +- README.md | 57 ++++++++++++++++++++++++++-------------------------- package.json | 2 +- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/LICENSE b/LICENSE index 2f04747..ff5d016 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ The MIT License (MIT) -Copyright (c) 2017 Aldwin Vlasblom +Copyright (c) 2018 Aldwin Vlasblom Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index b7e2ec0..bd8248c 100644 --- a/README.md +++ b/README.md @@ -8,53 +8,52 @@ Turn non-concurrent [FantasyLand 3][FL3] 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`][FL:Monad] (with sequential `ap`) in an +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`][FL:Monad] (with sequential `ap`) in an [`Alternative`][FL:Alternative] (with parallel `ap`). ## Usage ```js -//The concurrify function takes four arguments, explained below. -const concurrify = require('concurrify'); +// The concurrify function takes four arguments, explained below. +const concurrify = require ('concurrify'); -//We load the Type Representative of the Applicative we want to transform. -const Future = require('fluture'); +// The Type Representative of the Applicative we want to transform. +const Future = require ('fluture'); -//We create a "zero" instance and an "alt" function for "Alternative". -const zero = Future(() => {}); +// A "zero" instance and an "alt" function for "Alternative". +const zero = Future (() => {}); const alt = Future.race; -//We create an override "ap" function that runs the Applicatives concurrently. -const ap = (mx, mf) => Future.both(mx, mf).map(([x, f]) => f(x)); +// An override "ap" function that runs the Applicatives concurrently. +const ap = (mx, mf) => (Future.both (mx, mf)).map (([x, f]) => f (x)); -//Calling concurrify with these arguments gives us a new Type Representative. -const ConcurrentFuture = concurrify(Future, zero, alt, ap); +// A new Type Representative created by concurrify. +const ConcurrentFuture = concurrify (Future, zero, alt, ap); -//We can use our type as such: -ConcurrentFuture(Future.of(1)).sequential.fork(console.error, console.log); -``` - -## API - -```hs -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 +// We can use our type as such: +const par = ConcurrentFuture (Future.of (1)); +const seq = par.sequential; +seq.fork (console.error, console.log); ``` ## Interoperability -* Implements [FantasyLand 3][FL3] `Alternative` (`of`, `zero`, `map`, `ap`, `alt`). -* Instances can be identified by, and are compared using, [Sanctuary Type Identifiers][STI]. +* Implements [FantasyLand 3][FL3] `Alternative` + (`of`, `zero`, `map`, `ap`, `alt`). +* Instances can be identified by, and are compared using, + [Sanctuary Type Identifiers][STI]. +* Instances can be converted to String representations according to + [Sanctuary Show][SS]. - +## 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` [FL3]: https://github.com/fantasyland/fantasy-land/ [FL:Monad]: https://github.com/fantasyland/fantasy-land/#monad [FL:Alternative]: https://github.com/fantasyland/fantasy-land/#alternative - [STI]: https://github.com/sanctuary-js/sanctuary-type-identifiers +[SS]: https://github.com/sanctuary-js/sanctuary-show diff --git a/package.json b/package.json index 963a945..48d856d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "concurrify", - "version": "1.0.3", + "version": "1.1.0", "description": "Turn non-concurrent FantasyLand Applicatives concurrent", "main": "index.js", "repository": {