Reazen Relude Versions Save

FP-inspired prelude/standard library for ReasonML projects

v0.58.0

4 years ago

✨ New

  • @johnhaley81 - added Relude.Js.Promise.fromIOWithResult - converts an IO.t('a, 'e) to a Js.Promise.t(result('a, 'e)) so the error type remains polymorphic

v0.57.1

4 years ago

:bug: Bug fix

  • @quartz55 - Fixed an issue in TreeZipper.findInFocusAndChildren #253

v0.57.0

4 years ago

:heavy_check_mark: Code quality update

  • Replaced uses of Belt.Result.t('a, 'e) with the built-in result('a, 'e)
    • This should be purely a cosmetic change and not cause any breakages internally or externally

:bug: Bug fixes

  • @quartz55 - Fixed issue with TreeZipper.moveUp where the leftSiblings ordering was being mishandled #248

v0.56.0

4 years ago

This release updates the underlying bs-abstract dependency to 1.0 and allows Relude to compile with Bucklescript 7.1+.

:rotating_light: Breaking changes

  • Array.empty has been removed, as its type is no longer array('a), but it now introduces weak polymorphism. Bucklescript made this change to work around unsoundness issues with Js.Array.push. You can read more about this change on the Bucklescript blog and the related bs-abstract issue.
  • As a result of removing empty, Array no longer implements MONOID_ANY, PLUS, ALTERNATIVE, MONAD_ZERO, and MONAD_PLUS.
  • More fallout from this change: constructing a Relude.NonEmpty now does not require some of these typeclass instances (and instead uses a lazy () => t('a) empty function). This actually makes NonEmpty easier to construct.

:sparkles: New Stuff

  • The underlying signature for Fold_Map_Any and Fold_Map_Plus are now more flexible, allowing you to map both the container type and the inner type.

v0.55.0

4 years ago

:sparkles: New

  • @endlo - add Set.toggle for adding/removing an item from a Set
  • Added aliases for Array, List, Option:
    • filter -> keep
    • filterWithIndex -> keepWithIndex
    • filterNot -> reject
    • filterNotWithIndex -> rejectWithIndex

v0.54.0

4 years ago

:sparkles: 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

  • Option
  • Result
  • Validation
  • IO

Added SEMIALIGN and ALIGN instances

  • Option - Semialign and Align
  • Result.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

:rotating_light: Breaking changes

  • Ior had some renames described above
  • Bifunctor isntance was moved to the top-level of IO rather than being inside the WithError module 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.

v0.53.0

4 years ago

:sparkles: New

  • @johnhaley81 - added List and Array chunk function #236
  • @jihchi - improved test coverage

v0.52.0

4 years ago

:rotating_light: Breaking

  • Float.top and Float.bottom now use min_float and max_float as determined by Bucklescript. Previously this was based on JS-specific bindings to Number.MIN_VALUE.

:sparkles: New

  • String.charAtOrEmpty works like charAt but gives you "" if the provided index is out of range (instead of having to worry about option)
  • String.charCodeAt works similarly to the Js.String equivalent from Bucklescript, but it returns an option(int) instead of a float that could be NaN
  • Float.isNaN lets you determine if a floating point value is the nan value
  • Float.nan, Float.infinity, and Float.negativeInfinity values, so you don't have to rely on the globally-available values from Pervasives

v0.51.0

4 years ago

:sparkles: New

  • @austindd - Refactored Map and Set to use Belt-style phantom type param to reduce closure weight. See #194 for more info.

v0.50.0

4 years ago

:sparkles: New

  • @utkarshkukreti - added removeAt to List and Array #226
  • Added fromList, fromArray, and reverse to NonEmpty, which consequently adds them to NonEmpty.List and NonEmpty.Array
  • Added errorNel and errorNea to Validation to lift a single error into a VError containing a Nel/Nea
  • Added Relude_Free_Applicative module
    • Free applicatives are useful for encoding things like descriptions of data (e.g. schemas), and interpreting these structures into different types of "operational" applicatives. For example, you can define a "schema" for data types using the FreeAp structure, then interpret these schemas into JSON encoders and parsers, help printers, etc. More examples possibly to follow in another relude library.
    • See test for basic usage (not terribly compelling, but just proving the concept)

:rotating_light: Breaking

  • Renamed Relude_Interface.ARROW and ARROW_F to FUNCTION_1 and FUNCTION_1_F
  • Moved Bifunctor and Bifoldable modules outside the WithError functor for Result (they didn't need to be inside the WithError context)