<commit_before>name := "rescala"

organization := "de.tuda.stg"

version := "0.5.0"

scalaVersion := "2.11.4"

crossScalaVersions := Seq("2.10.4", "2.11.4")

scalaSource in Compile <<= baseDirectory { (base) => new File(base, "REScala/src") }

libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-compiler" % _)

scalaSource in Test <<= baseDirectory { (base) => new File(base, "REScala/test") }

parallelExecution in Test := true

excludeFilter <<= scalaVersion {
  case s if s.startsWith("2.10.") => HiddenFileFilter || "*Macro*"
  case s if s.startsWith("2.11.") => HiddenFileFilter
}

libraryDependencies ++= (
  "org.mockito" % "mockito-all" % "1.10.8" % "test" ::
    "org.scalatest" %% "scalatest" % "2.2.2" % "test" ::
    "com.novocode" % "junit-interface" % "0.11" % "test" ::
    Nil)


scalacOptions ++= (
  "-deprecation" ::
  "-encoding" :: "UTF-8" ::
  "-unchecked" ::
  "-feature" ::
  "-target:jvm-1.7" ::
  "-Xlint" ::
  "-Xfuture" ::
  //"-Xlog-implicits" ::
  //"-Yno-predef" ::
  //"-Yno-imports" ::
  "-Xfatal-warnings" ::
  "-Yinline-warnings" ::
  "-Yno-adapted-args" ::
  "-Ywarn-dead-code" ::
  "-Ywarn-nullary-override" ::
  "-Ywarn-nullary-unit" ::
  //"-Ywarn-numeric-widen" ::
  //"-Ywarn-value-discard" ::
  Nil)



sourceGenerators in Compile <+= sourceManaged in Compile map { dir =>
  val file = dir / "rescala" / "signals" / "GeneratedLift.scala"
  val definitions = (1 to 22).map{ i =>
    val params = 1 to i map ("n" + _)
    val types = 1 to i map ("A" + _)
    val signals = params zip types map {case (p, t) => s"$p: Stateful[$t]"}
    def sep(l: Seq[String]) = l.mkString(", ")
    val getValues = params map (_ + ".get(t)")
    s"""  def lift[${sep(types)}, B](${sep(signals)})(fun: (${sep(types)}) => B)(implicit maybe: Ticket): Signal[B] =
       |  mapping(${sep(params)})(t => fun(${sep(getValues)}))
     """.stripMargin
  }
  IO.write(file,
  s"""package rescala.signals
     |
     |import rescala._
     |import rescala.graph._
     |import rescala.turns._
     |
     |trait GeneratedLift {
     |self: Signals.type =>
     |${definitions.mkString("\n")}
     |}
   """.stripMargin)
  Seq(file)
}

initialCommands in console :=
  s"""import rescala._
     |import rescala.Implicits.default
   """.stripMargin
<commit_msg>i am not sure if i should care about indentation of generated code<commit_after>name := "rescala"

organization := "de.tuda.stg"

version := "0.5.0"

scalaVersion := "2.11.4"

crossScalaVersions := Seq("2.10.4", "2.11.4")

scalaSource in Compile <<= baseDirectory { (base) => new File(base, "REScala/src") }

libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-compiler" % _)

scalaSource in Test <<= baseDirectory { (base) => new File(base, "REScala/test") }

parallelExecution in Test := true

excludeFilter <<= scalaVersion {
  case s if s.startsWith("2.10.") => HiddenFileFilter || "*Macro*"
  case s if s.startsWith("2.11.") => HiddenFileFilter
}

libraryDependencies ++= (
  "org.mockito" % "mockito-all" % "1.10.8" % "test" ::
    "org.scalatest" %% "scalatest" % "2.2.2" % "test" ::
    "com.novocode" % "junit-interface" % "0.11" % "test" ::
    Nil)


scalacOptions ++= (
  "-deprecation" ::
  "-encoding" :: "UTF-8" ::
  "-unchecked" ::
  "-feature" ::
  "-target:jvm-1.7" ::
  "-Xlint" ::
  "-Xfuture" ::
  //"-Xlog-implicits" ::
  //"-Yno-predef" ::
  //"-Yno-imports" ::
  "-Xfatal-warnings" ::
  "-Yinline-warnings" ::
  "-Yno-adapted-args" ::
  "-Ywarn-dead-code" ::
  "-Ywarn-nullary-override" ::
  "-Ywarn-nullary-unit" ::
  //"-Ywarn-numeric-widen" ::
  //"-Ywarn-value-discard" ::
  Nil)



sourceGenerators in Compile <+= sourceManaged in Compile map { dir =>
  val file = dir / "rescala" / "signals" / "GeneratedLift.scala"
  val definitions = (1 to 22).map{ i =>
    val params = 1 to i map ("n" + _)
    val types = 1 to i map ("A" + _)
    val signals = params zip types map {case (p, t) => s"$p: Stateful[$t]"}
    def sep(l: Seq[String]) = l.mkString(", ")
    val getValues = params map (_ + ".get(t)")
    s"""  def lift[${sep(types)}, B](${sep(signals)})(fun: (${sep(types)}) => B)(implicit maybe: Ticket): Signal[B] =
       |    mapping(${sep(params)})(t => fun(${sep(getValues)}))
     """.stripMargin
  }
  IO.write(file,
  s"""package rescala.signals
     |
     |import rescala._
     |import rescala.graph._
     |import rescala.turns._
     |
     |trait GeneratedLift {
     |self: Signals.type =>
     |${definitions.mkString("\n")}
     |}
   """.stripMargin)
  Seq(file)
}

initialCommands in console :=
  s"""import rescala._
     |import rescala.Implicits.default
   """.stripMargin

{'fraction_non_alphanumeric': 0.21120969487124, 'fraction_numerical': 0.016879463319627787, 'mean_word_length': 3.1677186654643825, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1809187', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1771, 'n_words': 356}