-
Notifications
You must be signed in to change notification settings - Fork 603
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
A Stream can pull anything. #1757
Conversation
A `Stream[F, O]` is defined as a wrap on a `FreeC[F, O, Unit]`. The Unit type indicates, in types, that the "Result" type of the FreeC computation that would yield the stream is of no consequence: a Stream is a complete FreeC on its own, and its result is of no matter. We can also express that idea, in types, by marking that return type as an `Any`, the top type, which is another way to indicate that no useful information can come off the Result of the inner FreeC. One benefit is that we do not need spurious conversions on the FreeC object just to convert it back-and-forth a Stream: Any thing will do. To avoid problems with the Any poly-kindness, and much like with the INothing alias, we use a special IAny alias of Any for the types.
FreeC[F, O, IAny]
FreeC[F, O, IAny]
FreeC[F, O, IAny]
FreeC[F, O, Any]
FreeC[F, O, Any]
val _ = ev | ||
new Stream(free.asInstanceOf[FreeC[F, O, Unit]]) | ||
} | ||
def stream: Stream[F, O] = new Stream(free) |
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'm generally 👎 on removing the R <:< Unit
requirement here as requiring that evidence has exposed bugs where the remainder was not dealt with correctly.
/** | ||
* Alias for `Any` which may work better with type inference. | ||
*/ | ||
type IAny >: Any |
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.
If we were to go this way, I don't think we need IAny
as scalac doesn't treat Any
special from type inference perspective.
Not sure about this one. Would like to hear from other contributors. API-wise, I'm concerned about the ability to convert any pull to a stream, which seems like a regression considering we recently added the |
This is a torny issue in general (consider Also, I would only use |
All right. That makes this PR no longer useful. |
A
Stream[F, O]
is defined as a wrap on aFreeC[F, O, Unit]
. The Unit type indicates that the "Result" of theFreeC
computation that produces the stream has no relevant information: all that matters of the Stream is the output.We can also express that idea by marking that return type as an
Any
, the top type, which is another way to indicate that no useful information can come off the Result of the innerFreeC
. One benefit is that we do not need the spurious conversions of theFreeC
withvoid
, just to wrap it back into a Stream.