Skip to content

cacilhas/effects

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 

Kodumaro Effects

A dependency-free side-effect lazy dealer.

Installation

Add to your build.sbt (only Scala 2.12):

resolvers += "Kodumaro Maven Repository" at "https://cacilhas.info/maven"
libraryDependencies += "info.cacilhas.kodumaro" %% "kodumaro-effects" % "1.0.1"

Or using Git itself (Scala 2.12 or other versions):

lazy val kodumaroEffects = RootProject(uri("https://github.com/cacilhas/effects.git#release/1.0.1"))
dependsOn(kodumaroEffects)

TODO

  • Publish to Github Packages (waiting for Github Packages to support unauthenticated access).

I/O monad

The I/O monad is a wrapper around side-effect blocks to perform’em lazily.

import info.cacilhas.kodumaro.effect._

object Main extends App {

  val hello: IO[Unit] = println("Hello, World!")
  for (_ <- 1 to 5) hello.perform
}

A monad returning a value:

val process: IO[Either[Exception, Boolean]] = try {
  // Do some side-effect procedure
  Right(true)
} catch {
  case exc: Exception => Left(exc)
}

// Run some set up

val processStatus: Either[Exception, Boolean] = process // the I/O monad is performed

Copying

License

Author