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

Interaction with ZLayer #1

Closed
soujiro32167 opened this issue Mar 2, 2023 · 5 comments
Closed

Interaction with ZLayer #1

soujiro32167 opened this issue Mar 2, 2023 · 5 comments

Comments

@soujiro32167
Copy link
Contributor

related to zio/zio-prelude#821

Alas, Izumi tag strikes again!

to reproduce:

import neotype.*
import zio.*


given NonEmptyString: Newtype[String] with
  inline def validate(input: String): Boolean =
    input.nonEmpty

val layer = ZLayer.succeed(NonEmptyString("foo"))

image

@kitlangton
Copy link
Owner

Just tested. I'll need a neotype-zio package for the integration. But it will work. I'll open something tonight!

@kitlangton
Copy link
Owner

  given [A, B](using newType: Newtype.WithType[A, B], tag: Tag[A]): Tag[B] =
    newType.unsafeWrapF(tag)

This makes it work.

@soujiro32167
Copy link
Contributor Author

My hero! This is the same technique as you use to derive other typeclasses (circe, quill) isn't it?

@kitlangton
Copy link
Owner

Update: There are still some issues. It can now derive the tag; however, there are tag materialization issues in some cases due to some widening that the ZLayer macros perform. I'll try and get everything fixed. It'll work for basic things atm.

@kitlangton
Copy link
Owner

After exploring some more recently, I think this needs to be fixed @ the izumi reflect level :(

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

No branches or pull requests

2 participants