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.Order | |
import scala.collection.SortedMap | |
/** | |
* A data structure representing a bidirectional mapping between | |
* two key types. Each value in the bimap is associated with exactly | |
* one value of the opposite type. | |
*/ | |
final case class BiMap[A, B](ab: SortedMap[A, B], ba: SortedMap[B, A]) { self => | |
// TODO: remove unsafe constructor ^^^ |
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
(use-package polymode | |
:commands poly-scala-mode | |
:mode ("\\.scala\\'" . poly-scala-mode) | |
:config | |
(define-hostmode poly-scala-hostmode | |
:protect-syntax nil | |
:protect-font-lock t | |
:mode 'scala-mode) | |
(define-innermode poly-scala-sql-multiline-innermode |
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
sealed trait Error[E, A] | |
object Error { | |
case class ThrowError[E, A](error: E) extends Error[E, A] | |
implicit def monadError[E, S[_]: Functor](implicit I: Inject[Error[E, ?], S]): MonadError[Free[S, ?], E] = | |
new MonadError[Free[S, ?], E] { | |
def pure[A](a: A) = Free.pure(a) | |
def raiseError[A](e: E) = Free.inject[Error[E, ?], S](ThrowError(e)) | |
def handleErrorWith[A](fa: Free[S, A])(f: E => Free[S, A]) = | |
fa.fold( |
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 fs2.Task | |
import cats.implicits._ | |
import doobie.imports._ | |
import doobie.free.{databasemetadata => DMD} | |
package object migrations { | |
case class TableDesc( | |
catalog: Option[String], | |
schema: Option[String], | |
name: String |
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 test { | |
val x = for { | |
_ <- new Codensity[IO, Unit] { | |
def apply[B](f: Unit => IO[B]): IO[B] = | |
f(()).ensuring(IO.putStrLn("finally")) | |
} | |
a <- new Codensity[IO, Int] { | |
def apply[B](f: Int => IO[B]): IO[B] = | |
(IO.putStrLn("acquire: 1") >| 1) | |
.bracket(x => IO.putStrLn(s"release: $x"))(f) |
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
21:14 <edwardk> in scala you could have working coindexed prisms | |
21:20 <wedens> edwardk: interesting. do you have a gist? is inference the only problem? | |
21:20 <edwardk> not handy | |
21:21 <edwardk> the issue is that we want indexed lenses / traversals to downgrade to normal lenses / traversals right? | |
21:21 <edwardk> well | |
21:21 <edwardk> to do that (.) unifies 'p' in the second indexed lens you compose with with (->) in the one upstream | |
21:21 <edwardk> :t traversed | |
21:21 <lambdabot> (Applicative f1, Traversable f, Indexable Int p) => p a (f1 b) -> f a -> f1 (f b) | |
21:21 <edwardk> :t traversed.traversed | |
21:21 <lambdabot> (Applicative f1, Traversable f, Traversable f2, Indexable Int p) => p a (f1 b) -> f (f2 a) -> f1 (f (f2 b)) |
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 FreeCoproduct { | |
import scalaz._, Scalaz._ | |
import shapeless._ | |
import ops.coproduct.{Inject, Selector} | |
import Shapoyo._ | |
import Free._ | |
sealed trait Test1Op[A] | |
case object Test1Alg extends Test1Op[Int] |
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 scala.reflect.macros.Context | |
import scala.language.experimental.macros | |
import scala.annotation.StaticAnnotation | |
object builderMacro { | |
def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { | |
import c.universe._ | |
import Flag._ | |
val optType = typeOf[Option[Any]] |
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
killtom() { | |
pid=$(ps aux | grep apache-tomcat | grep 'bin/java' | grep -v grep | awk '{print $2}') | |
if [ -z "$pid" ] | |
then | |
echo "Tomcat is not running!" | |
else | |
echo "Killing Tomcat PID: $pid" | |
kill -9 $pid | |
fi | |
} |