Skip to content

Instantly share code, notes, and snippets.

View acdenhartog's full-sized avatar

Arno den Hartog acdenhartog

  • Department of Knowledge Engineering at Maastricht University
View GitHub Profile
@acdenhartog
acdenhartog / 0-includeProjects.scala
Last active May 19, 2016 23:51
Partial includeProjects macro implementation for SBT
import language.experimental.macros
object ProjectMacros {
import scala.reflect._
import reflect.macros._
def includeProjectsMacroImpl[T: c.WeakTypeTag](c: blackbox.Context)(instance: c.Expr[T]): c.Expr[SettingDef] = {
import c.universe._
def isProject(s:Symbol) = s.typeSignature <:< typeOf[Project] && !s.isMethod //methods could take parameters
@acdenhartog
acdenhartog / Reggy.scala
Created May 13, 2016 06:00
StringContext regex extractors idea
object Main extends App {
implicit class Reggy(val sc: StringContext) extends AnyVal {
def regexNonTypeSafe(args: CanParse[_]*) = new RegexMatcher(Tuple1(args),sc)
def regex[T<:Product](args: T):RegexMatcher[T] = new RegexMatcher(args,sc)
//this could work with some type level hackery to map the args though a Poly into CanParsers
}
@acdenhartog
acdenhartog / 0-CurryingUpdate
Last active March 14, 2016 09:41
Why the update method should have been curried in the Scala language specification:
This text describes much of what is wrong with the update sugar in Scala.
Each part should be able to drop directly into a repl/worksheet and compile.
See 2-TL;DR:.scala for motivation.