Skip to content

v2.0.0-alpha3

Pre-release
Pre-release
Compare
Choose a tag to compare
@robotlolita robotlolita released this 25 Jun 16:49
· 274 commits to master since this release

New features

  • Adds a nullable → maybe conversion
    (9706ab7);
  • Adds a .fold() method to the Maybe structure. This works similarly to Result and Validation's .fold() method, except the function for the Nothing case takes no arguments
    (6f59f61);
  • Adds the collect function (data/validation/collect), which makes aggregating errors from failures directly a bit simpler
    (#71, a677e96);

Bug fixes

  • Fixes the exported symbol for validation → either conversion
    (450cb70);
  • Fixes the Setoid implementation to work with the core/fantasy-land module
    (d761107);
  • Fixes a bunch of currying and argument order issues with the core/fantasy-land module
    (d5b0c74);

Miscellaneous

  • Annotated files are now only generated for testing and documentation, which makes browser bundles much smaller
    (e0186fa);

DEPRECATED FEATURES

  • The old .get() methods are deprecated in favour of the new .unsafeGet() methods. There was no behavioural change, just a naming one. See #42.
    (278d5a7, 19910b4);

BREAKING CHANGES

  • (8e1b27e)
    Modules that were previously named core.js now reflect the name of the functionality they implement. This affects you if you've been importing the core.js modules directly, rather than their folder. The following modules are affected by this change:

    • core/adt/core.jscore/adt/data.js (exports the data function);
    • data/either/core.jsdata/either/either.js (exports the either ADT);
    • data/maybe/core.jsdata/maybe/maybe.js (exports the maybe ADT);
    • data/validation/core.jsdata/validation/validation.js (exports the validation ADT).
  • (7a1ef33)
    Removes the data/either/fromNullable.js module, which was moved to the data/conversions module. This affects you if you have been importing that module directly. In that case you can import data/conversions/nullable-to-either.js instead:

    // Before
    const eitherFromNullable = require('data/either/fromNullable');
    
    // Now
    const eitherFromNullable = require('data/conversions/nullable-to-either');

    Note that no changes are necessary if you were importing the whole data/either module and taking the fromNullable method from there.

  • (5676d39)
    Either.try now takes a thunk, rather than being a curried-ish form of application:

    // Before
    Either.try((a) => a.foo())(null);   // ==> Left("cannot read property 'foo' of null")
    
    // Now
    Either.try(() => null.foo());       // ==> Left("cannot read property 'foo' of null")
  • (PR #62)
    Renames EitherResult. No behaviour changes, but a bunch of terminology changes that break existing code.

    Where one used to write:

    const { Left, Right } = require('folktale/data/either');

    One would now write:

    const { Error, Ok } = require('folktale/data/result');

    The data structure's name has been changed to Result. The Left case has been changed to Error, and the Right case has been changed to Ok. This affects all uses of .matchWith as well as constructing values.

  • (d5e780f)
    Remove the .cata() method from core/adt, but adds it to Maybe and Validation. This breaks any core/adt structure that was using .cata() instead of .matchWith(), but makes it easier for people to migrate their code with Maybe and Validation to Folktale 2 by just replacing require('data.maybe') with require('folktale/data/maybe').

  • (f0dd120)
    Several renamings to make the API consistent regarding its usage of English (see #21), so now all names in the API use US English spelling, although the documentation still uses British English spelling:

    • The Show derivation (core/adt/show.js) is now called DebugRepresentation (core/adt/derivations/debug-representation.js);
    • The Setoid derivation (core/adt/setoid.js) is now called Equality (core/adt/derivations/equality.js). The method for providing a custom comparison function, previously .withEquality(cmp) is now called .wthCustomComparison(cmp);
    • The Serialize derivation (core/adt/serialize.js) is now called Serialization (core/adt/derivations/serialization.js);
    • The derivations are now provided in the core/adt/derivations.js file, and consequently in a derivations property of the core/adt module, rather than directly there;
    • The partialise function (core/lambda/partialise.js) is now called partialize (core/lambda/partialize.js).