-
Notifications
You must be signed in to change notification settings - Fork 113
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
Adding a Free Monad implementation but with a zio.prelude flare #1171
base: series/2.x
Are you sure you want to change the base?
Conversation
…nused imports and variables
* @tparam E - the error type if any | ||
* @tparam A - the result type | ||
*/ | ||
sealed trait ImperativeDsl[Dsl[+_, +_], +E, +A] { self => |
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.
I might call this Imperative
just to make it a little shorter.
onSuccess: A1 => Result[E2, A2], | ||
onFailure: E1 => Result[E2, A2] | ||
): Result[E2, A2] = Result.suspend { | ||
// TODO: Consider if this can be done with foldM since its pissible E1 or E2 is Nothing |
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.
???
} | ||
|
||
// TODO: Consider what can be done to make the type lambda here simpler | ||
implicit def ZPureToExecutable[W] |
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.
No point to the W
parameter here unless you want to add other cases to Imperative
. There is no way to interact with it.
// TODO: Consider what can be done to make the type lambda here simpler | ||
implicit def ZPureToExecutable[W] | ||
: ToExecutable[({ type lambda[+E, +A] = ZPure[W, Unit, Unit, Any, E, A] })#lambda] = { | ||
// ({ type lambda[+E, +A] = ZPure[W, Unit, Unit, Any, E, A] })#lambda |
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.
Delete.
type InFailure <: E | ||
} | ||
|
||
// TODO: Consider what can be done to make the type lambda here simpler |
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.
Use EWriter
or another appropriate ZPure
type alias.
|
||
/** | ||
* An `Imperative[Dsl, E, A]` is a data structure that provides the ability to execute a user provided DSL as a sequence of operations. | ||
* From a theoretical standpoint `ImperativeDsl` is an implementation of a Free Monad.`` |
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.
* From a theoretical standpoint `ImperativeDsl` is an implementation of a Free Monad.`` | |
* From a theoretical standpoint `Imperative` is an implementation of a Free Monad.`` |
Adding a Free Monad structure under the name of
ImperativeDsl
, as discussed with @jdegoes and in #1168