Skip to content

Commit 17c8868

Browse files
authored
Merge pull request #2228 from xuwei-k/using-clause-implicit
add `using` clause
2 parents d348e9f + 41b861a commit 17c8868

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

modules/core/src/main/scala/doobie/util/fragment.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ object fragment {
9494

9595
/** Construct an [[Update0]] from this fragment with the given label. */
9696
def updateWithLabel(label: String): Update0 =
97-
Update[elems.type](sql, pos, label)(implicitly[Write[elems.type]]).toUpdate0(elems)
97+
Update[elems.type](sql, pos, label)(using implicitly[Write[elems.type]]).toUpdate0(elems)
9898

9999
override def toString =
100100
s"""Fragment("$sql")"""

modules/core/src/main/scala/doobie/util/query.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ object query {
120120
* @group Results
121121
*/
122122
def toMap[K, V](a: A)(implicit ev: B =:= (K, V), f: FactoryCompat[(K, V), Map[K, V]]): ConnectionIO[Map[K, V]] =
123-
toConnectionIO(a, IHRS.buildPair[Map, K, V](f, read.map(ev)))
123+
toConnectionIO(a, IHRS.buildPair[Map, K, V](using f, read.map(ev)))
124124

125125
/** Just like `toMap` but allowing to alter `PreparedExecution`.
126126
*/
@@ -131,7 +131,7 @@ object query {
131131
ev: B =:= (K, V),
132132
f: FactoryCompat[(K, V), Map[K, V]]
133133
): ConnectionIO[Map[K, V]] =
134-
toConnectionIOAlteringExecution(a, IHRS.buildPair[Map, K, V](f, read.map(ev)), fn)
134+
toConnectionIOAlteringExecution(a, IHRS.buildPair[Map, K, V](using f, read.map(ev)), fn)
135135

136136
/** Apply the argument `a` to construct a program in `[[doobie.free.connection.ConnectionIO ConnectionIO]]` yielding
137137
* an `F[B]` accumulated via `MonadPlus` append. This method is more general but less efficient than `to`.

modules/core/src/main/scala/doobie/util/transactor.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ object transactor {
211211
* and translate it to back `M` effect.
212212
*/
213213
def liftF[I](mkEffect: M ~> ConnectionIO => ConnectionIO[I])(implicit ev: Async[M]): M[I] =
214-
WeakAsync.liftK[M, ConnectionIO].use(toConnectionIO => trans(ev).apply(mkEffect(toConnectionIO)))(ev)
214+
WeakAsync.liftK[M, ConnectionIO].use(toConnectionIO => trans(using ev).apply(mkEffect(toConnectionIO)))(using ev)
215215

216216
/** Crate a program expressed as `Stream` with `ConnectionIO` effects using a provided natural transformation `M ~>
217217
* ConnectionIO` and translate it back to a `Stream` with `M` effects.
218218
*/
219219
def liftS[I](mkStream: M ~> ConnectionIO => Stream[ConnectionIO, I])(implicit ev: Async[M]): Stream[M, I] =
220-
Stream.resource(WeakAsync.liftK[M, ConnectionIO])(ev).flatMap(toConnectionIO =>
221-
transP(ev).apply(mkStream(toConnectionIO)))
220+
Stream.resource(WeakAsync.liftK[M, ConnectionIO])(using ev).flatMap(toConnectionIO =>
221+
transP(using ev).apply(mkStream(toConnectionIO)))
222222

223223
/** Embed a `Pipe` with `ConnectionIO` effects inside a `Pipe` with `M` effects by lifting incoming stream to
224224
* `ConnectionIO` effects and lowering outgoing stream to `M` effects.

modules/refined/src/main/scala/doobie/refined/Instances.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ trait Instances {
4646
validate: Validate[T, P],
4747
manifest: TypeName[F[T, P]]
4848
): F[T, P] =
49-
rightOrException[F[T, P]](refType.refine[P](t)(validate))
49+
rightOrException[F[T, P]](refType.refine[P](t)(using validate))
5050

5151
private def unwrapRefinedType[T, P, F[_, _]](ftp: F[T, P])(
5252
implicit refType: RefType[F]
@@ -57,7 +57,7 @@ trait Instances {
5757
implicit manifest: TypeName[T]
5858
): T =
5959
either match {
60-
case Left(err) => throw new SecondaryValidationFailed[T](err)(manifest)
60+
case Left(err) => throw new SecondaryValidationFailed[T](err)(using manifest)
6161
case Right(t) => t
6262
}
6363

0 commit comments

Comments
 (0)