This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ~>[A[_], B[_]] { def apply[T](a: A[T]): B[T] } | |
object Test { | |
def x[A[_],B[_]](f: A ~> B) = f | |
import Param._ | |
val f = x { (p: Param[Option,List]) => p.ret( p.in.toList ) } | |
val a: List[Int] = f( Some(3) ) | |
val b: List[String] = f( Some("aa") ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Proposal: Default compiler/interpreter classpath in a managed environment | |
The compiler uses a default classpath of 'java.class.path'. Because many | |
applications do not use custom class loaders, this default is often sufficient | |
and no classpath configuration is required. This is because all jars- the | |
application and its dependencies, including the Scala compiler and library- are | |
in 'java.class.path' and the class loader for the application is the same as | |
that for Scala. | |
However, it does not work in more complicated setups, including various managed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.xml._ | |
import transform._ | |
object Test { | |
// utility method for a simple interface to the transform package | |
def transform(xml: Node)(f: Node => Seq[Node]) = { | |
val rule = new RewriteRule { override def transform(n: Node) = f(n) } | |
val transformer = new RuleTransformer(rule) | |
transformer transform xml | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in comments, the syntax: | |
// [A](B => C) | |
// represents a quantified function literal parameterized by type A | |
object Z | |
{ | |
// The main type, a quantified function object | |
trait Q[M[_], N[_]] { def apply[C](m: M[C]): N[C] } | |
// Helper Types |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
class PrivateConfigurations(info: ProjectInfo) extends DefaultProject(info) | |
{ | |
// define a custom configuration that will not get published | |
val compileOnly = config("compileOnly") hide | |
// add all dependencies in that configuration to the compile classpath | |
override def compileClasspath = super.compileClasspath +++ managedClasspath(compileOnly) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# only keep nodes in scala.collection and immediate parents that aren't scala.ScalaObject, java.lang.Object, or scala.Product | |
gvpr 'E[index(tail.label, "scala.collection.") > -1 && index(head.label, "scala.ScalaObject") == -1 | |
&& index(head.label, "java.lang.Object") == -1 && index(head.label, "scala.Product") == -1] {}' library_inherit.dot | | |
# discard nodes without edges | |
gvpr 'N[degree > 0] {} E{}' | | |
# make classes blue and objects red and shorten some names | |
sed -e 's/label="class /color=blue label="/' \ | |
-e 's/label="object /color=red label="/' \ | |
-e 's/label="scala.collection./label="c./' \ | |
-e 's/label="c.immutable./label="c.immut./' \ |
NewerOlder