• Stars
    star
    549
  • Rank 80,988 (Top 2 %)
  • Language
    Scala
  • Created about 15 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This project aims to be the Scala Incubator project for Automatic-Resource-Management in the scala library

Scala Automatic Resource Management

Join the chat at https://gitter.im/jsuereth/scala-arm

This project is an attempt to provide an Automatic-Resource-Management library for the scala distribution. It is based off of code contributed to the Scalax project.

Using scala-arm

In SBT:

libraryDependencies += "com.jsuereth" %% "scala-arm" % "2.0"

or (if you want to manually specify the Scala version for some reason)

libraryDependencies += "com.jsuereth" % "scala-arm_2.11" % "2.0"
libraryDependencies += "com.jsuereth" % "scala-arm_2.12" % "2.0"

In Maven:

<dependency>
   <groupId>com.jsuereth</groupId>
   <artifactId>scala-arm_${scala.binary.version}</artifactId>
   <version>2.0</version>
</dependency>

Examples

Scala-arm provides a way of managing resources and re-using code. Here's an example:

    import resource._
    // Copy input into output.
    for {
      input <- managed(new java.io.FileInputStream("test.txt"))
      output <- managed(new java.io.FileOutputStream("test2.txt"))
    } {
      val buffer = new Array[Byte](512)
      def read(): Unit = input.read(buffer) match {
        case -1 => ()
        case  n =>
          output.write(buffer,0,n)
          read()
      }
      read()
    }

For more information on usage, see Usage

SCALA LICENSE

Copyright (c) 2002-2013 EPFL, Lausanne, unless otherwise specified. All rights reserved.

This software was developed by the Programming Methods Laboratory of the Swiss Federal Institute of Technology (EPFL), Lausanne, Switzerland.

Permission to use, copy, modify, and distribute this software in source or binary form for any purpose with or without fee is hereby granted, provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the EPFL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

More Repositories

1

sbt-in-action-examples

Source code examples for the book "sbt in Action"
Scala
144
star
2

scala-in-depth-source

The source code for the Scala In Depth book.
Scala
109
star
3

sauerkraut

A reimagined scala-pickling in the Scala 3 world
Scala
73
star
4

streamerz

Playground of Akka Streams and video processing in Scala
HTML
67
star
5

spring-akka-sample

Spring-akka sample for SpringOne 2012 talk.
JavaScript
51
star
6

viewducers

Scala collection views meet Transducers hype
Scala
42
star
7

intro-to-fp

Introduction to Functional programming talk from Pittsburgh TechFest
JavaScript
40
star
8

intro-to-actors

Source code for intro to actors talk
Scala
39
star
9

sperformance

Performance Testing framework aimed at automagically comparing performance tests and working inside Simple Build Tool
Scala
33
star
10

scala-embedded-interpreter-sample

Sample Embedded interpreter so I don't have to look up this code (and neither do you!)
Scala
33
star
11

shady-side

Prototype Scala -> GLSL translation, including scaffolding to run + test
Scala
21
star
12

scala-mojo-support

Helper to create maven mojo projects in the Scala languages
Scala
20
star
13

scala-cel

Scala Community Extension Libraries
Shell
18
star
14

snark

Twitter command line client example (ne scala 2015)
Scala
15
star
15

lambda-doge

A language that takes itself seriously.
Scala
12
star
16

binary-resilience

Source code proof of binary incompatibilities and potential solutions. WIP
Scala
12
star
17

tic-tac-toe

Tic-Tac-Toe game server example for Devoxx
Scala
10
star
18

osgi-scalac-plugin

OSGi compiler helpers for Scala
Scala
6
star
19

scala-99-puzzles

99 Prolog puzzles adapted for scala
Scala
6
star
20

jsuereth.github.com

Personal Blog/website
JavaScript
6
star
21

scala-lolz

Laffs 4 Scala. Iz gretist Prograham EVAR!
Scala
5
star
22

raspberry-potter

Scala
5
star
23

evil_monkey

Because sometimes you need an evil monkey to do it.
Scala
5
star
24

private-setter-scalac-plugin

Adds a @PrivateSetter annotation for use on vars to Scalac
4
star
25

scala-plugin

My working development efforts on the eclipse plugin
Scala
4
star
26

serializable

Scala
4
star
27

suspendable

Attempt to support CPS plugin
Scala
3
star
28

scala-spring-actors-sample

Sample scala application that uses spring actors
3
star
29

nerdcapture

A Screen/Audio capturing utiltiy library using Play Iteratees
Scala
2
star
30

scala-repo-cleaner

Shell
2
star
31

logwatch-extras

Additions to logwatch for nexus + hudson log files
2
star
32

specs2-scalaz

Scalaz for specs2
Scala
2
star
33

scala-fresh

Ugly hacks to make Scala Fresh build pipeline work
Scala
2
star
34

scala-actors

Toying with additons/fixes to scala actors
Scala
2
star
35

protocopter

New Prototype-based language for the JVM
Scala
2
star
36

github-rename

1
star
37

cat

Essence of the Iterator Pattern code, used during "Introduction to category theory" talk
Scala
1
star
38

slow-ivy-project

Example slow ivy project to test ivy resolution on.
Scala
1
star
39

TubeZ

Asynchronous Stream Processing Library for developing web delivered solutions
1
star
40

collection-tests

Scala
1
star
41

scala-ejb

EJB Helpers for the Scala language
Scala
1
star
42

maven-demo

Demo of maven features for Scala LiftOff
Scala
1
star