Purify v0.15

April 30, 2020
Not sure what purify is? Check out the Getting Started page. Also check out the FAQ page!

Breaking change inside Codec

Codec had a undefinedType codec which was insufficient as there was no way to create optional properties on an object.
This was brought up in an issue and to resolve this I removed this codec in favor of a optional combinator, please check out the docs on how to use it.

An updated Either/MaybeAsync API

When I first started designing the API for Either and MaybeAsync I wanted to bring the ease of use of proper error handling within IO, just like it is in languages with do-notation and for-comprehensions.
That's why the original API in version 0.12 only worked with async/await and I thought and this will be enough for most people.
Turns out most people started creating wrappers to make it more chainable and issues started piling in GitHub, no one liked the "imperative" API.
That's why I decided to spend some time brainstorming a new API, that didn't force people to use async/await, and this is the result:
// async/await
const deleteUser = (req) =>
    EitherAsync(async ({ liftEither, fromPromise, throwE }) => {
       const request  = await liftEither(validateRequest(req))

       try {
           const user = await fromPromise(getUser(request.userId))
       } catch {

       return deleteUserDb(user)
// new API
const deleteUser = (req) =>
        .chain(request => fromPromise(() => getUser(request.userId)))
        .mapLeft(_     => Error.UserDoesNotExist)
        .chain(user    => liftPromise(() => deleteUserDb(user)))
This is stripped down version of the code, just to demonstrate the similarities, for the full version check out the updated documentation of EitherAsync and MaybeAsync.
Both APIs will exist simultaneously and you're free to use whichever you like, much like how you can use both async/await and Promise.then.

Other changes

  • Added a new Either#swap method