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
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. |
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
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 | |
} |
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 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 |