v0.54.0
✨ New
Added mapHandleError function to Result and IO
- basically a shortcut for
x |> map(f) |> handleError(g) - This was added in anticipation of the refactor in reazen/relude-reason-react#25
- See #241
Reworked Ior to remove success/fail semantics, and make it more general purpose
Before this PR, Ior had constructors IOk('a), IError('e), and IBoth('a, 'e), but this makes the type more semantic, and less useful for the purposes below. I changed the constructors to This('a), That('b), and Both('a, 'b). This still allows for success/fail semantics (This being success, and That being failure), but it also allows the type to be used for less-semantic things, like ALIGN.
This was a breaking change in Ior, but should be easy to fix - just rename IOk to This, IError to That, and IBoth to Both (and other similar name changes).
Added some additional functions for Ior
catThis,catThat,merge,fold, etc. - see files changed
Added SEMIALIGN and ALIGN typeclasses
module type SEMIALIGN = {
include BsAbstract.Interface.FUNCTOR;
let align: (t('a), t('b)) => t(Relude_Ior_Type.t('a, 'b));
let alignWith: (Relude_Ior_Type.t('a, 'b) => 'c, t('a), t('b)) => t('c);
};
module type ALIGN = {
include SEMIALIGN;
let nil: t('a);
};These are quite similar to the APPLY and APPLICATIVE typeclasses (and also similar to SEMIGROUP/MONOID), but they have some interesting uses that you can't get with APPLY.
One use of these is that they allow you to compose two effectful values, and will capture a successful result if either or both sides succeed. This is similar to apply, but apply fails if either side fails, whereas align will only fail if both sides fail. The result of align is captured in an Ior, which has constructors for This('a), That('b), or Both('a 'b).
Another use of these is for zipping values together with the ability to fill in default values. Some of these helper functions have not yet been implemented, but you can see some here: https://hackage.haskell.org/package/semialign-1.1/docs/Data-Align.html#g:1
See Haskell, Scala cats/scalaz, and purescript resources for other info on Align.
Added align and alignWith functions to various types
OptionResultValidationIO
Added SEMIALIGN and ALIGN instances
Option-SemialignandAlignResult.WithError-Semialign(with fail-fast error semantics)Validation.WithErrors-Semialign(with error collecting semantics)IO.WithError-Semialign
Added extension modules for SEMIALIGN and ALIGN
These are empty placeholders for now, but would likely be the place to add some of the zip helpers
🚨 Breaking changes
Iorhad some renames described aboveBifunctorisntance was moved to the top-level ofIOrather than being inside theWithErrormodule functor- Possibly a few other minor breaking changes with functions/modules being moved - let me know if anyone runs into problems, and I can help to track them down.