Skip to content
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

Draft
wants to merge 9 commits into
base: series/2.x
Choose a base branch
from

Conversation

DamianReeves
Copy link
Collaborator

Adding a Free Monad structure under the name of ImperativeDsl, as discussed with @jdegoes and in #1168

* @tparam E - the error type if any
* @tparam A - the result type
*/
sealed trait ImperativeDsl[Dsl[+_, +_], +E, +A] { self =>
Copy link
Contributor

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
Copy link
Contributor

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]
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* From a theoretical standpoint `ImperativeDsl` is an implementation of a Free Monad.``
* From a theoretical standpoint `Imperative` is an implementation of a Free Monad.``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants