Skip to content

Instantly share code, notes, and snippets.

View sellout's full-sized avatar
🍌
semper φ

Greg Pfeil sellout

🍌
semper φ
View GitHub Profile
> nix-channel --update
downloading Nix expressions from ‘https://d3g5gsiof5omrk.cloudfront.net/nixpkgs/nixpkgs-17.09pre106045.7369fd0b51/nixexprs.tar.xz’...
downloading ‘https://d3g5gsiof5omrk.cloudfront.net/nixpkgs/nixpkgs-17.09pre106045.7369fd0b51/nixexprs.tar.xz’... [7471/8550 KiB, 7391.9 KiB/s]
error: cannot connect to daemon at ‘/nix/var/nix/daemon-socket/socket’: Connection refused
cannot fetch ‘https://d3g5gsiof5omrk.cloudfront.net/nixpkgs/nixpkgs-17.09pre106045.7369fd0b51/nixexprs.tar.xz’
> nix-daemon
error: cannot bind to socket ‘/nix/var/nix/daemon-socket/socket’: Address already in use

Porting from Scalaz to Cats (and friends)

Mappings

There are a lot of cases where things simply differ by name. These are the easiest changes to make.

  • scalaz.Zip -> cats.Cartesian (with the primary operation zip -> product)
  • scalaz.Unzip -> cats.MonadCombine ... sort of
  • scalaz.Task -> fs2.Task (or monix.Task)
@sellout
sellout / plugins.sbt
Created January 6, 2017 03:56
This is in ~/.sbt/0.13/plugins/
resolvers += Resolver.bintrayRepo("tek", "maven")
addCompilerPlugin("tryp" %% "splain" % "0.1.11")
addSbtPlugin("org.ensime" % "sbt-ensime" % "1.12.4")
addSbtPlugin("com.softwaremill.clippy" % "plugin-sbt" % "0.3.4")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.5")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10")
trait Ops[T, F[_]] {
// currently
object transCata {
def apply[U] = new PartiallyApplied[U] // PartiallyApplied
final class PartiallyApplied[U] {
def apply[G[_]: Functor] // unnecessary type param, and seductive constraint syntax
(f: F[U] => G[U])
(implicit U: Corecursive.Aux[U, G], BF: Functor[F]) // Aux
: U =
typeClassInstance.transCata(self)(f)
trait A[T] {
type F[_]
}
trait B1[T] extends A[T]
object B1 {
type Aux[T, Fʹ[_]] = B1[T] { type F[A] = Fʹ[A] }
}
object Test {
abstract class Recursive[T <: AnyKind] {
type Base[_ <: AnyKind] <: AnyKind
type ~~>[_ <: AnyKind, _ <: AnyKind]
def project: T ~~> Base[T]
}
object Recursive {
image: java:8
variables:
SBT: "./sbt"
TEMP_DIR: "./tmp/"
QUASAR_MONGODB_TESTDB: "quasar-test"
QUASAR_TEST_PATH_PREFIX: "/${QUASAR_MONGODB_TESTDB}/"
build:
stage: build
+ object ::\:: {
+ def apply[F[_]] = new Aux[F]
+
+ final class Aux[F[_]] {
+ def apply[T[_[_]], G[_]]
+ (i: Injectable.Aux[G, QScriptTotal[T, ?]])
+ (implicit F: F :<: QScriptTotal[T, ?])
+ : Injectable.Aux[Coproduct[F, G, ?], QScriptTotal[T, ?]] =
+ Injectable.coproduct(Injectable.inject[F, QScriptTotal[T, ?]], i)
+ }
(defvar solarized-directory "~/Documents/personal/emacs-color-theme-solarized/")
(add-to-list 'load-path "~/Documents/Lisp-community/emacs-extended-faces/")
(if (< emacs-major-version 24)
(progn (load (concat solarized-directory "color-theme-solarized"))
(color-theme-solarized))
(progn (add-to-list 'custom-theme-load-path solarized-directory)
(load-theme 'solarized t)))

Normalization & Optimization

First, normalization and optimization are two different things. Normalization, which has various sub-definitions, depending on the exact properties involves approaching some “normal form” that reduces the variety of the structure at hand. It can often pessimize a structure, but does so in a predictable way. A normalized structure is easier to apply other operations to, because it is restricted in its form.

Optimization, on the other hand, denormalizes in exchange for better performance. But an optimized structure is harder to reason about and make changes to.

So, the general approach is to normalize a structure, apply whatever transformations are appropriate, then optimize the structure. If you are converting between structures, usually only the final structure would have optimization applied, but normalization of each structure can be useful.

Defining Transformations