monifu

syntax

package syntax

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. syntax
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. trait Not[T] extends AnyRef

    Type-class for proving that an implicit T does not exist in scope.

    Type-class for proving that an implicit T does not exist in scope.

    Example:

    // works
    implicitly[Not[Numeric[String]]]
    
    implicitly[Not[Numeric[Int]]]
    //=> :9: error: cannot prove that Not[Numeric[Int]] because an implicit for Numeric[Int] exists in scope
    //=>               implicitly[Not[Numeric[Int]]]
    //=>                         ^
    
    implicitly[Int =:= Double]
    //=> :9: error: Cannot prove that Int =:= Double.
    //=>               implicitly[Int =:= Double]
    //=>                         ^
    
    // works
    implicitly[Not[Int =:= Double]]
    T

    is the implicit value that shouldn't exist in scope for Not[T] to exist

    Annotations
    @implicitNotFound( ... )
  2. implicit final class TryThenClose[T <: AnyRef { def close(): Unit }] extends AnyVal

    Implementation for a tryThenClose extension method meant for closeable resources, like input streams, for safe disposal of resources.

    Implementation for a tryThenClose extension method meant for closeable resources, like input streams, for safe disposal of resources.

    This example:

    import monifu.syntax.TryThenClose
    import java.io.{FileReader, BufferedReader}
    
    val firstLine =
      new BufferedReader(new FileReader("file.txt")).tryThenClose { in =>
        in.readLine()
      }

    Is equivalent to this:

    import java.io.{FileReader, BufferedReader}
    
    val fistLine = {
      val in = new BufferedReader(new FileReader("file.txt"))
      try {
        in.readLine()
      } finally {
        in.close()
      }
    }

    Actually for this to work it doesn't have to be a Java Closable as the type-checking is based on structural typing (yet because it's implemented as a macro, the actual call is not reflective).

    import monifu.syntax.TryThenClose
    class Foo { def close() = println("CLOSING") }
    
    new Foo().tryThenClose { _ =>
      println("Yay!")
    }
  3. implicit final class TypeSafeEquals[T] extends AnyVal

    Provides type-safe equality and inequality operators, implemented with macros for efficiency reasons.

Value Members

  1. object Not

  2. object TryThenClose

  3. object TypeSafeEquals

Inherited from AnyRef

Inherited from Any

Ungrouped