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]]
is the implicit value that shouldn't exist in scope for Not[T]
to exist
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!") }
Provides type-safe equality and inequality operators, implemented with macros for efficiency reasons.