-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move around some stuff in core._ #2313
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,20 +105,14 @@ package object db { | |
} | ||
|
||
trait FoxyTFunctions[F[_]] { | ||
def apply[A](a: A)(implicit F: Monad[F]): FoxyT[F, A] = // TODO: remove me? @michalrus | ||
pure(a) | ||
|
||
def pure[A](a: A)(implicit F: Monad[F]): FoxyT[F, A] = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, we have pure from cats. |
||
Monad[FoxyT[F, ?]].pure(a) | ||
|
||
def good[A](a: A)(implicit F: Monad[F]): FoxyT[F, A] = // TODO: remove me @michalrus | ||
pure(a) | ||
a.pure[FoxyT[F, ?]] | ||
|
||
def unit(implicit F: Monad[F]): FoxyT[F, Unit] = | ||
pure(()) // TODO: remove me? @michalrus | ||
().pure[FoxyT[F, ?]] // TODO: remove me? @michalrus | ||
|
||
def none[A](implicit F: Monad[F]): FoxyT[F, Option[A]] = | ||
pure(None) // TODO: remove me? @michalrus | ||
(None: Option[A]).pure[FoxyT[F, ?]] // TODO: remove me? @michalrus | ||
|
||
def uiWarning(f: Failure)(implicit F: Monad[F]): FoxyT[F, Unit] = | ||
StateT.modify(MetaResponse.Warning(f) :: _) | ||
|
@@ -161,7 +155,7 @@ package object db { | |
L.map(lfa)(_.fold(Either.left(_), Either.right(_))).sequence.flatMap { xa ⇒ | ||
val failures = L.collect(xa) { case Left(f) ⇒ f.toList }.toList.flatten | ||
val values = L.collect(xa) { case Right(a) ⇒ a } | ||
NonEmptyList.fromList(failures).fold(FoxyT[F].pure(values))(FoxyT[F].failures(_)) | ||
NonEmptyList.fromList(failures).fold(values.pure[FoxyT[F, ?]])(FoxyT[F].failures(_)) | ||
} | ||
|
||
/** A bit like ``sequence`` but will ignore failed Foxies. */ | ||
|
@@ -276,15 +270,12 @@ package object db { | |
def appendForUpdate[A, B <: slick.dbio.NoStream](sql: SqlAction[A, B, Effect.Read]): DBIO[A] = | ||
sql.overrideStatements(sql.statements.map(_ + " for update")) | ||
|
||
def lift[A](value: A): DBIO[A] = DBIO.successful(value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, we have pure from cats. |
||
|
||
def liftFuture[A](future: Future[A]): DBIO[A] = DBIO.from(future) | ||
|
||
// TODO: I don’t know… does this help? @michalrus | ||
def ifElse[A](condition: Boolean, ifBranch: ⇒ DbResultT[A], elseBranch: ⇒ DbResultT[A]) = | ||
if (condition) ifBranch else elseBranch | ||
|
||
def doOrMeh(condition: Boolean, action: ⇒ DbResultT[_])(implicit ec: EC): DbResultT[Unit] = | ||
if (condition) action.meh else DbResultT.unit | ||
def when[F[_]](p: Boolean, s: ⇒ F[Unit])(implicit F: Applicative[F]): F[Unit] = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if (p) s.void else F.pure(()) | ||
|
||
def doOrGood[A](condition: Boolean, action: ⇒ DbResultT[A], good: ⇒ A)(implicit ec: EC): DbResultT[A] = | ||
if (condition) action else DbResultT.good(good) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code.