Skip to content

Instantly share code, notes, and snippets.

View smarter's full-sized avatar

Guillaume Martres smarter

View GitHub Profile
@smarter
smarter / gadt.md
Last active March 6, 2024 23:33
GADTs in Scala

Generalized Algebraic Data Types in Scala

Basic GADTs

Here's an ADT which is not a GADT, in Haskell:

data Expr = IntExpr Int | BoolExpr Bool
//> using scala 3.nightly
import scala.language.experimental.relaxedExtensionImports
object A:
extension (s: String)
def wow: Unit = println(s)
object B:
extension (i: Int)
def wow: Unit = println(i)
From 8606ae2990c191766b5b7c9eca250f4569632abe Mon Sep 17 00:00:00 2001
From: Guillaume Martres <smarter@ubuntu.com>
Date: Wed, 24 Mar 2021 12:37:44 +0100
Subject: [PATCH] CI: turn off option that runs git submodule foreach
Because this is run without running git submodule update first, it seems
to break whenever a submodule is deleted.
---
.github/workflows/ci.yaml | 52 +++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
This file has been truncated, but you can view the full file.
[2020-10-02 19:10:12Z INFO HostContext] No proxy settings were found based on environmental variables (http_proxy/https_proxy/HTTP_PROXY/HTTPS_PROXY)
[2020-10-02 19:10:12Z INFO HostContext] Well known directory 'Bin': '/home/drone/github-actions-runners/runner-1/bin.2.273.5'
[2020-10-02 19:10:12Z INFO HostContext] Well known directory 'Root': '/home/drone/github-actions-runners/runner-1'
[2020-10-02 19:10:12Z INFO HostContext] Well known config file 'Credentials': '/home/drone/github-actions-runners/runner-1/.credentials'
[2020-10-02 19:10:12Z INFO Listener] Runner is built for Linux (X64) - linux-x64.
[2020-10-02 19:10:12Z INFO Listener] RuntimeInformation: Linux 4.4.0-151-generic #178-Ubuntu SMP Tue Jun 11 08:30:22 UTC 2019.
[2020-10-02 19:10:12Z INFO Listener] Version: 2.273.5
[2020-10-02 19:10:12Z INFO Listener] Commit: a79bab4b3c993a205a2d73d2b618299d8a96bd26
[2020-10-02 19:10:12Z INFO Listener] Culture: en-US
[2020-10-02 19:10:12Z INFO Listener] UI Culture: en-US
Lisp Backtrace:
"looking-at" (0x91c61e70)
"scala-syntax:looking-at-simplePattern-beginning" (0x91c620d0)
"scala-font-lock:limit-pattern2" (0x91c623a0)
"scala-font-lock:limit-pattern" (0x91c625f0)
"eval" (0x91c627d0)
"font-lock-fontify-keywords-region" (0x91c62d30)
"font-lock-default-fontify-region" (0x91c63050)
"font-lock-fontify-region" (0x91c632c8)
0x84976b0 PVEC_COMPILED
@smarter
smarter / fmap.scala
Last active November 18, 2019 08:55
Should work with 0.20.0-RC1
// Compiles with https://github.com/lampepfl/dotty/pull/4672
// ./bin/dotc -classpath "$(coursier fetch -p org.typelevel:cats-core_2.13:2.0.0)" out/fmap.scala
import cats._
import cats.implicits._
object Test {
val fmap: [A, B] -> (A => B) => [F[_]] -> F[A] => (given Functor[F]) => F[B] = [A, B] -> (f: A => B) => ([F[_]] -> (fa: F[A]) => (given ev: Functor[F]) => fa.map(f))
val addOne = fmap((x: Int) => x + 1)
rep: Update report:
Resolve time: -1 ms, Download time: -1 ms, Download size: -1 bytes
test:
ch.epfl.lamp:dotty-doc_0.14:0.14.0-RC1:default (artifactId=dotty-doc_0.14, project.version=0.14.0-RC1, pom.groupId=ch.epfl.lamp, groupId=ch.epfl.lamp, project.groupId=ch.epfl.lamp, version=0.14.0-RC1, pom.version=0.14.0-RC1, project.artifactId=dotty-doc_0.14, pom.artifactId=dotty-doc_0.14): (Artifact(dotty-doc_0.14, jar, jar, None, Vector(), Some(https://repo1.maven.org/maven2/ch/epfl/lamp/dotty-doc_0.14/0.14.0-RC1/dotty-doc_0.14-0.14.0-RC1.jar), Map(artifactId -> dotty-doc_0.14, project.version -> 0.14.0-RC1, pom.groupId -> ch.epfl.lamp, groupId -> ch.epfl.lamp, project.groupId -> ch.epfl.lamp, version -> 0.14.0-RC1, pom.version -> 0.14.0-RC1, project.artifactId -> dotty-doc_0.14, pom.artifactId -> dotty-doc_0.14), None),/home/smarter/.cache/coursier/v1/https/repo1.maven.org/maven2/ch/epfl/lamp/dotty-doc_0.14/0.14.0-RC1/dotty-doc_0.14-0.14.0-RC1.jar)
org.scala-sbt:compi
@smarter
smarter / sbt
Created February 18, 2019 16:32
#!/bin/bash
#SBT_OPTS="-Xms512M -Xmx4096M -XX:ReservedCodeCacheSize=1024M -XX:+CMSClassUnloadingEnabled"
#SBT_OPTS="-Xms512M -Xmx1536M -XX:+CMSClassUnloadingEnabled -XX:MaxInlineLevel=35"
SBT_OPTS="-Xms512M -Xmx6192M -XX:ReservedCodeCacheSize=1024M -XX:+CMSClassUnloadingEnabled -XX:MaxInlineLevel=35"
ARGS=()
while [ $# -ne 0 ]; do
case $1 in
-D*)
@smarter
smarter / projection-proposal.md
Created January 5, 2016 12:49
Type projection proposal

NOTE: This is a sketch of the proposal, many details need to be filled out and the scheme hasn't been implemented yet.

G |- T <: S
--------------------
G |- T#L <: S#L

------------------------------
G |- {L: X..Y, ...}#L <: Y
[ {
"id" : "wsdPkgMetrics/compile",
"compilerVersion" : "0.10.0-RC1",
"compilerArguments" : [ ],
"sourceDirectories" : [ "wsdPkgMetrics/src" ],
"dependencyClasspath" : [ "/home/smarter/.cache/coursier/v1/https/repo1.maven.org/maven2/com/lihaoyi/ammonite-ops_2.12/1.3.2/ammonite-ops_2.12-1.3.2.jar", "/home/smarter/.cache/coursier/v1/https/repo1.maven.org/maven2/ch/epfl/lamp/dotty-library_0.10/0.10.0-RC1/dotty-library_0.10-0.10.0-RC1.jar", "/home/smarter/.cache/coursier/v1/https/repo1.maven.org/maven2/com/lihaoyi/geny_2.12/0.1.2/geny_2.12-0.1.2.jar", "/home/smarter/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.7/scala-library-2.12.7.jar", "/home/smarter/.cache/coursier/v1/https/repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.25.2/sqlite-jdbc-3.25.2.jar", "/home/smarter/.cache/coursier/v1/https/repo1.maven.org/maven2/ch/epfl/lamp/scala-library/0.10.0-RC1/scala-library-0.10.0-RC1.jar" ],
"classDirectory" : "out/wsdPkgMetrics/compile/dest/classes"
} ]