Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@TheMayoras
Copy link
Contributor

I have not added Scaladoc links, moved traits to ZIO companion object, or organized in alphabetical order yet.

@jdegoes
Copy link
Member

jdegoes commented Apr 27, 2019

@TheMayoras

The pull request contains a lot of files that shouldn't be there. I think maybe the IDE added them.

Anyway, before I review, could you remove the following files from the pull request:

  • All .class files / directories
  • All .project files / directories
  • All .classpath files / directories
  • All .settings files / directories

I think that'll clean it up quite a lot. 😅

@TheMayoras
Copy link
Contributor Author

@jdegoes My most recent commit has the files removed.

@AshishPrasad
Copy link

@TheMayoras

The diff still contain .prefs and other non-scala files.

Probably, it is better to only include .scala files for this pull request.

@LGLO
Copy link
Contributor

LGLO commented Apr 29, 2019

@TheMayoras
Take a look at diff here. It still contains a lot of changes.
I guess exit file should be removed and sbt fmt should be run.

@TheMayoras
Copy link
Contributor Author

@jdegoes @AshishPrasad I ran sbt fmt and removed a lot of extraneous files. Hopefully it is a bit better. Sorry for all the problems 😅

@AshishPrasad
Copy link

AshishPrasad commented Apr 29, 2019

@TheMayoras the exit file should not be added.

Also, microsite files should not be deleted.


I think, you can run git show --name-status and ensure only the intended files (typically .scala files) are added to the pull request.

@jdegoes
Copy link
Member

jdegoes commented Apr 30, 2019

@TheMayoras Git is quite the beast to tame, don't let it stress you too much, and please give a holler if anything seems confusing.


def testAsyncIOEffectReturns =
unsafeRun(IO.effectAsyncM[Any, Throwable, Int](k => IO.effectTotal(k(IO.succeed(42))))) must_=== 42
unsafeRun(IO.effectAsyncM[Throwable, Int](k => IO.effectTotal(k(IO.succeed(42))))) must_=== 42
Copy link
Member

Choose a reason for hiding this comment

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

This are some really nice cleanups!

// ALL error types in this trait must be a subtype of `UpperE`.
// TAKEN FROM ZIO_E_THROWABLE
// ALL environment types in this trait must be a supertype of `LowerR`.
type IoR = Any
Copy link
Member

Choose a reason for hiding this comment

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

I'd delete this, I don't think you need it anymore, or all the temporary comments above and below.


/** Accesses the whole environment of the effect.
*/
final def environment: ZIO[IoR, Nothing, IoR] = ZIO.access(ZIO.identityFn[IoR])
Copy link
Member

Choose a reason for hiding this comment

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

Since we know IoR will be Any, we can delete environment, as it is not useless for the IO type.

* val portNumber = effect.access(_.config.portNumber)
* }}}
*/
final def access: ZIO.AccessPartiallyApplied[IoR] =
Copy link
Member

Choose a reason for hiding this comment

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

Ditto for this, we know R = Any, so we can delete this method, since it won't be useful for IO.


/** Effectfully accesses the environment of the effect.
*/
final def accessM: ZIO.AccessMPartiallyApplied[IoR] =
Copy link
Member

Choose a reason for hiding this comment

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

Ditto for this, we know R = Any, so we can delete this method, since it won't be useful for IO.

* This is similar to dependency injection, and the `provide` function can be
* thought of as `inject`.
*/
final def provide[E, A](r: IoR): ZIO[IoR, E, A] => IO[E, A] =
Copy link
Member

Choose a reason for hiding this comment

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

Ditto for this, we know R = Any, so we can delete this method, since it won't be useful for IO.

* (unsafely) execute tasks. This is useful for integration with
* non-functional code that must call back into functional code.
*/
final def runtime: ZIO[IoR, Nothing, Runtime[IoR]] = ZIO.runtime
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using ZIO[IoR, ..., try: IO[..., i.e. omit the R parameter entirely by using the IO type synonym.

In fact, that can help keep this file on track: all the effect types will be IO or weaker (e.g. UIO for finalizers, etc.).

* This method can be used for terminating a fiber because a defect has been
* detected in the code.
*/
final def die(t: Throwable): UIO[Nothing] = ZIO.die(t)
Copy link
Member

Choose a reason for hiding this comment

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

I'd delete all the comments in this file, later we can just link to ZIO documentation using the Scaladoc linking support:

/**
 * See [[scalaz.zio.ZIO.die]]
 */

* stack. Manual use of this method can improve fairness, at the cost of
* overhead.
*/
final val yieldNow: UIO[Unit] = ZIO.Yield
Copy link
Member

Choose a reason for hiding this comment

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

For all these files, try just to delegate to ZIO methods, not any of the data constructors directly.

* composite fiber that produces unit. This version is faster than [[forkAll]]
* in cases where the results of the forked fibers are not needed.
*/
final def forkAll_[E, A](as: Iterable[ZIO[IoR, E, A]]): ZIO[IoR, Nothing, Unit] =
Copy link
Member

Choose a reason for hiding this comment

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

Remember to replace all the ZIO[IoR, ... in this file with IO[....

final def await: IO[E, A] =
IO.effectAsyncInterrupt[Any, E, A](k => {
var result = null.asInstanceOf[Either[Canceler, IO[E, A]]]
final def await: IO[Any, E, A] =
Copy link
Member

Choose a reason for hiding this comment

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

This is a typo, IO will only support 2 type parameters E and A, not the R type parameter. Same as below.

def apply[A](a: => A): Task[A] = effect(a)

type TaskE = Throwable
type TaskR = Any
Copy link
Member

Choose a reason for hiding this comment

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

I'd delete:

  1. All the temp comments
  2. The type aliases for TaskE and TaskR
  3. Scaladoc for all the functions (instead, we can link to ZIO sScaladoc)

* The moral equivalent of `throw` for pure code.
* [[scalaz.zio.ZIO.fail]]
*/
final def fail(error: TaskE): IO[TaskE, Nothing] = ZIO.fail(error)
Copy link
Member

Choose a reason for hiding this comment

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

Replace all IO[???, A] in this file by Task[A], and delete all the environmental functions (provide, accessM, access, environment, etc.), because R = Any, they won't be useful.

*
* [[scalaz.zio.ZIO.runtime]]
*/
final def runtime: ZIO[TaskR, Nothing, Runtime[TaskR]] = ZIO.runtime
Copy link
Member

Choose a reason for hiding this comment

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

I'd replace all the ZIO[TaskR, ...] by either Task (if the error is Throwable) or UIO (if the error is Nothing).

*/
object TaskR {

type TaskrE = Throwable
Copy link
Member

Choose a reason for hiding this comment

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

As in the other cases, I'd delete:

  1. All the temp comments.
  2. The TaskrE and TaskR type synonyms
  3. All the Scaladoc (instead link to ZIO Scaladoc)

/** Returns an effect that models failure with the specified error.
* The moral equivalent of `throw` for pure code.
*/
final def fail(error: TaskrE): IO[TaskrE, Nothing] = ZIO.fail(error)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of IO[TaskrE, ...], use Task[...] everywhere in this file.


/** Accesses the whole environment of the effect.
*/
final def environment[R]: ZIO[R, Nothing, R] = ZIO.access(ZIO.identityFn[R])
Copy link
Member

Choose a reason for hiding this comment

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

We don't really have a type alias for the combination but I see it a lot... we can fix it later.

* This is similar to dependency injection, and the `provide` function can be
* thought of as `inject`.
*/
final def provide[R, A](r: R): ZIO[R, TaskrE, A] => IO[TaskrE, A] =
Copy link
Member

Choose a reason for hiding this comment

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

Replace ZIO[R, TaskrE, ...] by TaskR[R, ...] in this whole file.

@jdegoes
Copy link
Member

jdegoes commented Jul 13, 2019

@TheMayoras

Is sandbox a ZIO trait function?

Yes, although I thought it was a ZIO.* (companion object) method too.

Also, are Task and TaskR allowed to have unsandbox? The method requires a Cause[Throwable], but the type alias is for Throwable

Yes, they are allowed to have unsandbox, and they return Cause[Throwable] (for both Task and TaskR, E = Throwable).

@TheMayoras
Copy link
Contributor Author

@jdegoes

As far as I can tell, sandbox is currently only in the ZIO trait.

Also, I get type errors when adding unsandbox to the Task types. The input parameter requires ZIO[..., Cause[Throwable], ...]

I'm trying to fix a weird doc bug at the moment. It's giving me am ambiguous link for the bracket and bracketExit methods in the companion objects. I'm looking into it, but I cannot get it working (as you can probably tell from my 100000 commits recently)

@jdegoes
Copy link
Member

jdegoes commented Jul 13, 2019

As far as I can tell, sandbox is currently only in the ZIO trait.

All right, we can ignore it, then, we only need to worry about the ZIO.* object methods.

I'm trying to fix a weird doc bug at the moment. It's giving me am ambiguous link for the bracket and bracketExit methods in the companion objects. I'm looking into it, but I cannot get it working (as you can probably tell from my 100000 commits recently)

I will try to help tomorrow. Family day today!

@TheMayoras
Copy link
Contributor Author

@jdegoes

So everything seems to be working well except for the docs.

Besides that, I think everything is finished.

@jdegoes
Copy link
Member

jdegoes commented Jul 15, 2019

@TheMayoras Awesome work! 🎉

I had a chance to look at the mdoc errors:

[error] /home/circleci/project/core/shared/src/main/scala/zio/UIO.scala:30:3: The link target "zio.ZIO$.bracket" is ambiguous. Several members fit the target:
[error] [R, E, A, B](acquire: zio.ZIO[R,E,A],release: A => zio.ZIO[R, Nothing, _],use: A => zio.ZIO[R,E,B]): zio.ZIO[R,E,B] in object ZIO [chosen]
[error] [R, E, A](acquire: zio.ZIO[R,E,A]): zio.ZIO.BracketAcquire[R,E,A] in object ZIO
[error] 
[error] 
[error] Quick crash course on using Scaladoc links
[error] ==========================================
[error] Disambiguating terms and types: Prefix terms with '$' and types with '!' in case both names are in use:
[error]  - [[scala.collection.immutable.List!.apply class List's apply method]] and
[error]  - [[scala.collection.immutable.List$.apply object List's apply method]]
[error] Disambiguating overloaded members: If a term is overloaded, you can indicate the first part of its signature followed by *:
[error]  - [[[scala.collection.immutable.List$.fill[A](Int)(⇒A):List[A]* Fill with a single parameter]]]
[error]  - [[[scala.collection.immutable.List$.fill[A](Int,Int)(⇒A):List[List[A]]* Fill with a two parameters]]]
[error] Notes:
[error]  - you can use any number of matching square brackets to avoid interference with the signature
[error]  - you can use \\. to escape dots in prefixes (don't forget to use * at the end to match the signature!)
[error]  - you can use \\# to escape hashes, otherwise they will be considered as delimiters, like dots.
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/UIO.scala:24:3: The link target "zio.ZIO$.bracket" is ambiguous. Several members fit the target:
[error] [R, E, A, B](acquire: zio.ZIO[R,E,A],release: A => zio.ZIO[R, Nothing, _],use: A => zio.ZIO[R,E,B]): zio.ZIO[R,E,B] in object ZIO [chosen]
[error] [R, E, A](acquire: zio.ZIO[R,E,A]): zio.ZIO.BracketAcquire[R,E,A] in object ZIO
[error] 
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/UIO.scala:42:3: The link target "zio.ZIO$.bracketExit" is ambiguous. Several members fit the target:
[error] [R, E, A, B](acquire: zio.ZIO[R,E,A],release: (A, zio.Exit[E,B]) => zio.ZIO[R, Nothing, _],use: A => zio.ZIO[R,E,B]): zio.ZIO[R,E,B] in object ZIO [chosen]
[error] [R, E, A](acquire: zio.ZIO[R,E,A]): zio.ZIO.BracketExitAcquire[R,E,A] in object ZIO
[error] 
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/UIO.scala:36:3: The link target "zio.ZIO$.bracketExit" is ambiguous. Several members fit the target:
[error] [R, E, A, B](acquire: zio.ZIO[R,E,A],release: (A, zio.Exit[E,B]) => zio.ZIO[R, Nothing, _],use: A => zio.ZIO[R,E,B]): zio.ZIO[R,E,B] in object ZIO [chosen]
[error] [R, E, A](acquire: zio.ZIO[R,E,A]): zio.ZIO.BracketExitAcquire[R,E,A] in object ZIO
[error] 
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/TaskR.scala:46:3: Could not find any member to link for "zio.ZIO$.bracket[R,".
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/TaskR.scala:40:3: Could not find any member to link for "zio.ZIO$.bracket[R,".
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/TaskR.scala:61:3: Could not find any member to link for "zio.ZIO$.bracketExit[R,".
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/TaskR.scala:55:3: Could not find any member to link for "zio.ZIO$.bracketExit[R,".
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/Task.scala:32:3: Could not find any member to link for "zio.ZIO$.bracket[R,".
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/Task.scala:26:3: Could not find any member to link for "zio.ZIO$.bracket[R,".
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/Task.scala:44:3: Could not find any member to link for "zio.ZIO$.bracketExit[R,".
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/Task.scala:38:3: Could not find any member to link for "zio.ZIO$.bracketExit[R,".
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/IO.scala:32:3: Could not find any member to link for "zio.ZIO$.bracket[R,".
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/IO.scala:26:3: Could not find any member to link for "zio.ZIO.bracket[R,".
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/IO.scala:44:3: The link target "zio.ZIO$.bracketExit" is ambiguous. Several members fit the target:
[error] [R, E, A, B](acquire: zio.ZIO[R,E,A],release: (A, zio.Exit[E,B]) => zio.ZIO[R, Nothing, _],use: A => zio.ZIO[R,E,B]): zio.ZIO[R,E,B] in object ZIO [chosen]
[error] [R, E, A](acquire: zio.ZIO[R,E,A]): zio.ZIO.BracketExitAcquire[R,E,A] in object ZIO
[error] 
[error]   /**
[error]   ^
[error] /home/circleci/project/core/shared/src/main/scala/zio/IO.scala:38:3: The link target "zio.ZIO$.bracketExit" is ambiguous. Several members fit the target:
[error] [R, E, A, B](acquire: zio.ZIO[R,E,A],release: (A, zio.Exit[E,B]) => zio.ZIO[R, Nothing, _],use: A => zio.ZIO[R,E,B]): zio.ZIO[R,E,B] in object ZIO [chosen]
[error] [R, E, A](acquire: zio.ZIO[R,E,A]): zio.ZIO.BracketExitAcquire[R,E,A] in object ZIO
[error] 
[error]   /**
[error]   ^
[error] 16 errors found
[error] (coreJVM / Compile / doc) Scaladoc generation failed
[error] Total time: 39 s, completed Jul 14, 2019 10:16:45 PM
Exited with code 1

Here's what's happening: when linking to the ZIO object methods, via [[methodReference]] inside the Scaladoc of the UIO / TaskR / Task / IO companion objects, the documentation compiler finds multiple methods with the same name, and does not know which one to link to.

To disambiguate them, we can specify more details, like the above error message suggests.

Something like this should do the trick:

[[[zio.ZIO$.bracket[R, E, A](zio.ZIO[R,E,A]): zio.ZIO.BracketAcquire[R,E,A] ]]]

You might have to play around to get the syntax exactly right.

@TheMayoras
Copy link
Contributor Author

@jdegoes

So I tried adding more details (like See [[[[zio.ZIO.bracket[R, E, A, B]*]]]]). It always returns:

@TheMayoras
Copy link
Contributor Author

@jdegoes

So I tried adding See [[[[zio.ZIO.bracket[R, E, A, B]*]]]], but it always bring back:
Could not find any member to link for "zio.ZIO$.bracket[R,".
I feel like I'm not entering it correctly, but I found it from here.

@TheMayoras
Copy link
Contributor Author

Also, the tests seem to pass most of the time. The failing jdk11 test passes most of the time.

@jdegoes
Copy link
Member

jdegoes commented Jul 15, 2019

@TheMayoras How about for now, you just say:

see `ZIO.bracket`

and not use a Scaladoc link?

Don't worry about the flaky tests, they are not caused by this PR. 😄

@TheMayoras
Copy link
Contributor Author

@jdegoes

I will fix it up when I get home at 6!

Thank you so much for all of your help. I'm sure it's taken me longer than it should have, so thank you for your patience and help!

@jdegoes
Copy link
Member

jdegoes commented Jul 15, 2019

@TheMayoras It's been a pleasure, and thank you for your help!

@@ -0,0 +1,91 @@
package zio.interop.reactiveStreams
Copy link
Member

Choose a reason for hiding this comment

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

This file can be removed as it was moved to a separate repo

@TheMayoras
Copy link
Contributor Author

@jdegoes

It looks like the only failing test is that flaky Timeout error.

@jdegoes jdegoes merged commit f6c883d into zio:master Jul 16, 2019
@jdegoes
Copy link
Member

jdegoes commented Jul 16, 2019

@TheMayoras Thanks for your immense work on this mega-project, and your patience sorting through all the details. And congratulations on your first ZIO pull request!

giphy

@TheMayoras
Copy link
Contributor Author

@jdegoes

Thank you so much! It's been a journey, and I was more than a little scared to start with. You are a saint for helping me so much!

ghostdogpr pushed a commit to ghostdogpr/scalaz-zio that referenced this pull request Jul 26, 2019
…o#805)

* message

* done

* class, classpath, project, settings removed

* removed a lot of unnecessary files

* sbt fmt run

* Most method parameters have been changed to IO, UIO, Task, or TaskR.  Methods organized alphabetically.  Hopefully all other files were deleted.

* .Project file removed

* Scaladoc reformatted. Better return types for specific type aliases

* .gitignore improved

* Finished?

* Conflicts Resolved?

* conflicts turned back

* Zio.scala sorted

* gitignore improved?

* gitignore improved? V2

* .gitignore. removed?

* Issues with missing Classes and Functions

* Ready?

* Clone current file.  Move all ZIO functions into ZIOFunctions.  Moving all functions into object ZIO causes compilation errors.  UIO, IO, Task, TaskR were copied into new clone

* IO got interruptChildren

* Inferred to Any errors fixed

* ZIO.scala organized

* grabbed changes from redone repo

* Compiling after Merge.  'fmt' run.  'Docusaurus' throwing error about 'Cannot run program 'yarn''

* sbt fmt

* Generalized mapAccumM signature zio#1029 (zio#1037)

* Generalized mapAccumM signature

* Fixed weird compiler error with explicit type parameters

* Update util-core to 19.6.0 (zio#1039)

* Update fs2-core to 1.0.5 (zio#1000)

* Resolve ( zio#952 - Add links to resources) and fix documentation for effectBlockingCancelable (zio#978)

* Resolves "Add user provided canceler to effectBlocking" (zio#966)

 * Add new effectBlockingCancelable method to blocking API
 * Add tests & documentation

* Fix documentatation for effectBlockingCancelable and Add more resources to resources page (zio#952)

 * Add link to https://freskog.github.io/blog/2019/05/30/explore-zio-stm/
 * Add link to https://github.com/freskog/stm-partitioning
 * Correct documentation for effectBlockingCancelable

* DRY the build (zio#1019)

* DRY the build

Bring back JDK11 into build matrix

* Disable Dotty builds

* Apparently, apt runs on Ubuntu after bootup

* Implement TracingStatus without bracket to fix a bug found in https://github.com/zio/zio/pull/1041/files#r295777382 (zio#1047)

* Update sbt-dotty to 0.3.3 (zio#1042)

* Update sbt-bloop to 1.3.2 (zio#1043)

* Update sbt-microsites to 0.9.1 (zio#1044)

* Update sbt-mdoc to 1.2.10 (zio#1045)

* Return null guard for tracingStatus removed in zio#1047 (zio#1051)

* Fix release errors (zio#1050)

* Fix zio#987 Disable inlining during non-release builds (zio#1054)

* Speed up builds (zio#1055)

* Preserve errors in bracketExit when release dies (zio#1041)

Similar to how `ensuring` works, we accumulate both errors in
case `use` failed and `release` died.

* Update rxjava to 2.2.10 (zio#1052)

* Update sbt-mdoc to 1.3.1 (zio#1053)

* Restore build on tags (zio#1056)

* Restore build on tags

* Fix syntax

* Remove sneaky \t

* Fix yarn install (zio#1057)

* Fix yarn install (zio#1057) (zio#1058)

* Fix yarn install (zio#1059)

* Upgrade nodejs (zio#1060)

* Upgrade nodejs (zio#1061)

* Hold onto slippery fibers (zio#1063)

* Hold onto slippery fibers

* fmt

* Fix typo in docs: aa -> a (zio#1066)

* Fix node and yarn related issues for publishing microsite via circleci (zio#1068)

* Fix node and yarn related issues for publishing microsite via circleci

* Add nvm

* Add nvm settings

* Update dotty (zio#1062)

* Cross compile using dotty

* Fix dotty compilation errors

* WIP: disable scala2 macros

* Fix dotty compilation error in tests

* Fix broken links in contributing docs (zio#1067)

* sbt fmt run

* sbt fmt run

* Pulled in 6-24-19 9:21

* .sbtopts reverted back to the zio's heap size

* Pulled in ignore and parallelErrors

* Test errors fixed in IOSPec and RTSSSpec.  fmt run

* removed un-needed .idea, yarn.lock, node_modules

* onInterrupt cleanup changed to ZIO[R1, Nothing, Any]

* git pull.  All files checked for missing methods.  Explicit type paramater added to ZManageSpec.scala:210 in order to suppress compile error 'Type inferred to be

* Disambiguated IO, Task, TaskR, UIO bracket and bracketExit ScalaDoc links

* Fixed ScalaDoc links V2?

* Fixed ScalaDoc links V3?

* Fixed ScalaDoc links V4?

* Fixed ScalaDoc links V5?

* Fixed ScalaDoc links V6?

* Testing different ScalaDoc links?

* Testing different ScalaDoc links 2?

* Testing different ScalaDoc links 3?

* Testing different ScalaDoc links 4?

* Testing different ScalaDoc links 5?

* Change to @see annotation in companion objects

* Removed ScalaDoc links to bracket and bracketExit.  QueueSubscriber removed from interop-reactiveStreams

* fmt run
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.