Pamflet 0.8.0

in

Over the holiday break I've implemented left TOC for Pamflet, and released it as Pamflet 0.8.0.

scopt 4

in

Here's how functional DSL looks like in scopt 4:

import scopt.OParser
val builder = OParser.builder[Config]
val parser1 = {
  import builder._
  OParser.sequence(
    programName("scopt"),
    head("scopt", "4.x"),
    // option -f, --foo
    opt[Int]('f', "foo")
      .action((x, c) => c.copy(foo = x))
      .text("foo is an integer property"),
    // more options here...
  )
}
 
// OParser.parse returns Option[Config]
OParser.parse(parser1, args, Config()) match {
  case Some(config) =>
    // do something
  case _ =>
    // arguments are bad, error message will have been displayed
}

Instead of calling methods on OptionParser, the functional DSL first creates a builder based on your specific Config datatype, and calls opt[A](...) functions that returns OParser[A, Config].

These OParser[A, Config] parsers can be composed using OParser.sequence(...).

holiday brussel sprouts salad

masking scala.Seq

in

As of Scala 2.13.0-M5, it's planned that scala.Seq will change from scala.collection.Seq to scala.collection.immutable.Seq. Scala 2.13 collections rework explains a bit about why it's been non-immutable historically. Between the lines, I think it's saying that we should celebrate that scala.Seq will now be immutable out of the box.

Defaulting to immutable sequence would be good for apps and fresh code. The situation is a bit more complicated for library authors.

  • If you have a cross-built library, and
  • if your users are using your library from multiple Scala versions
  • and your users are using Array(...)

this change to immutable Seq could be a breaking change to your API.

underhill (2018.12 mixtape)

in

Spotify: https://open.spotify.com/user/1235450353/playlist/1cOJUEKtQfCKAovwSZhdyh...
YouTube: https://www.youtube.com/playlist?list=PLSUh6oJ5ZotVgnwc5xG-mE2uiunHANOyY

3 h 28 min

track list

  • Nobody But You - George FitzGerald, Hudson Scott
  • Nothing To Lose - Giorgia Angiuli
  • Bellyache (Marian Hill Remix) - Billie Eilish, Marian Hill
  • Technicolour - Mansionair
  • Come Home - BAYNK, Shallou
  • asleep (feat. MOONZz) - pluko, MOONZz

making conference a safer space for women

in

This post was coauthored by Eugene Yokota and Yifan Xing.

We need to change the culture around tech conferences to improve the inclusion of women (and people from other backgrounds too!). For that, there needs to be clear signaling and communication about two basic issues:

  1. No, it's not ok to hit on women at a conference.
  2. Assume technical competence, and treat women as professional peers.

These points should be communicated over and over at each conference before the keynote takes place, and before socializing hours.

'Red Mars' by Kim Stanley Robinson

Red Mars (Mars Trilogy, #1)Red Mars by Kim Stanley Robinson
My rating: 4 of 5 stars

Red Mars is a science fiction classic written in 1992. This book is everything I wanted and more, starting with first hundred astronauts and cosmonauts migrating to Mars to build the infrastructure such that more people can migrate. By the middle of the book, thousands of people migrate to Mars. The book explores various dimensions the epic project, not just technological challenges, but psychological effects, personality differences, and political interests by superpowers. The geography of Mars is written in vivid, majestic details.

super shell for sbt

in

I've implemented "super shell" feature for sbt over the weekend. The idea is to take over the bottom n lines of the termnial, and display the current tasks in progress.

the limitation of using log as status report

Logs are useful in many situations, and sometimes it's the only viable tool to find out what's going on. But on a console app like sbt, using logs to tell the build user what's going on doesn't always work.

stricter Scala with -Xlint, -Xfatal-warnings, and Scalafix

in

Compile, or compile not. There's no warning. Two of my favorite Scala compiler flags lately are "-Xlint" and "-Xfatal-warnings".
Here is an example setting that can be used with subprojects:

ThisBuild / organization := "com.example"
ThisBuild / version      := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "2.12.6"
 
lazy val commonSettings = List(
  scalacOptions ++= Seq(
    "-encoding", "utf8",
    "-deprecation",
    "-unchecked",
    "-Xlint",
    "-feature",
    "-language:existentials",

git gone: cleaning stale local branches

git gone is a custom git command that I wrote based on Erik Aybar's Git Tip: Deleting Old Local Branches. I'm not comfortable with Bash scripting, so it took me some Googling and Stackoverflowing, but hopefully it does the job. Save the source at the end of this page as git-gone in ~/bin or wherever you keep your local scripts.

To read how to use it type in git gone:

$ git gone
usage: git gone [-pndD] [<branch>=origin]
OPTIONS
  -p  prune remote branch
  -n  dry run: list the gone branches
  -d  delete the gone branches
  -D  delete the gone branches forcefully
 
EXAMPLES
git gone -pn  prune and dry run
git gone -d delete the gone branches
Syndicate content