Cats Instances for Java Time
Cats Instances for Scalacheck
//> using dep "org.http4s::http4s-scalatags::0.25.2" | |
//> using dep "org.http4s::http4s-dsl::0.23.23" | |
//> using dep "org.http4s::http4s-ember-server::0.23.23" | |
//> using dep "org.tpolecat::skunk-core::0.6.0" | |
//> using dep "com.dimafeng::testcontainers-scala-postgresql::0.41.0" | |
//> using dep "com.outr::scribe-slf4j::3.12.2" | |
import skunk.*, codec.all.*, syntax.all.* | |
import cats.effect.* | |
import scalatags.Text.all.* |
Cats Instances for Java Time
Cats Instances for Scalacheck
The following describes how you can publish artifacts for any sbt project using the GitHub Package Registry and the sbt-github-packages plugin.
In your GitHub account, go to Settings > Developer settings > Personal access tokens, then click on Generate new token (or click here). Fill in some sort of meaningful name (I chose Dev) and click on the write:packages
checkbox:
Some of these practices might be based on wrong assumptions and I'm not aware of it, so I would appreciate any feedback.
avoiding some dependency conflicts:
~/.sbt/{0.13,1.0}/plugins/plugins.sbt
undeclaredCompileDependencies
and make the obvious missing dependencies explicit by adding them to libraryDependencies
of each sub-projectunusedCompileDependencies
and remove some obvious unused libraries. This has false positives, so ; reload; Test/compile
after each change and ultimately run all tests to see that it didn't break anythingundeclaredCompileDependenciesTest
to the CI pipeline, so that it will fail if you have some undeclared dependencieskeeping dependencies up to date and resolving conflicts:
object game { | |
case class Lens[S, A](set: A => S => S, get: S => A) { self => | |
def >>> [B](that: Lens[A, B]): Lens[S, B] = | |
Lens[S, B]( | |
set = (b: B) => (s: S) => self.set(that.set(b)(self.get(s)))(s), | |
get = (s: S) => that.get(self.get(s)) | |
) | |
} | |
case class Prism[S, A](set: A => S, get: S => Option[A]) { self => |
import scala.annotation.tailrec | |
/** | |
* A Type-aligned list is a list of functions which can be | |
* chained together. They are "type-aligned" because their | |
* types all line. For example, suppose you have the following | |
* functions: | |
* | |
* val foo: Int => String = i => i.toString | |
* val bar: String => Char = s => s.head |
I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.
This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea
Balaji Sivaraman @balajisivaraman_twitter
Hi all, I need some help understanding a piece of Doobie code from the examples. It is the StreamingCopy one: (https://github.com/tpolecat/doobie/blob/series/0.4.x/yax/example/src/main/scala/example/StreamingCopy.scala). I am using a modified version of the fuseMap2 example from that file. Here’s how I’ve modified it for my requirements:
def fuseMap[F[_]: Catchable: Monad, A, B](
source: Process[ConnectionIO, A],
sink: Vector[A] => ConnectionIO[B],
delete: ConnectionIO[Unit]
)(
sourceXA: Transactor[F],
With the recent announcement of cats-effect, a relevant question from the past resurfaces: why does IO
, which is otherwise quite Task
-like, not define both
or race
? To be clear, the type signatures of these functions would be as follows:
object IO {
def both[A, B](ioa: IO[A], iob: IO[B])(implicit EC: ExecutionContext): IO[(A, B)] = ???
def race[A, B](ioa: IO[A], iob: IO[B])(implicit EC: ExecutionContext): IO[Either[A, B]] = ???
}