Skip to content

ThoughtWorksInc/RAII.scala

Folders and files

NameName
Last commit message
Last commit date
Aug 23, 2017
Dec 30, 2019
Dec 30, 2019
Dec 30, 2019
Aug 21, 2017
Nov 21, 2019
Dec 30, 2019
May 28, 2016
Nov 3, 2016
Jul 9, 2019
Mar 30, 2017
Jul 29, 2017
Dec 30, 2019
Apr 18, 2018
Apr 18, 2018

Repository files navigation

RAII.scala

Build Status Latest version Scaladoc

RAII.scala is a collection of utilities aims to manage native resources in Scalaz.

Asynchronous Do

An asynchronous.Do is an asynchronous value, like scala.concurrent.Future or scalaz.concurrent.Task. The difference is that resources in Do can be either automatically acquired/released in scope, or managed by reference counting mechanism.

To use Do, add the following setting to your build.sbt,

libraryDependencies += "com.thoughtworks.raii" %% "asynchronous" % "latest.release"

and check the Scaladoc for usage.

ResourceT

Do consists of some monad transformers. The ability of resource management in Do is provided by the monad transformer ResourceT.

You can combine ResourceT with monads other than asynchronous.Do. For example, a resource manager in synchronous execution.

Covariant ResourceT

To use ResourceT for monadic data types whose kind is F[+A](e.g. scalaz.concurrent.Future or scalaz.Name), add the following setting to your build.sbt:

libraryDependencies += "com.thoughtworks.raii" %% "covariant" % "latest.release"

and check the Scaladoc for usage.

Invariant ResourceT

To use ResourceT for monadic data types whose kind is F[A](e.g. scalaz.effect.IO), add the following setting to your build.sbt:

libraryDependencies += "com.thoughtworks.raii" %% "invariant" % "latest.release"

and check the Scaladoc for usage.

Links

Related projects

  • Scalaz provides type classes and underlying data structures for this project.
  • ThoughtWorks Each provides monadic/each-like syntax which can be used with this project.
  • tryt.scala provides exception handling monad transformers for this project.
  • future.scala provides the asynchronous task types for this project.
  • DeepLearning.scala uses this project for asynchronous executed neural networks.

Credits

This library is inspired by Josh Suereth's scala-arm, in which I implemented the reference counting mechanism at first.