<commit_before>// Copyright (c) 2013-2018 <NAME> and Contributors
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

package doobie.syntax

import cats.data.{EitherT, OptionT}
import cats.effect.Bracket
import doobie.HC
import doobie.free.connection.ConnectionIO
import doobie.util.transactor.Transactor

class ConnectionIOOps[A](ma: ConnectionIO[A]) {
  def transact[M[_]](xa: Transactor[M])(implicit ev: Bracket[M, Throwable]): M[A] = xa.transB.apply(ma)
}

class OptionTConnectionIOOps[A](ma: OptionT[ConnectionIO, A]) {
  def transact[M[_]](xa: Transactor[M])(implicit ev: Bracket[M, Throwable]): OptionT[M, A] =
    OptionT(
      xa.transB.apply(ma.orElseF(HC.rollback.map(_ => None)).value)
    )
}

class EitherTConnectionIOOps[E, A](ma: EitherT[ConnectionIO, E, A]) {
  def transact[M[_]](xa: Transactor[M])(implicit ev: Bracket[M, Throwable]): EitherT[M, E, A] =
    EitherT(
      xa.transB.apply(ma.leftSemiflatMap(e => HC.rollback.map(_ => e)).value)
    )
}

trait ToConnectionIOOps {
  implicit def toConnectionIOOps[A](ma: ConnectionIO[A]): ConnectionIOOps[A] =
    new ConnectionIOOps(ma)

  implicit def toOptionTConnectionIOOps[A](ma: OptionT[ConnectionIO, A]): OptionTConnectionIOOps[A] =
    new OptionTConnectionIOOps(ma)

  implicit def toEitherTConnectionIOOps[E, A](ma: EitherT[ConnectionIO, E, A]): EitherTConnectionIOOps[E, A] =<commit_msg>attempt to fix instance ambiguity<commit_after>// Copyright (c) 2013-2018 <NAME> and Contributors
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

package doobie.syntax

import cats.data.{EitherT, OptionT}
import cats.effect.Bracket
import cats.syntax.functor._
import doobie.HC
import doobie.free.connection.{AsyncConnectionIO, ConnectionIO}
import doobie.util.transactor.Transactor

class ConnectionIOOps[A](ma: ConnectionIO[A]) {
  def transact[M[_]](xa: Transactor[M])(implicit ev: Bracket[M, Throwable]): M[A] = xa.transB.apply(ma)
}

class OptionTConnectionIOOps[A](ma: OptionT[ConnectionIO, A]) {
  def transact[M[_]](xa: Transactor[M])(implicit ev: Bracket[M, Throwable]): OptionT[M, A] =
    OptionT(
      xa.transB.apply(ma.orElseF(HC.rollback.as(None)).value)
    )
}

class EitherTConnectionIOOps[E, A](ma: EitherT[ConnectionIO, E, A]) {
  def transact[M[_]](xa: Transactor[M])(implicit ev: Bracket[M, Throwable]): EitherT[M, E, A] =
    EitherT(
      xa.transB.apply(ma.leftSemiflatMap(HC.rollback.as(_)).value)
    )
}

trait ToConnectionIOOps {
  implicit def toConnectionIOOps[A](ma: ConnectionIO[A]): ConnectionIOOps[A] =
    new ConnectionIOOps(ma)

  implicit def toOptionTConnectionIOOps[A](ma: OptionT[ConnectionIO, A]): OptionTConnectionIOOps[A] =
    new OptionTConnectionIOOps(ma)

  implicit def toEitherTConnectionIOOps[E, A](ma: EitherT[ConnectionIO, E, A]): EitherTConnectionIOOps[E, A] =
{'fraction_non_alphanumeric': 0.14222824246528953, 'fraction_numerical': 0.005418218760582459, 'mean_word_length': 5.608501118568233, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3832899', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1058, 'n_words': 218}