theiterators / sealed-monad Goto Github PK
View Code? Open in Web Editor NEWScala library for nice business logic oriented, for-comprehension-style error handling
License: Apache License 2.0
Scala library for nice business logic oriented, for-comprehension-style error handling
License: Apache License 2.0
Hi,
It would be great to have .void
as alias to .map(_ => ())
The project is currently undocumented - adding descriptions, tips and example (typechecked) usages to functions exposed to the user will be extremely helpful.
I've came across couple of methods missing, e.g.:
noValueOr
noValueOrF
flatTapWhenNot
ensureNotF
We could use an alternative to this function, preferably named ensureF
:
def ensure[ADT](pred: A => Boolean, orElse: => ADT): Sealed[F, A, ADT] = seal[ADT].ensure(pred, orElse)
This could cut off some boilerplate compared to the following usage of attemptF
:
private def setFailed(obj: SomeObj): F[Result] = ???
private def ensureSomething(obj: SomeObj): StepF[Unit] =
transactor
.execute(someDbCall())
.attemptF[Result, Unit] {
case list if !list.exists(_.id != obj.id) => F.pure(Right(()))
case _ =>
setFailed(obj)
.map(result => Left(result))
}
versus potential ensureF
:
private def ensureSomething(obj: SomeObj): StepF[Unit] =
transactor
.execute(someDbCall())
.ensureF(!_.exists(_.id != deployment.id), setFailed(obj))
Similar to #188
Current documentation lives under: https://theiterators.github.io/sealed-monad/ and is very limited. Ideally it should:
Hi,
I have encountered an inconsistency with the order of type parameters in the attemptF
method within which could potentially cause confusion.
final class SealedFAOps {
def attemptF[ADT, B]
}
// When using attemptF:
attemptF[FooResult, Unit]
sealed trait Sealed {
def attemptF[B, ADT1 >: ADT]
}
// When using attemptF:
attemptF[Unit, FooResult]
...or see if it's possible.
As in title, not sure if "effectful" ensure is a good idea ๐คท
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.