Releases: polyadic/funcky
2.5.0
Reader Monad
This release includes the Reader
monad including a bunch of factory methods
and convenience extensions.
public static Reader<Enviroment, IEnumerable<string>> DefaultLayout(IEnumerable<DateTime> month)
=> from colorizedMonthName in ColorizedMonthName(month)
from weekDayLine in WeekDayLine()
from weeksInMonth in month
.GroupBy(GetWeekOfYear)
.Select(FormatWeek)
.Sequence()
select BuildDefaultLayout(colorizedMonthName, weekDayLine, weeksInMonth);
Improved Action
Extensions
Funcky now supports Curry
, Uncurry
and Flip
for Action
s too.
This release also adds the inversion of ActionToUnit
: UnitToAction
More Extensions for IEnumerable<T>
Intersperse
: Adds a given item in between all items of an enumerable.JoinToString
: Alias forstring.Join
.WithPrevious
: Similar toWithFirst/Last/Index
but with the predecessor of each item.ForEach
: Add an overload toForEach
that accepts aUnit
-returningFunc
.
Additional Factory Methods
EitherOrBoth.FromOptions
creates anEitherOrBoth
from two options.Lazy.FromFunc
creates aLazy<T>
from aFunc
.
This is sugar over theLazy<T>
constructor, with the additional benefit of supporting type inference.Lazy.Return
creates aLazy<T>
from a value.
This is sugar over theLazy<T>
constructor, with the additional benefit of supporting type inference.
Documentation Improvements
This release comes with a few small documentation improvements.
Funcky users will now also see the [Pure]
attributes which were previously not emitted.
2.4.1
2.4.0
Try*
→ *OrNone
We've renamed all Try*
methods, such as TryParse
, TryGet
value to *OrNone
.
The old methods are still available, but marked as obsolete and will be removed in 3.0.0.
Factory methods for IEnumerable<T>
This release adds some new factory methods for creating IEnumerable<T>
to the Sequence
class:
Sequence.RepeatRange
: Generates a sequence that contains the same sequence of elements the given number of timesSequence.Cycle
: Cycles the same element over and over again as an endless generator.Sequence.CycleRange
: Generates a sequence that contains the same sequence of elements over and over again as an endless generatorSequence.Concat
More Extension Methods
for IEnumerable<T>
Materialize
: Materializes all the items of a lazy enumerable.PowerSet
: Returns a sequence with the set of all subsetsShuffle
: Returns the given sequence in random Order in O(n).Split
: Splits the source sequence a separator.ZipLongest
: Zips two sequences with different lengths.
for string
SplitLazy
: Splits a string by separator lazily.SplitLines
: Splits a string by newline lazily.
for Func
Curry
Uncurry
Flip
Compose
EitherOrBoth
EitherOrBoth is a new data type that can represent Left
, Right
and Both
. It is used in ZipLongest
.
Monad.Return
This release adds a Return
method for all monad types in Funcky:
Option.Return
Either<TLeft>.Return
Result.Return
OptionEqualityComparer
To support more advanced comparison scenarios, OptionEqualityComparer
has been added similar to the already existing OptionComparer
.
Smaller Improvements
- Added a missing
Match
overload toEither
that takesAction
s - Added additional overloads for
Functional.True
andFunctional.False
for up to four parameters.
2.3.0
net5.0
has been added to Funcky's target frameworks.
Improvements to Option<T>
Option<T>
is now implicitly convertible fromT
.public static Option<int> Answer => 42;
Option
adds support forSystem.Text.Json
:
The customJsonConverter
is picked up automatically when serializing/deserializing.
None
is serialized asnull
andSome(value)
is serialized to whatevervalue
serializes to.
Factory methods for IEnumerable<T>
This release adds factory methods for creating IEnumerable<T>
with the static class Sequence
:
Sequence.Return
: Creates anIEnumerable<T>
with exactly one item.Sequence.FromNullable
: Creates anIEnumerable<T>
with zero or one items.Sequence.Generate
: Creates anIEnumerable<T>
using a generation function and a seed.
More Extension Methods for IEnumerable<T>
This release adds a bunch of new extension methods on IEnumerable<T>
:
AdjacentGroupBy
AverageOrNone
CartesianProduct
Chunk
ElementAtOrNone
Interleave
MaxOrNone
Merge
MinOrNone
Pairwise
Partition
SlidingWindow
TakeEvery
Transpose
WithFirst
WithIndex
WithLast
IAsyncEnumerable<T>
Support
This release adds a couple of extension methods that provide interoperability
with Option<T>
to IAsyncEnumerable<T>
:
WhereSelect
FirstOrNoneAsync
LastOrNoneAsync
SingleOrNoneAsync
ElementAtOrNoneAsync
A couple of the new extension methods on IEnumerable<T>
have async counterparts:
Pairwise
TakeEvery
The naming of the extension methods and their overloads follows that of System.Linq.Async
.
Improved IQueryable
Support
This release adds specialized extension methods for IQueryable<T>
that are better
suited especially for use with EF Core:
FirstOrNone
LastOrNone
SingleOrNone
Dependencies
To support .NET Standard, Funcky conditionally pulls in dependencies
that provide the missing functionality:
Microsoft.Bcl.AsyncInterfaces
for .NET Standard 2.0System.Collections.Immutable
andSystem.Text.Json
for .NET Standard 2.0 and 2.1- The version constraints for all these packages have been relaxed to allow 5.x.
Improvements
ConfigureAwait(false)
is now used everywhereawait
is used.- The
IRetryPolicy
implementations now use correctTimespan
withdouble
multiplication
when targeting .NET Standard 2.0.
Deprecations
ObjectExtensions.ToEnumerable
has been deprecated in favor ofSequence.FromNullable
.RequireClass
andRequireStruct
have been obsoleted with no replacement.
2.3.0-beta1
Funcky 2.3.0-beta1
Funcky 2.3 is a release with a lot of new Features especially when working intensivly with Linq and Option<T>
Deprecations
ObjectExtensions.ToEnumerable
has been deprecated in favor ofSequence.FromNullable
.
Factory methods for IEnumerable<T>
This release adds factory methods for creating IEnumerable<T>
with the static class Sequence
:
Sequence.Return
: Creates anIEnumerable<T>
with exactly one item.Sequence.FromNullable
: Creates anIEnumerable<T>
with zero or one items.
More Extension Methods for IEnumerable<T>
This release adds a bunch of new extension methods on IEnumerable<T>
:
AdjacentGroupBy
AverageOrNone
CartesianProduct
Chunk
ElementAtOrNone
Interleave
MaxOrNone
Merge
MinOrNone
Pairwise
Partition
SlidingWindow
TakeEvery
Transpose
WithFirst
WithIndex
WithLast
IAsyncEnumerable<T>
Support
This release adds a couple of extension methods that provide interoperability
with Option<T>
to IAsyncEnumerable<T>
:
WhereSelect
FirstOrNoneAsync
LastOrNoneAsync
SingleOrNoneAsync
ElementAtOrNoneAsync
A couple of the new extension methods on IEnumerable<T>
have async counterparts:
Pairwise
TakeEvery
The naming of the extension methods and their overloads follows that of System.Linq.Async
.
Improved IQueryable
Support
This release adds specialized extension methods for IQueryable<T>
that are better
suited especially for use with EF Core:
FirstOrNone
LastOrNone
SingleOrNone
Serialization
Option
adds support for System.Text.Json
:
The custom JsonConverter
is picked up automatically when serializing/deserializing.
None
is serialized as null
and Some(value)
is serialized to whatever value
serializes to.
Dependencies
To support .NET Standard, Funcky conditionally pulls in dependencies
that provide the missing functionality:
Microsoft.Bcl.AsyncInterfaces
for .NET Standard 2.0System.Collections.Immutable
andSystem.Text.Json
for .NET Standard 2.0 and 2.1
Improvements
ConfigureAwait(false)
is now used everywhereawait
is used.- The
IRetryPolicy
implementations now use correctTimespan
withdouble
multiplication
when targeting .NET Standard 2.0.
2.2.0
2.1.1
2.1.0
2.0.0
Breaking Changes
- Remove
Reader
monad based onawait
. - Remove
IToString
. - Remove overload for
Option.From
that flattens passedOption
s. - Move
ToEnumerable
extension method to its own class.
This is only a breaking change if you've used the extension method as normal method.
In that case you need to changeEnumerableExtensions.ToEnumerable
toObjectExtensions.ToEnumerable
. - Rename
Option.From
toOption.FromNullable
and remove overload that takes non-nullable value types. - Unify
Option<T>.ToEnumerable
andYield
toToEnumerable
- Rename
OrElse
overloads that return the item toGetOrElse
which improves overload resolution. - The
Each
extension method onIEnumerable<T>
has been renamed toForEach
. - Move the
Ok
constructor ofResult<T>
to a non-generic class. This allows for the compiler to infer the generic type.
Old:Result<int>.Ok(10)
. New:Result.Ok(10)
. - Use
Func<T, bool>
instead ofPredicate<T>
in predicate composition functions (Functional.All
,Functional.Any
,Functional.Not
),
because most APIs inSystem
useFunc
. Functional.Any
now returnsfalse
when the given list of predicates is empty.
Fixes
- Fix incorrect
Equals
implementation onOption
.
Equals
previously returnedtrue
when comparing aNone
value with aSome
value containing the default value of the type. Exception
created byResult
monad contains valid stack trace- Fix incorrect implementation on
Result.SelectMany
which called theselectedResultSelector
even when the
result was an error. As a result (pun intended) of the fix,ResultCombinationException
is no longer needed and also removed.
Additions
- Add
IndexOfOrNone
,LastIndexOfOrNone
,IndexOfAnyOrNone
andLastIndexOfAnyOrNone
extension methods tostring
. - Added
Curry
,Uncurry
andFlip
to theFunctional
Class - Add extension method for
HttpHeaders.TryGetValues
, which returns anOption
. - Add extension methods for getting
Stream
properties that are not always available, asOption
:
GetLengthOrNone
,GetPositionOrNone
,GetReadTimeoutOrNone
,GetWriteTimeoutOrNone
. - Add
None
extension method toIEnumerable
. Option<Task<T>>
,Option<Task>
and theirValueTask
equivalents are now awaitable:var answer = await Option.Some(Task.FromResult(42));
Improvements
- Full nullable support introduced with C# 8.
- Mark our functions as
[Pure]
. - Implement
IEquatable
onOption
,Result
andEither
.
2.0.0-rc.2
- Move the
Ok
constructor ofResult<T>
to a non-generic class. This allows for the compiler to infer the generic type.
Old:Result<int>.Ok(10)
. New:Result.Ok(10)
. - Add
IndexOfOrNone
,LastIndexOfOrNone
,IndexOfAnyOrNone
andLastIndexOfAnyOrNone
extension methods tostring
. - Rename
OrElse
overloads that return the item toGetOrElse
which improves overload resolution. - Added
Curry
,Uncurry
andFlip
to theFunctional
Class - Remove
IToString
. - Mark our functions as
[Pure]
. - Fix incorrect implementation on
Result.SelectMany
which called theselectedResultSelector
even when the
result was an error. As a result (pun intended) of the fix,ResultCombinationException
is no longer needed and also removed.