-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure DSL for Exacts #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work @ustits! 👏 Can't wait to use it in my projects
I support the name change to ensure
to keep it consistent with Arrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks super awesome @ustits 🙌 Great work, I only have two small nits, so I am going to approve. We can update or change them later if we want to
Feel free to merge 🥳
PS: Not much to know about Knit, it seems you did great otherwise the build would've failed. It just makes sure that the code examples we write are valid. Then you run ./gradlew knit
to update the tests or it fails on CI saying the knit is outdated.
override fun from(value: A): Either<E, R> = either { construct(ExactScope(value, this)) } | ||
} | ||
|
||
public class ExactScope<A, E : Any>(public val raw: A, private val raise: Raise<E>) : Raise<E> by raise { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public class ExactScope<A, E : Any>(public val raw: A, private val raise: Raise<E>) : Raise<E> by raise { | |
public class ExactScope<A, E : Any>(public val raw: A, raise: Raise<E>) : Raise<E> by raise { |
Don't think this needs to be captured in case of delegation, right? 🤔
object : Exact<A, R> { | ||
override fun from(value: A): Either<ExactError, R> = either { construct(ExactScope(value, this)) } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exact
can be a fun interface
that I look at it like this. It will be more performant, and look slightly better here.
object : Exact<A, R> { | |
override fun from(value: A): Either<ExactError, R> = either { construct(ExactScope(value, this)) } | |
} | |
Exact { value -> either { construct(ExactScope(value, this)) } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, also will change ExactEither
Thank you @ustits 🙌 |
ensure
dsl forExact
arrow.exact
by my mistake)Decided to use
ensure
instead ofrefine
, I think it will be better for users to have consistent naming throughout all Arrow modules.ensure
accepts otherExact
so now it must be easier to combine them.The only problem is that I am not quite familiar with knit and probably have made something wrong, @nomisRev please fix me in that case 🙏
Feel free to change this PR!