- object becomes module
- package becomes module
- package object becomes module
- Support for top-level definitions
This file contains 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 mill._, scalalib._ | |
object MyModule extends ScalaModule { | |
def inlineIvyDeps = T { | |
def parseDep(usingDepClause: String): Dep = { | |
val part = usingDepClause.drop("//> using dep ".size) | |
if (part.startsWith("\"")) Dep.parse(part.tail.init.trim) | |
else Dep.parse(part.trim) | |
} |
This file contains 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 mill._, scalalib._, scalajslib._ | |
import scala.collection.mutable | |
object ElectronModule { | |
class Worker(val dstBase: os.Path) extends AutoCloseable { | |
private val updateTimes = mutable.Map[os.Path, Long]() | |
private var process: os.SubProcess = null |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'"> | |
<meta charset="UTF-8"> | |
<title>Hello, Indigo!</title> | |
<style> | |
body { | |
padding: 0; |
This file contains 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
override def run(args: List[String]): IO[ExitCode] = { | |
val databaseConfig = DatabaseConfig( | |
host = "localhost", | |
port = 5432, | |
username = "postgres", | |
database = "postgres", | |
password = None, | |
strategy = Strategy.SearchPath, | |
debug = true | |
) |
This file contains 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 cats.effect._ | |
import cats.implicits._ | |
import com.twitter.finagle.{Http, ListeningServer} | |
import doobie._ | |
import doobie.hikari._ | |
import io.catbird.util._ | |
import io.catbird.util.effect._ | |
object App extends IOApp { | |
val transactor: Resource[IO, HikariTransactor[IO]] = { |
This file contains 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 com.lightbend.lagom.scaladsl.playjson.JsonSerializer | |
import reflect.macros._ | |
object JsonSerializerImpl { | |
/** | |
* Generates a list of JsonSerializers for all direct subtypes of type T. Every subtype needs an implicit Format[T] | |
* in scope at the place of expansion. | |
* @param c | |
* @tparam T |
This file contains 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
[info] Updating facebookApi... | |
[info] Updating userSearchApi... | |
[info] Updating ... | |
[info] Updating auth... | |
[info] Done updating. | |
[warn] There may be incompatibilities among your library dependencies. | |
[warn] Run 'evicted' to see detailed eviction warnings | |
[info] Updating accountApi... | |
[info] Done updating. | |
[warn] There may be incompatibilities among your library dependencies. |
This file contains 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 cats.syntax.apply._ | |
import io.circe._ | |
import io.circe.literal._ | |
object JsonValidation{ | |
def validate[A: Decoder]( f: HCursor => ACursor, pred: A => Boolean, err: A => String ): Decoder[A] = | |
Decoder.instance( | |
f andThen{ ac => | |
ac.as[A].flatMap( a => | |
if ( pred( a ) ) |
This file contains 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 Rational { | |
implicit def rationalInt(n: Int): Rational = | |
Rational(n, 1) | |
def gcd(a: Int, b: Int): Int = | |
if (b == 0) a else gcd(b, a % b) | |
} | |
case class Rational(p: Int, q: Int) { | |
require(q != 0, "Denominator 'q' cannot be 0") |
NewerOlder