Skip to content

Commit

Permalink
fix: parse arg in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
ValdemarGr committed Feb 5, 2024
1 parent 630a19e commit 12af7cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class ArgParsing[C](variables: VariableMap[C]) {
if (tooMuch.isEmpty) G.unit
else G.raise(s"Too many fields provided, unknown fields are ${tooMuch.toList.map(x => s"'$x'").mkString_(", ")}.", context)

val fv = arg.impl.foldMap[G, ValidatedNec[String, A]](new (Arg.Impl ~> G) {
val fv = arg.impl.parFoldMap[G, ValidatedNec[String, A]](new (Arg.Impl ~> G) {
def apply[B](fa: Arg.Impl[B]): G[B] = fa match {
case fa: ArgDecoder[a, B] =>
G.ambientField(fa.av.name) {
Expand Down
6 changes: 6 additions & 0 deletions modules/core/src/main/scala/gql/std/FreeApply.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import scala.annotation.nowarn
/** FreeApply is a Free Applicative, but witout pure. It has an Apply instance.
*/
sealed abstract class FreeApply[F[_], +A] extends Product with Serializable {
def parFoldMap[G[_], B >: A](fk: F ~> G)(implicit G: Parallel[G]): G[B] = {
implicit val H: Apply[G.F] = G.apply
val fk2: F ~> G.F = fk.andThen(G.parallel)
G.sequential(foldMap[G.F, B](fk2))
}

def foldMap[G[_], B >: A](fk: F ~> G)(implicit G: Apply[G]): G[B] =
FreeApply.foldMap[F, G, B](this)(fk)

Expand Down

0 comments on commit 12af7cb

Please sign in to comment.