Releases: reazen/relude
v0.49.0
Thanks to contributors!
✨ New
- @utkarshkukreti New functions for
Array
/List
:insertAt
- inserts an element at an index, shifting the following elements downupdateAt
- modifies an element at an index using a functionswapAt
- swaps the values at two indices
✔️ Tests
- @jihchi - Greatly improved test coverage for various modules
v0.48.0
✨ New
- Added extension module functors for
ENUM
andBOUNDED_ENUM
, inspired by purescript-enumsfromToAsList
- generate a list of enum values from a start value to an end valueupFromAsList
- generate a list of enum values starting from (but not including) a start valueupFromIncludingAsList
- generate a list of enum values starting from (and including) a start valuedownFromAsList
- generate a list of enums down from (but not including) a start valuedownFromIncludingAsList
- generate a list of enums down from (and including) a start value- See https://github.com/reazen/relude/blob/master/__tests__/extensions/Relude_Extensions_Enum_test.re for example usage
v0.47.0
✨ New
- @jihchi - unit tests and documentation updates! Thanks!
Relude.Bool
- Added typeclass instance for
BsAbstract.Interface.BOUNDED
typeclass - Added typeclass instance for
Relude_Interface.ENUM
typeclass - Added typeclass instance for
Relude_Interface_BOUNDED_ENUM
typeclass
- Added typeclass instance for
Relude.Eq
- Added new module for functions having to do with
Eq
- Added
by
function - the contravariant map for the('a, 'a) => bool
equality function- Given a function
('a, 'a) => bool
, and a function'b => 'a
, returns a new equality function for('b, 'b) => bool
- Given a function
- Added typeclass instances for
BsAbstract.Interface.CONTRAVARIANT
for('a, 'a) => bool
function - Added
invert
function for inverting an('a, 'a) => bool
equality function
- Added new module for functions having to do with
Relude.Int
- Added typeclass instances for
BOUNDED
andENUM
- Added typeclass instances for
Relude.Interface
- Added typeclass module type
ARROW
for capturing atype a
, atype b
, and a functiona => b
- Added typeclass module type functor
ARROW_F
for capturing two types, and returning anARROW
for the types - Added
LOWER_BOUNDED
typeclass for representing a type with a lower bound (e.g.string
has""
as a lower bound) - Added
UPPER_BOUNDED
typeclass for representing a type with an upper bound - Added
ENUM
typeclass for representing a type that can be enumerated - Added
BOUNDED_ENUM
typeclass for representing a type that can be enumerated, and has an upper and lower bound
- Added typeclass module type
Relude.Ord
- Added module for working with comparison functions of the form
('a, 'a) => BsAbstract.Interface.ordering
by
function is the contravariant map for the compare function- Added
CONTRAVARIANT
instance for the compare function usingby
- Added
reverse
function for reversing the order of a compare function - Moved a bunch of loose helper function from
Relude_Extensions_Ord
toRelude_Ord
- these are now used byRelude_Extensions_Ord
- Added module for working with comparison functions of the form
Relude_Ordering
- Added a module for working with the
BsAbstract.Interface.ordering
type - the polymorphic variant that contains inhabitantsequal_to
,greater_than
, andless_than
- Various helper functions and typeclass instances for working with values of type
ordering
- Added a module for working with the
Relude_Tuple
- Split up the
Tuple
module into submodulesRelude.Tuple2
, etc. - Added helper functions and module functors for creating
Eq
andOrd
instances for types that can be converted to a tuple
- Split up the
Relude_Unit
- Added module for dealing with
unit
values - Various helper functions and typeclasses
- Added module for dealing with
Relude_Extensions_Eq
- Added functions and modules for inverting equality functions/
Eq
modules - Added functions/module functors for creating
Eq
modules in terms of otherEq
modules (via theCONTRAVARIANT
nature ofEQ
)
- Added functions and modules for inverting equality functions/
Relude_Extensions_Ord
- Added functions and modules for reversing comparison functions/
Ord
modules - Added functions/module functors for creating
Eq
modules in terms of otherEq
modules (via theCONTRAVARIANT
nature ofEQ
)
- Added functions and modules for reversing comparison functions/
Relude_Extensions_Show
- Added some basic helpers for
Show
modules
- Added some basic helpers for
🚨 Breaking
- Changed
Relude_Extensions_Ord.Named
module toRelude_Extensions_Ord.OrdNamed
- Attn: @johnhaley81
- Any module that defines its own
Ord
module andinclude
sRelude_Extensions_Ord
and that used to access comparison functions using theNamed
module, should now useOrdNamed
. - This was done to avoid possible naming conflicts with multiple extension modules wanting use provide a module of functions with named/labelled parameters.
- Fix: change uses of
Named
coming fromOrdExtensions
toOrdNamed
✔️ Code quality
- New and/or improved test coverage for
Bool
Eq
Float
Ord
Tuple
Unit
Extensions.Eq
Extensions.Ord
🤔 Who cares?
- You can now define
eq
/compare
functions andEq
/Ord
modules for your domain types in new and exciting ways.- For example, if you can convert your type to any type that has an
Ord
instance (i.e. extracting someint
/string
identifier from some domain type, you can "derive" anOrd
instance for your domain type in terms ofInt.Ord
orString.Ord
- Or if you have a domain type that you want to order by several of its value in some order of precedence, and you have
Ord
instances for the types of those values, you can create anOrd
instance for your domain type by providing a function that maps it to aTuple2-5
, and theOrd
instances for each value involved.
- For example, if you can convert your type to any type that has an
TODO
- Added bounded enum extensions like https://github.com/purescript/purescript-enums/blob/master/src/Data/Enum.purs#L172-L237
v0.46.0
✨ New
- Add
String.padStart
andString.padEnd
- Should work the same/similarly to the JS functions below:
v0.45.0
✨ New
- Adds a
TreeZipper
- similar toListZipper
, but for a multi-way "rose" tree, likeRelude_Tree
#208 - Allows you to "navigate" within a Tree and manipulate the values around you
- See Tony Morris' presentation here for more info: http://data.tmorris.net/talks/zippers/bd054c210649101b84662c614fc45af3c27a5eef/zippers.pdf
- I have not implemented all the typeclasses (Apply/Applicative/Monad/Comonad/Foldbale/etc.) at this time, but that can be done in the future.
v0.44.0
✨ New
- Add a non-empty, multi-way "rose" tree module
Relude_Tree
- Inspired by many similar implementations in Haskell/Purescript/Elm
v0.43.0
✨ New stuff
Option.Ord
is available if the inner type is a member ofOrd
(similar to howOption.Eq
works)Option.String
,Option.Int
andOption.Float
specializations now all come withOrd
support
🐛 Bug fixes
- The recently-added
Option.Eq
helper had the wrong type in its signature (list('a)
, almost as if I copied-and-pasted it from somewhere...)
v0.42.0
✔️ Code quality
- Attempt to fix inadvertent shadowing warnings caused by re-aliasing functions/operators/modules in some of the Relude library modules #205
🚨 Possible breaking changes
The above change may cause breakages if you happened to be using one of these aliased modules like Relude.IO.Result
, or relying on the fact that some of the Relude
modules had re-aliased the >>
/<<
operators from Relude_Function.Infix
.
To fix these issues, just reference the function/module from the proper place, or add a open Relude.Function.Infix
at the top of your module.
v0.41.0
v0.40.0
✨ New
Parallel semantics for IO
APPLY
- Implement parallel execution semantics for the
IO
APPLY
typeclass! 🎆 - Anything that uses an
APPLY
-based parallelization (apply
,map2-5
,tuple2-5
,mapTuple2-5
,all
,traverse
/sequence
, etc.) should now execute the IO operations in parallel rather than sequential.- You shouldn't have to change anything - it should just now be parallel when run
- This was implemented by adding a new
Apply
constructor toIO
, to go along with theMap
andFlatMap
constructors - Prior to this change the
IO
apply
function was implemented in terms offlatMap
, which is why it had the sequential execution semantics. AddingApply
allows for parallel semantics.
IO
unsafeRunAsyncPar2
and 3
- Added
unsafeRunAsyncPar2
and3
functions for IO - These are used internally to implement the paralell semantics of
IO
'sApply
, so it's better to useapply
-based combinators to compose parallelIO
values, rather than manually running them using these. - That said, if people find these useful, we can add more, like up to the usual 5, or more!
compose
function for IO
, Result
and Option
- Added a compose function for the above types, which allow you to compose two functions that are each wrapped inside their own functor contexts.
let rec compose:
'a 'b 'c 'e.
(t('b => 'c, 'e), t('a => 'b, 'e)) => t('a => 'c, 'e) = ...
let (<<<) = compose;
let andThen:
'a 'b 'c 'e.
(t('a => 'b, 'e), t('b => 'c, 'e)) => t('a => 'c, 'e) = ...
let (>>>) = andThen;
- This was useful for implementing some of the
IO
pattern matching with the addition ofApply
- I also made
IO
,Result
, andOption
implementSemigroupoid
instances using the abovecompose
functions. I'm not 100% sure if this is a valid thing to do, but it seemed reasonable. Happy to be corrected if this is invalid (and at some point we need to add property-based tests).
🚨 Breaking
-
A small breaking change to
IO.withDelay
- I realized thatwithDelay
was actually creating a newIO
that put the delay before the inputIO
, so I changed this to split thewithDelay
function into two different versions:withDelayAfter
- creates a new IO which when run, will execute the givenIO
first, then add the delaywithDelay
- alias forwithDelayAfter
withDelayBefore
- creates a new IO which when run, will execute the delay, then the givenIO
The breaking change is that withDelay
used to work more like withDelayBefore
, but now is just an alias for withDelayAfter
. The end result of each of these is the same, they just put the delay at either the start or the end of the IO
operation
🗣️ Request for feedback
This change to IO
Apply
has not been tested super thoroughly other than some high-level unit tests and some production use cases in our app, so I'd love to hear from anyone as to whether the parallel behavior is working for you, or if you encounter any new problems. If you adopt this version of relude in an existing app, I'd recommend exercising all parts of your app which use IO
to make sure there are no regressions.
If you do find regressions, I'd recommend reverting the version of relude for now, and I can try to look into specific cases. If you encounter issues, I'd appreciate minimal reproduction test cases, but any sort of issue description would be appreciated. The most useful information is just a description of what IO
combinators you're using, and the order in which they are being used (i.e. "we are doing an async
, followed by flatMap
, apply
, summonError
, etc.").