Skip to main content
Version: 2.0.0-beta13

What to Import

Most Places

import effectie.core._
import effectie.syntax.all._
import effectie.core._ // for Fx
import effectie.syntax.all._ // for effectOf(), pureOf(), errorOf(), etc.

def foo[F[_]: Fx](n: Int): F[int] =
for {
n2 <- bar(n)
} yield n + n2

For Main Method

You need instances for Fx when you actually run your program. It's usually only one place where you put the main method.

Fx[F] Instance

For the instance of Fx[F],

import effectie.instances.ce2.fx._

Example

import cats._
import cats.syntax.all._

import effectie.core._
import effectie.syntax.all._

trait Foo[F[_]] {
def foo(n: Int): F[Int]
}
object Foo {
def apply[F[_]: Fx: Monad]: Foo[F] = new FooF[F]

private class FooF[F[_]: Fx: Monad] extends Foo[F] {
def foo(n: Int): F[Int] = {
for {
n2 <-
if (n > 0)
pureOf(n * 2)
else
pureOf(n * n)
n3 <- pureOf(n2 * 3)
n4 <- pureOf(n2 * 2)
} yield n3 + n4
}
}
}
import cats.effect._

object MyApp extends IOApp.Simple {

import effectie.instances.ce2.fx._

def run: IO[Unit] = {
for {
n <- Foo[IO].foo(123)
_ <- putStrLn(s"Result: ${n.toString}")
} yield ()
}

}