-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
162 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
cats/shared/src/main/scala/org/atnos/eff/syntax/addon/cats/IOOps2.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.atnos.eff.syntax.addon.cats | ||
|
||
import cats.effect.IO | ||
import org.atnos.eff._ | ||
import org.atnos.eff.addon.cats.effect.IOEffect | ||
import org.atnos.eff.addon.cats.effect.IOInterpretation | ||
|
||
final class IOOps2[R, A](private val e: Eff[R, A]) extends AnyVal { | ||
|
||
def ioAttempt(implicit m: MemberInOut[IO, R]): Eff[R, Throwable Either A] = | ||
IOEffect.ioAttempt(e) | ||
|
||
def runIoMemo[U](cache: Cache)(implicit m: Member.Aux[Memoized, R, U], task: IO |= U): Eff[U, A] = | ||
IOEffect.runIoMemo(cache)(e) | ||
|
||
def ioMemo(key: AnyRef, cache: Cache)(implicit task: IO /= R): Eff[R, A] = | ||
IOInterpretation.ioMemo(key, cache, e) | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
cats/shared/src/main/scala/org/atnos/eff/syntax/addon/cats/effect/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.atnos.eff.syntax.addon.cats | ||
|
||
import cats.effect.IO | ||
import org.atnos.eff._ | ||
|
||
package object effect { | ||
|
||
implicit final def toIOOps[A](e: Eff[Fx1[IO], A]): IOOps[A] = new IOOps[A](e) | ||
implicit final def toIOOps2[R, A](e: Eff[R, A]): IOOps2[R, A] = new IOOps2[R, A](e) | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
doobie/src/main/scala/org/atnos/eff/addon/doobie/connectionio.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.atnos.eff.addon.doobie | ||
|
||
object connectionio extends DoobieConnectionIOEffect |
5 changes: 0 additions & 5 deletions
5
doobie/src/main/scala/org/atnos/eff/addon/doobie/package.scala
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
monix/shared/src/main/scala/org/atnos/eff/addon/monix/package.scala
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
monix/shared/src/main/scala/org/atnos/eff/addon/monix/task.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.atnos.eff.addon.monix | ||
|
||
object task extends TaskEffect |
77 changes: 77 additions & 0 deletions
77
scalaz/shared/src/main/scala/org/atnos/eff/addon/scalaz/EffScalaz.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.atnos.eff | ||
package addon | ||
package scalaz | ||
|
||
import _root_.scalaz._ | ||
import _root_.scalaz.syntax.functor._ | ||
import _root_.scalaz.std.vector._ | ||
|
||
object EffScalaz { | ||
|
||
def traverseA[R, F[_]: Traverse, A, B](fs: F[A])(f: A => Eff[R, B]): Eff[R, F[B]] = | ||
Traverse[F].traverse(fs)(f)(EffScalazApplicative[R]) | ||
|
||
def sequenceA[R, F[_]: Traverse, A](fs: F[Eff[R, A]]): Eff[R, F[A]] = | ||
Traverse[F].sequence(fs)(EffScalazApplicative[R]) | ||
|
||
def flatTraverseA[R, F[_], A, B](fs: F[A])( | ||
f: A => Eff[R, F[B]] | ||
)(implicit FT: Traverse[F], FM: Bind[F]): Eff[R, F[B]] = | ||
FT.traverseM[A, Eff[R, *], B](fs)(f)(EffScalazApplicative[R], FM) | ||
|
||
/** use the applicative instance of Eff to sequence a list of values, then flatten it */ | ||
def flatSequenceA[R, F[_], A](fs: F[Eff[R, F[A]]])(implicit FT: Traverse[F], FM: Bind[F]): Eff[R, F[A]] = | ||
FT.traverseM[Eff[R, F[A]], Eff[R, *], A](fs)(identity)(EffScalazApplicative[R], FM) | ||
|
||
def detach[M[_], A](eff: Eff[Fx1[M], A])(implicit m: Monad[M], b: BindRec[M]): M[A] = | ||
BindRec[M].tailrecM[Eff[Fx1[M], A], A](eff) { | ||
case Pure(a, Last(Some(l))) => Monad[M].point(-\/(l.value.as(a))) | ||
case Pure(a, Last(None)) => Monad[M].point(\/-(a)) | ||
|
||
case Impure(NoEffect(a), continuation, last) => | ||
Monad[M].point(-\/(continuation(a).addLast(last))) | ||
|
||
case Impure(u, continuation, last) => | ||
u match { | ||
case NoEffect(a) => Monad[M].point(-\/(continuation(a).addLast(last))) | ||
case UnionTagged(ta: M[Nothing] @unchecked, _) => | ||
last match { | ||
case Last(Some(l)) => Monad[M].map(ta)(x => -\/(continuation(x).addLast(last))) | ||
case Last(None) => Monad[M].map(ta)(x => -\/(continuation(x))) | ||
} | ||
} | ||
|
||
case ap @ ImpureAp(_, _, _) => | ||
Monad[M].point(-\/(ap.toMonadic)) | ||
} | ||
|
||
def detachA[M[_], A]( | ||
eff: Eff[Fx1[M], A] | ||
)(implicit monad: Monad[M], bindRec: BindRec[M], applicative: Applicative[M]): M[A] = | ||
BindRec[M].tailrecM[Eff[Fx1[M], A], A](eff) { | ||
case Pure(a, Last(Some(l))) => monad.point(-\/(l.value.as(a))) | ||
case Pure(a, Last(None)) => monad.point(\/-(a)) | ||
|
||
case Impure(NoEffect(a), continuation, last) => | ||
monad.point(-\/(continuation(a).addLast(last))) | ||
|
||
case Impure(u, continuation, last) => | ||
u match { | ||
case NoEffect(a) => Monad[M].point(-\/(continuation(a).addLast(last))) | ||
case UnionTagged(ta: M[Nothing] @unchecked, _) => | ||
last match { | ||
case Last(Some(l)) => Monad[M].map(ta)(x => -\/(continuation(x).addLast(last))) | ||
case Last(None) => Monad[M].map(ta)(x => -\/(continuation(x))) | ||
} | ||
} | ||
|
||
case ap @ ImpureAp(unions, continuation, last) => | ||
val effects = unions.unions.collect { case UnionTagged(mx: M[Nothing] @unchecked, _) => mx } | ||
val sequenced = applicative.sequence[Nothing, Vector](effects) | ||
|
||
last match { | ||
case Last(Some(l)) => Monad[M].map(sequenced)(x => -\/(continuation(x).addLast(last))) | ||
case Last(None) => Monad[M].map(sequenced)(x => -\/(continuation(x))) | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
scalaz/shared/src/main/scala/org/atnos/eff/addon/scalaz/all.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.atnos.eff.addon.scalaz | ||
|
||
object all extends either with eval with safe with validate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.atnos.eff | ||
|
||
object reader extends ReaderCreation with ReaderInterpretation | ||
object writer extends WriterCreation with WriterInterpretation | ||
object state extends StateCreation with StateInterpretation with StateImplicits | ||
object eval extends EvalCreation with EvalInterpretation | ||
object option extends OptionCreation with OptionInterpretation | ||
object list extends ListCreation with ListInterpretation | ||
object either extends EitherCreation with EitherInterpretation with EitherImplicits | ||
object future extends FutureCreation with FutureInterpretation | ||
object memo extends MemoCreation with MemoInterpretation | ||
|
||
object create | ||
extends ReaderCreation | ||
with WriterCreation | ||
with StateCreation | ||
with EvalCreation | ||
with OptionCreation | ||
with ListCreation | ||
with EitherCreation | ||
with ValidateCreation | ||
with ChooseCreation | ||
with FutureCreation | ||
with MemoCreation | ||
with EffCreation | ||
with SafeCreation | ||
|
||
object all | ||
extends ReaderEffect | ||
with WriterEffect | ||
with StateEffect | ||
with EvalEffect | ||
with OptionEffect | ||
with ListEffect | ||
with EitherEffect | ||
with ValidateEffect | ||
with ChooseEffect | ||
with SafeEffect | ||
with MemoEffect | ||
with Batch | ||
with EffInterpretation | ||
with EffCreation | ||
with EffImplicits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
twitter/src/main/scala/org/atnos/eff/addon/twitter/future.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.atnos.eff.addon.twitter | ||
|
||
object future extends TwitterFutureEffect |
5 changes: 0 additions & 5 deletions
5
twitter/src/main/scala/org/atnos/eff/addon/twitter/package.scala
This file was deleted.
Oops, something went wrong.