org.tpolecat
stuff
Latest releases and supported Scala versions for Release | 2.12 | 2.13 | 3.0.0 | Notes | |
---|---|---|---|---|---|
Atto | 0.9.5 | ||||
Doobie (CE2) | 0.13.4 | ||||
Doobie (CE3) | 1.0.0-M5 | ||||
Natchez (CE2) | 0.0.26 | EOL | |||
Natchez (CE3) | 0.1.3 |
org.tpolecat
stuffRelease | 2.12 | 2.13 | 3.0.0 | Notes | |
---|---|---|---|---|---|
Atto | 0.9.5 | ||||
Doobie (CE2) | 0.13.4 | ||||
Doobie (CE3) | 1.0.0-M5 | ||||
Natchez (CE2) | 0.0.26 | EOL | |||
Natchez (CE3) | 0.1.3 |
Let me know if you hear of any more and I'll update the list.
Hub/Provider | Registration URL |
---|---|
Bastrop | www.covac.info |
Bell | http://www.bellcountyhealth.org |
Gillespie | https://www.hillcountrymemorial.org/hill-country-covid/ |
import java.io.ByteArrayInputStream | |
import java.security.PrivateKey | |
import java.security.PublicKey | |
import org.bouncycastle.jce.provider.BouncyCastleProvider | |
import org.bouncycastle.openpgp.operator.jcajce._ | |
import org.bouncycastle.openpgp._ | |
import scala.util.control.NonFatal | |
/** | |
* Methods to turn GPG ASCII-amored exported text into JCA keys. Many thanks to Twitter friends, |
Ok, so to map CITEXT
, which is not a standard type JDBC knows about, we need a wrapper class and need to move the value back and forth via the generic PGobject
data type.
import org.postgresql.util.PGobject
case class CIText(s: String)
object CIText {
sealed trait MaybeNumeric[A] | |
case class YesNumeric[A](n: Numeric[A]) extends MaybeNumeric[A] | |
case class NoNumeric[A]() extends MaybeNumeric[A] | |
object MaybeNumeric { | |
implicit def instance[A](implicit ev: Numeric[A]): MaybeNumeric[A] = | |
YesNumeric(ev) | |
} |
import scalaz._, Scalaz._ | |
/** Abstraction over functions of the shape `A => F[A]`. */ | |
case class EndoT[F[_], A](run: A => F[A]) { | |
def apply(a: A): F[A] = | |
run(a) | |
def andThen(e: EndoT[F, A])(implicit ev: Bind[F]): EndoT[F, A] = | |
e.compose(this) |
Let's get our imports out of the way.
import scala.util.Random.nextInt
import scala.concurrent._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
// addCompilerPlugin("com.milessabin" % "si2712fix-plugin" % "1.2.0" cross CrossVersion.full) | |
import scalaz._, Scalaz._ | |
implicit def f2k[F[_], A, B](f: A => F[B]) = Kleisli(f) | |
val a: Int => ListT[List, Int] = { | |
case 0 => ListT(List(List(0, 1))) | |
case 1 => ListT(List(List(0), List(1))) | |
} |
EDIT: This gist has been promoted and is now a blog post.
Scala methods can have multiple lists of value parameters but only one list of type parameters, which is occasionally irritating when some are inferable and others are not. Consider this method which has two type parameters, one inferable and one not.
import scalaz._, Scalaz._
One of the cool things PostgreSQL gives you is a simple notification system that you can use to let clients know that something interesting has happened. For instance you can set up rules that broadcast notifications when a table is updated, and client applications can update displays in response. The JDBC driver provides access to this API so I thought I would see what it would look like in doobie.
The program below constructs a Process[ConnectionIO, PGNotification]
that registers for events, polls for them periodically (this is the best we can do with current driver support), and unregisters when the stream terminates for any reason. We use a Transactor
to replace ConnectionIO
with Task
which gives us something we can actually run.
package doobie.example
import doobie.imports._