zio / zio-prelude

A lightweight, distinctly Scala take on functional abstractions, with tight ZIO integration
https://zio.dev/zio-prelude
Apache License 2.0
441 stars 112 forks source link

Composition of data structures #628

Open regiskuckaertz opened 3 years ago

regiskuckaertz commented 3 years ago

I need to read how you define newtypes, but this data types:

case class Compose[F[+_], G[+_], +A](fga: F[G[A]])

is IdentityBoth, ForEach, etc. if its two underlying containers are. I will define this in my codebase but happy to contribute it if this sounds interesting.

adamgfraser commented 3 years ago

I think we definitely want to have a solution for these composed abstractions. We already have some work in this direction, for example the compose operator on AssociativeBoth, but I'm not sure this provides the ergonomics since I don't think you would be able to use it implicitly. Perhaps a new type version of the above would be the best solution.