Skip to content

Instantly share code, notes, and snippets.

View milessabin's full-sized avatar

Miles Sabin milessabin

View GitHub Profile
2023.07.14 12:33:50 INFO Started: Metals version 0.11.12 in workspace '/home/miles/projects/gsp-graphql' for client Neovim 0.9.1.
Jul 14, 2023 12:33:50 PM org.flywaydb.core.internal.license.VersionPrinter printVersionOnly
INFO: Flyway Community Edition 9.16.3 by Redgate
Jul 14, 2023 12:33:50 PM org.flywaydb.core.internal.license.VersionPrinter printVersion
INFO: See release notes here: https://rd.gt/416ObMi
Jul 14, 2023 12:33:50 PM org.flywaydb.core.internal.license.VersionPrinter printVersion
INFO:
Jul 14, 2023 12:33:50 PM org.flywaydb.core.internal.database.base.BaseDatabaseType createDatabase
INFO: Database: jdbc:h2:file:/home/miles/projects/gsp-graphql/.metals/metals (H2 2.1)
Jul 14, 2023 12:33:50 PM org.flywaydb.core.internal.command.DbValidate validate
java.net.ConnectException: Connection refused
| => sat java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.checkConnect(Native Method)
at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishConnect(UnixAsynchronousSocketChannelImpl.java:252)
at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:198)
at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213)
at java.base/sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:306)
at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
miles@tarski:~% cs launch scala3-repl
scala> trait A
| trait B
| type M[X] = X match
| case A => Int
| case B => String
|
// defined trait A
// defined trait B
@milessabin
milessabin / trait-instances-2.scala
Last active June 23, 2020 08:39
Constraining trait type parameters via a super class type parameter constraint ... different instances along different paths
import cats.{Applicative, Monad}
import cats.implicits._
abstract class Foo[+M[_[_]], F[_]](implicit val M: M[F])
trait Bar[F[_]] extends Foo[Applicative, F] { def bar = Applicative[F] }
trait Baz[F[_]] extends Foo[Monad, F] { def baz = Monad[F] }
class User[F[_]: Monad] extends Bar[F] with Baz[F]
object Test {
@milessabin
milessabin / trait-instances.scala
Last active June 23, 2020 08:40
Constraining a trait type parameter via a super class type parameter constraint
import cats.{Applicative, Monad}
import cats.implicits._
abstract class Foo[+M[_[_]], F[_]](implicit val M: M[F])
trait Bar[F[_]] extends Foo[Applicative, F] { def bar = Applicative[F] }
trait Baz[F[_]] extends Foo[Monad, F] { def baz = Monad[F] }
class User[F[_]: Monad] extends Bar[F] with Baz[F]
object Test {
/*
* Copyright (c) 2019 Miles Sabin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
def tupleType(tpes: List[Type]): Type = {
val PairType = typeOf[_ *: _] match {
case Type.IsAppliedType(tp) => tp.tycon
}
@tailrec
def nestedPairs(tpes: List[Type], acc: Type): Type = tpes match {
case Nil => acc
case hd :: tail => nestedPairs(tail, Type.AppliedType(PairType, List(hd, acc)))
}
object Utils {
type Id[t] = t
type Const[c] = [t] => c
}
import Utils._
class Instances[F[_[_]], T[_]]
trait Functor[F[_]]
@milessabin
milessabin / LocalTests.scala
Last active October 6, 2018 18:26
Setup for local integration (ie. compile pos/neg/run) tests for lampepfl/dotty
// local/localtests/test/localtests/LocalTests.scala
package localtests
import java.nio.file._
import java.util.stream.{ Stream => JStream }
import org.junit.{ AfterClass, Test }
import scala.collection.JavaConverters._
import scala.concurrent.duration._