language-ext v3.3.19 Release Notes
Release Date: 2019-08-21 // over 4 years ago-
Reader
The
Reader
monad now has more advanced error handling (which is also reflected in the code-gen that wraps theReader
monad).๐ This means
Reader<Env, A>.Run(env)
now returnsReaderResult<A>
instead ofTryOption<A>
. I have also removedFilter
andWhere
fromReader
and instead you should use:from x in success? Reader\<Env, A\>(successValue) : ReaderFail\<Env, A\>("Fail message") ...
Filter
andWhere
would return a result in aBottom
state, which isn't ideal. Obviously if you need this functionality back then you can create the extension methods yourself to create a similar functionality:public static Reader\<Env, A\> Where\<Env, A\>(this Reader\<Env, A\> ma, Func\<A, bool\> f) =\>ma.Bind(a =\> f(a) ? Reader\<Env, A\>(a) : ReaderFail\<Env, A\>(BottomException.Default));
Fail states can be created using:
ReaderFail\<Env, A\>(string message); ReaderFail\<Env, A\>(string message, Exception exception); ReaderFail\<Env, A\>(Exception exception);
ReaderResult
ReaderResult<A>
hasMatch
andIfNone
(so replace previous usage ofIfNoneOrFail
withIfNone
). It also has conversion methods:ToSeq()
,ToList()
,ToOption()
,ToOptionUnsafe()
,ToOptionAsync()
,ToEither()
,ToEither(Func<Error, L> f)
,ToEitherUnsafe()
,ToEitherUnsafe(Func<Error, L> f)
,ToEitherAsync()
,ToEitherAsync(Func<Error, L> f)
,ToTry()
,ToTryAsync()
Error
๐ป To facilitate the better error handling I needed to add a new
Error
type. The chances of this clashing with user's code is large, so it has been put into a new namespace:LanguageExt.Common
. It can hold a message, a status valueint
, and anException
.Result
๐ It seems to me that
Result
,OptionalResult
, andError
belong in the same namespace soResult
andOptionalResult
have been moved toLanguageExt.Common
.๐ On the whole you shouldn't really see
Error
orResult
, most of the time you'll just be doing member access - and so the need to include theLanguageExt.Common
should be rare.