Skip to content

Commit

Permalink
Merge pull request #422 from 47degrees/fix/compiler-warnings-2020-01-13
Browse files Browse the repository at this point in the history
Fix compiler warnings across project
  • Loading branch information
sloshy authored Jan 15, 2021
2 parents db771e0 + b214738 commit 66b1cf6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions fetch-debug/src/main/scala/document.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class Document {
* Format this document on `writer` and try to set line
* breaks so that the result fits in `width` columns.
*/
def format(width: Int, writer: Writer) {
def format(width: Int, writer: Writer): Unit = {
type FmtState = (Int, Boolean, Document)

def fits(w: Int, state: List[FmtState]): Boolean =
Expand All @@ -67,7 +67,7 @@ abstract class Document {
fits(w, (i, false, d) :: z)
}

def spaces(n: Int) {
def spaces(n: Int): Unit = {
var rem = n
while (rem >= 16) { writer write " "; rem -= 16 }
if (rem >= 8) { writer write " "; rem -= 8 }
Expand Down
18 changes: 10 additions & 8 deletions fetch-examples/src/test/scala/GithubExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ class GithubExample extends AnyWordSpec with Matchers {
val url = GITHUB / "repos" / owner / repo +? ("access_token", ACCESS_TOKEN)
val req = Request[F](Method.GET, url)
for {
result <- c.fetch[Repo](req)({
case Status.Ok(res) =>
res.as[Repo]
case res =>
CF.raiseError(new Exception(res.body.toString))
})
result <- c
.run(req)
.use[F, Repo] {
case Status.Ok(res) =>
res.as[Repo]
case res =>
CF.raiseError(new Exception(res.body.toString))
}
} yield Option(result)
}
}
Expand Down Expand Up @@ -228,7 +230,7 @@ class GithubExample extends AnyWordSpec with Matchers {
val GITHUB: Uri = Uri.unsafeFromString("https://api.github.com")

private def fetchCollectionRecursively[F[_], A](c: Client[F], req: Request[F])(implicit
CF: MonadError[F, Throwable],
CF: BracketThrow[F],
E: EntityDecoder[F, List[A]]
): F[List[A]] = {
val REL_NEXT = "rel=\"next\"".r
Expand Down Expand Up @@ -256,7 +258,7 @@ class GithubExample extends AnyWordSpec with Matchers {
)

for {
result <- c.fetch[List[A]](req) {
result <- c.run(req).use[F, List[A]] {
case Status.Ok(res) =>
if (hasNext(res)) {
for {
Expand Down
13 changes: 8 additions & 5 deletions fetch/src/main/scala/fetch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ object `package` {
val newRequest = Batch(combined, ds)
val newResult = CombinationSuspend((r: FetchStatus) =>
r match {
case FetchDone(m: Map[Any, Any]) =>
case FetchDone(preM) =>
val m = preM.asInstanceOf[Map[Any, Any]]
val xResult = m.get(aId).map(FetchDone(_)).getOrElse(FetchMissing())
val yResult = m.get(anotherId).map(FetchDone(_)).getOrElse(FetchMissing())
CombinationBarrier(() => x.result, xResult)
Expand All @@ -184,7 +185,8 @@ object `package` {
val newRequest = Batch(combined, ds)
val newResult = CombinationSuspend((r: FetchStatus) =>
r match {
case FetchDone(m: Map[Any, Any]) =>
case FetchDone(preM) =>
val m = preM.asInstanceOf[Map[Any, Any]]
val oneResult = m.get(oneId).map(FetchDone(_)).getOrElse(FetchMissing())
CombinationBarrier(() => x.result, oneResult)
.flatMap(() => y.result)
Expand All @@ -201,7 +203,8 @@ object `package` {
val newRequest = Batch(combined, ds)
val newResult = CombinationSuspend((r: FetchStatus) =>
r match {
case FetchDone(m: Map[Any, Any]) =>
case FetchDone(preM) =>
val m = preM.asInstanceOf[Map[Any, Any]]
val oneResult = m.get(oneId).map(FetchDone(_)).getOrElse(FetchMissing())
CombinationBarrier(() => y.result, oneResult)
.flatMap(() => x.result)
Expand Down Expand Up @@ -258,8 +261,8 @@ object `package` {

// Fetch Monad

implicit def fetchM[F[_]: Monad]: Monad[Fetch[F, ?]] =
new Monad[Fetch[F, ?]] with StackSafeMonad[Fetch[F, ?]] {
implicit def fetchM[F[_]: Monad]: Monad[Fetch[F, *]] =
new Monad[Fetch[F, *]] with StackSafeMonad[Fetch[F, *]] {
def pure[A](a: A): Fetch[F, A] =
Unfetch(
Monad[F].pure(Done(a))
Expand Down

0 comments on commit 66b1cf6

Please sign in to comment.