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

Simplified 'provideSomeM' #894

Merged
merged 1 commit into from May 26, 2019

Conversation

andreamarcolin
Copy link
Contributor

This PR aims to simplify the signature of provideSomeM dropping one type variable (R1).

An example of what should be a common scenario when using this API looks like

type MyEnv = FirstModule with SecondModule

def program: ZIO[MyEnv, Throwable, Unit] = ???

def buildEnv: ZIO[FirstModule, Throwable, MyEnv] = ???

where FirstModule and SecondModule (definitions omitted for brevity) are standard ZIO modules as described in this great @jdegoes article

In this case, an attempt to use provideSomeM (e.g. to effectfully build a part of the environment which depends on another part of it) leads to something like this:

program.provideSomeM[FirstModule, Any, Throwable](_ => buildEnv)

or

program.provideSomeM(_: Any => buildEnv)

which is not so clean due to a type variable (R1) which cannot be inferred automatically from buildEnv function (in fact, with R0 AND R1, we have two "environments".

Removing the type variable R1, leads to a cleaner

program.provideSomeM(buildEnv)

This PR originated from a discussion with the community on Gitter, where even @jdegoes was involved:
Schermata 2019-05-23 alle 12 32 33

Copy link
Member

@regiskuckaertz regiskuckaertz left a comment

Choose a reason for hiding this comment

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

Another case of profunctor awesomeness 🎉

Copy link
Member

@jdegoes jdegoes left a comment

Choose a reason for hiding this comment

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

Looks awesome! Thank you!

@jdegoes jdegoes merged commit 766995b into zio:master May 26, 2019
@jdegoes
Copy link
Member

jdegoes commented May 26, 2019

giphy

Thank you for your first contribution to ZIO! 🎉

@andreamarcolin andreamarcolin deleted the simplified-providesomem branch June 19, 2019 05:27
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.

None yet

3 participants