Permalink
Browse files

fix procedure syntax warnings

  • Loading branch information...
1 parent cba156f commit bffbbcf366ca3a33dad6b3c10683228b20812bcf @xuwei-k xuwei-k committed Dec 12, 2016
@@ -207,7 +207,7 @@ sealed abstract class Future[+A] {
val cancel = new AtomicBoolean(false)
val done = new AtomicBoolean(false)
scheduler.schedule(new Runnable {
- def run() {
+ def run(): Unit = {
if (done.compareAndSet(false,true)) {
cancel.set(true)
cb(-\/(new TimeoutException(s"Timed out after $timeoutInMillis milliseconds")))
@@ -30,7 +30,7 @@ object Run {
def strategy: Strategy = r.strategy
- def run(a: B) {
+ def run(a: B): Unit = {
r.run(f(a))
}
}
@@ -20,9 +20,9 @@ case class Timer(timeoutTickMs: Int = 100, workerName: String = "TimeoutContextW
private[this] val lock = new ReentrantReadWriteLock()
private[this] var futures: SortedMap[Long, List[() => Unit]] = SortedMap()
private[this] val workerRunnable = new Runnable() {
- def run() {
+ def run(): Unit = {
@tailrec
- def innerRun() {
+ def innerRun(): Unit = {
lastNow = alignTimeResolution(System.currentTimeMillis)
// Deal with stuff to expire.
futures.headOption match {
@@ -48,11 +48,11 @@ case class Timer(timeoutTickMs: Int = 100, workerName: String = "TimeoutContextW
private[this] val workerThread = new Thread(workerRunnable, workerName)
workerThread.start()
- private[this] def expireFutures(futures: SortedMap[Long, List[() => Unit]]) {
+ private[this] def expireFutures(futures: SortedMap[Long, List[() => Unit]]): Unit = {
futures.foreach(vector => vector._2.foreach(call => call()))
}
- def stop(expireImmediately: Boolean = false) {
+ def stop(expireImmediately: Boolean = false): Unit = {
withWrite{
continueRunning = false
if (expireImmediately) {
@@ -99,7 +99,7 @@ case class One[V, A](v: V, a1: A)(implicit r: Reducer[A, V]) extends Finger[V, A
def map[B, V2](f: A => B)(implicit r: Reducer[B, V2]) = one(f(a1))
- def foreach(f: A => Unit) {
+ def foreach(f: A => Unit): Unit = {
f(a1)
}
@@ -138,7 +138,7 @@ case class Two[V, A](v: V, a1: A, a2: A)(implicit r: Reducer[A, V]) extends Fing
def map[B, V2](f: A => B)(implicit r: Reducer[B, V2]) = two(f(a1), f(a2))
- def foreach(f: A => Unit) {
+ def foreach(f: A => Unit): Unit = {
f(a1)
f(a2)
}
@@ -185,7 +185,7 @@ case class Three[V, A](v: V, a1: A, a2: A, a3: A)(implicit r: Reducer[A, V]) ext
def map[B, V2](f: A => B)(implicit r: Reducer[B, V2]) = three(f(a1), f(a2), f(a3))
- def foreach(f: A => Unit) {
+ def foreach(f: A => Unit): Unit = {
f(a1)
f(a2)
f(a3)
@@ -238,7 +238,7 @@ case class Four[V, A](v: V, a1: A, a2: A, a3: A, a4: A)(implicit r: Reducer[A, V
def map[B, V2](f: A => B)(implicit r: Reducer[B, V2]) = four(f(a1), f(a2), f(a3), f(a4))
- def foreach(f: A => Unit) {
+ def foreach(f: A => Unit): Unit = {
f(a1)
f(a2)
f(a3)
@@ -290,7 +290,7 @@ sealed abstract class Node[V, A](implicit r: Reducer[A, V]) {
(v, a1, a2) => node2(f(a1), f(a2)),
(v, a1, a2, a3) => node3(f(a1), f(a2), f(a3)))
- def foreach(f: A => Unit) {
+ def foreach(f: A => Unit): Unit = {
fold(
(_, a1, a2) => { f(a1); f(a2) },
(_, a1, a2, a3) => { f(a1); f(a2); f(a3) }
@@ -823,7 +823,7 @@ sealed abstract class FingerTree[V, A](implicit measurer: Reducer[A, V]) {
}
/** Execute the provided side effect for each element in the tree. */
- def foreach(f: A => Unit) {
+ def foreach(f: A => Unit): Unit = {
fold(
_ => {},
(_, x) => { f(x) },
@@ -22,7 +22,7 @@ sealed abstract class ImmutableArray[+A] {
def isEmpty: Boolean = length == 0
def toArray[B >: A : ClassTag]: Array[B]
- def copyToArray[B >: A](xs: Array[B], start: Int, len: Int)
+ def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit
def slice(from: Int, until: Int): ImmutableArray[A]
def ++[B >: A: ClassTag](other: ImmutableArray[B]): ImmutableArray[B]
@@ -159,7 +159,7 @@ object ImmutableArray extends ImmutableArrayInstances {
def length = arr.length
def toArray[B >: A : ClassTag] = arr.clone.asInstanceOf[Array[B]]
- def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) { arr.copyToArray(xs, start, len) }
+ def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit = { arr.copyToArray(xs, start, len) }
def slice(from: Int, until: Int) = fromArray(arr.slice(from, until))
@@ -223,7 +223,7 @@ object ImmutableArray extends ImmutableArrayInstances {
def length = str.length
def toArray[B >: Char : ClassTag] = str.toArray
- def copyToArray[B >: Char](xs: Array[B], start: Int, len: Int) { str.copyToArray(xs, start, len) }
+ def copyToArray[B >: Char](xs: Array[B], start: Int, len: Int): Unit = { str.copyToArray(xs, start, len) }
def slice(from: Int, until: Int) = new StringArray(str.slice(from, until))
@@ -16,7 +16,7 @@ trait SafeApp {
def runc: IO[Unit] = ioUnit
- final def main(args: Array[String]) {
+ final def main(args: Array[String]): Unit = {
run(ImmutableArray.fromArray(args)).unsafePerformIO()
}
@@ -4,14 +4,14 @@ import scalaz.{CaseInsensitive => CI}
object CaseInsensitiveUsage extends App {
- def maps() {
+ def maps(): Unit = {
val nums: Map[CI[String], Int] = Map(CI("ONE") -> 1, CI("Two") -> 2)
assert(nums(CI("one")) == 1)
assert(nums(CI("TWO")) == 2)
}
- def sets() {
+ def sets(): Unit = {
val nums: Set[CI[String]] = Set(CI("ONE"), CI("Two"))
assert(nums(CI("one")))
@@ -14,7 +14,7 @@ object DirectTypeClassUsage extends App {
direct2()
// Direct use of type class for one type, Option
- def direct1() {
+ def direct1(): Unit = {
import scalaz._
// Import the members of the type class instance for Option.
@@ -26,7 +26,7 @@ object DirectTypeClassUsage extends App {
// Direct use of type class for multiple types
- def direct2() {
+ def direct2(): Unit = {
import scalaz._
// Import the type class instances for Option and List.
@@ -10,7 +10,7 @@ object MixedBag extends App {
kleisiArrow()
dListExample()
- def monoid() {
+ def monoid(): Unit = {
import std.anyVal._
import std.option._
@@ -24,7 +24,7 @@ object MixedBag extends App {
intInstance.semigroupSyntax.mappend(1, 2)
}
- def traverseBigList() {
+ def traverseBigList(): Unit = {
import std.option._
import std.list._
import syntax.traverse._
@@ -34,7 +34,7 @@ object MixedBag extends App {
()
}
- def traverseBigStream() {
+ def traverseBigStream(): Unit = {
import std.option._
import std.stream._
import syntax.traverse._
@@ -44,7 +44,7 @@ object MixedBag extends App {
()
}
- def tree() {
+ def tree(): Unit = {
import std.string._
import syntax.semigroup._
import syntax.equal._
@@ -61,7 +61,7 @@ object MixedBag extends App {
m assert_=== "12345"
}
- def strictTree() {
+ def strictTree(): Unit = {
import std.string._
import syntax.semigroup._
import syntax.equal._
@@ -78,7 +78,7 @@ object MixedBag extends App {
m assert_=== "12345"
}
- def kleisiArrow() {
+ def kleisiArrow(): Unit = {
import Kleisli._
import std.option._
import syntax.compose._
@@ -90,7 +90,7 @@ object MixedBag extends App {
f >>> K.arr(i => i * 2) >>> K.arr(x => println(x)) run 3
}
- def dListExample() {
+ def dListExample(): Unit = {
import DList._
import syntax.monad._
import syntax.writer._
@@ -118,7 +118,7 @@ object MixedBag extends App {
flattenWriter(node(node(leaf(1), leaf(3)), leaf(2))).toList
}
- def zipper() {
+ def zipper(): Unit = {
import scalaz.std.list
val fileName = "abc.txt"
@@ -6,7 +6,7 @@ object PartiallyApplied extends App {
function1()
- def function1() {
+ def function1(): Unit = {
import scalaz._
import std.function._
import syntax.monad._
@@ -5,17 +5,17 @@ import scalaz._
object StateTUsage extends App {
import StateT._
- def f[M[_]: Functor] {
+ def f[M[_]: Functor] = {
Functor[StateT[M, Int, ?]]
}
- def m[M[_]: Monad] {
+ def m[M[_]: Monad] = {
Applicative[StateT[M, Int, ?]]
Monad[StateT[M, Int, ?]]
MonadState[StateT[M, Int, ?], Int]
}
- def state() {
+ def state(): Unit = {
val state: State[String, Int] = State((x: String) => (x + 1, 0))
val eval: Int = state.eval("")
state.flatMap(_ => state)
@@ -17,7 +17,7 @@ object SyntaxUsage extends App {
// Use the syntax only for Monad[Option]
// This includes the syntax for the parent type classes.
- def syntax1() {
+ def syntax1(): Unit = {
import scalaz._
// Import type class instances for Option, and the
@@ -34,7 +34,7 @@ object SyntaxUsage extends App {
}
// Use two different instances, and the syntax for all Monads
- def syntax2() {
+ def syntax2(): Unit = {
import scalaz._
// Import type class instances for Option and List
@@ -51,7 +51,7 @@ object SyntaxUsage extends App {
1.point[Option]
}
- def syntax3() {
+ def syntax3(): Unit = {
import scalaz._
// Import all type class instances
@@ -64,7 +64,7 @@ object SyntaxUsage extends App {
o2.tuple(o2)
}
- def stdSyntax() {
+ def stdSyntax(): Unit = {
import scalaz.Tags.Last
import scalaz.std.anyVal._
import scalaz.std.stream.streamSyntax._
@@ -81,7 +81,7 @@ object SyntaxUsage extends App {
Last.unwrap((some(1).last |+| some(2).last)) assert_=== some(2)
}
- def stdSyntaxUeber() {
+ def stdSyntaxUeber(): Unit = {
// Scalaz 6 Style: import everything: type class instances, implicit conversions
// to the syntax wrappers, general functions.
import scalaz._
@@ -4,7 +4,7 @@ package scalaz.example
object UnapplyInference extends App {
eitherTBifunctor()
- def eitherTBifunctor() {
+ def eitherTBifunctor(): Unit = {
import scalaz._, Scalaz._
val either: (Int \/ Int) = \/.right(1)
@@ -13,7 +13,7 @@ object UnapplyInference extends App {
println((eitherT :-> (_ - 1)).run) // Some(Right(0))
}
- def eitherTBitraverse() {
+ def eitherTBitraverse(): Unit = {
import scalaz._
import std.list._, std.option._
import syntax.all._
@@ -25,15 +25,15 @@ object UnapplyInference extends App {
}
// Without Unapply
- def stateTraverse1 {
+ def stateTraverse1: Unit = {
import scalaz._, Scalaz._
val ls = List(1, 2, 3)
val traverseOpt: Option[List[Int]] = ls.traverse(a => some(a))
val traverseState: State[Int, List[Int]] = ls.traverse[State[Int,?],Int](a => State((x: Int) => (x+1,a)))
}
// With Unapply (in the signature of traverseU)
- def stateTraverse2 {
+ def stateTraverse2: Unit = {
import scalaz._, Scalaz._
val ls = List(1, 2, 3)
@@ -43,7 +43,7 @@ object UnapplyInference extends App {
val pair: State[Int, (Int, Int)] = State((x: Int) => (x + 1, x)).tuple(State((x: Int) => (x + 2, x)))
}
- def kleisliCompose() {
+ def kleisliCompose(): Unit = {
import scalaz._
import std.option._
import syntax.compose._
@@ -53,13 +53,13 @@ object UnapplyInference extends App {
k >>> k
}
- def kleisliU() {
+ def kleisliU(): Unit = {
import scalaz._
val k: Kleisli[NumberFormatException \/ ?, String, Int] =
Kleisli.kleisliU{s: String => try \/-(s.toInt) catch{ case e: NumberFormatException => -\/(e) }}
}
- def functorSyntaxChaining() {
+ def functorSyntaxChaining(): Unit = {
import scalaz._
import syntax.functor._
@@ -13,7 +13,7 @@ object WordCount {
wordCount
}
- def wordCount {
+ def wordCount: Unit = {
import scalaz.State
val text = "the cat in the hat\n sat on the mat\n".toList
Oops, something went wrong.

0 comments on commit bffbbcf

Please sign in to comment.