Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. diff --git a/core/shared/src/main/scala/scalaz/zio/clock/package.scala b/core/shared/src/main/scala/scalaz/zio/clock/package.scala
  2. index 5691082e..33cfcb61 100644
  3. --- a/core/shared/src/main/scala/scalaz/zio/clock/package.scala
  4. +++ b/core/shared/src/main/scala/scalaz/zio/clock/package.scala
  5. @@ -17,28 +17,37 @@
  6. package scalaz.zio
  7.  
  8. import scalaz.zio.duration.Duration
  9. -
  10. import java.util.concurrent.TimeUnit
  11.  
  12. -package object clock extends Clock.Service[Clock] {
  13. - final val clockService: ZIO[Clock, Nothing, Clock.Service[Any]] =
  14. - ZIO.access(_.clock)
  15. -
  16. - /**
  17. - * Returns the current time, relative to the Unix epoch.
  18. - */
  19. - final def currentTime(unit: TimeUnit): ZIO[Clock, Nothing, Long] =
  20. - ZIO.accessM(_.clock currentTime unit)
  21. -
  22. - /**
  23. - * Returns the system nano time, which is not relative to any date.
  24. - */
  25. - final val nanoTime: ZIO[Clock, Nothing, Long] =
  26. - ZIO.accessM(_.clock.nanoTime)
  27. -
  28. - /**
  29. - * Sleeps for the specified duration. This is always asynchronous.
  30. - */
  31. - final def sleep(duration: Duration): ZIO[Clock, Nothing, Unit] =
  32. - ZIO.accessM(_.clock sleep duration)
  33. +package object clock {
  34. + final val clockService:ZIO[Clock, Nothing, Clock.Service[Any]] = clockPackage.clockService
  35. + final def currentTime(unit: TimeUnit): ZIO[Clock, Nothing, Long] = clockPackage.currentTime(unit)
  36. + final val nanoTime: ZIO[Clock, Nothing, Long] = clockPackage.nanoTime
  37. + final def sleep(duration: Duration): ZIO[Clock, Nothing, Unit] = clockPackage.sleep(duration)
  38. +
  39. +
  40. + private object clockPackage extends Clock.Service[Clock] {
  41. + final val clockService: ZIO[Clock, Nothing, Clock.Service[Any]] =
  42. + ZIO.access(_.clock)
  43. +
  44. + /**
  45. + * Returns the current time, relative to the Unix epoch.
  46. + */
  47. + final def currentTime(unit: TimeUnit): ZIO[Clock, Nothing, Long] =
  48. + ZIO.accessM(_.clock currentTime unit)
  49. +
  50. + /**
  51. + * Returns the system nano time, which is not relative to any date.
  52. + */
  53. + final val nanoTime: ZIO[Clock, Nothing, Long] =
  54. + ZIO.accessM(_.clock.nanoTime)
  55. +
  56. + /**
  57. + * Sleeps for the specified duration. This is always asynchronous.
  58. + */
  59. + final def sleep(duration: Duration): ZIO[Clock, Nothing, Unit] =
  60. + ZIO.accessM(_.clock sleep duration)
  61. + }
  62. +
  63. }
  64. +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement