Skip to content

Instantly share code, notes, and snippets.

Lars Hupel larsrh

Block or report user

Report or block larsrh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@larsrh
larsrh / witness.scala
Created Jul 19, 2019
Arbitrary[Arbitrary]
View witness.scala
import $ivy.`org.scalacheck::scalacheck:1.14.0`
import org.scalacheck._
import org.scalacheck.Arbitrary._
import scala.reflect._
trait TypeWitness1 {
type F[_]
val name: String
def lift[A](implicit arb: Arbitrary[A]): Arbitrary[F[A]]
@larsrh
larsrh / demo1.scala
Last active Sep 14, 2018
LX Scala 2018/Scala Italy 2018 demo code: "Numeric programming with spire"
View demo1.scala
val cities1 = Map("Portugal" -> List("Lisbon"), "Spain" -> List("Madrid"))
val cities2 = Map("Portugal" -> List("Coimbra"))
cities1 |+| cities2
@larsrh
larsrh / scheduler.pl
Created Mar 19, 2018
Tiny job scheduler in SWI Prolog, for tutorial purposes.
View scheduler.pl
:- dynamic running/2.
:- dynamic jobid/1.
jobid(0).
resource(node1, 1, linux).
resource(node2, 2, linux).
resource(node3, 1, macos).
capacity(Node, Capacity) :- resource(Node, Capacity, _).
@larsrh
larsrh / conditional.scala
Last active Feb 13, 2018
Summon a conditional implicit
View conditional.scala
/*
* implicit conversion ("view"): implicit def f(x: A): B
* non-view implicit: implicit def f(implicit x: A): B
*
* we can summon implicit conversions with `implicitly[A => B]`
* we can't do that with non-view implicits
* this macro provides the trait `Conditional[A, B]` that provides precisely that
*/
package conditional
@larsrh
larsrh / Proofs.idr
Last active Nov 20, 2017
Idris code from Munich Lambda meetup, 2017-11-20
View Proofs.idr
module Proofs
%default total
data Natural : Type where
Zero : Natural
Succ : Natural -> Natural
add : Natural -> Natural -> Natural
add Zero y = y
@larsrh
larsrh / proposal.md
Last active Aug 3, 2017
Draft proposal for sbt upgrade
View proposal.md

Aid the ecosystem in upgrading to sbt 1.0.x

Proposer

Proposed by Lars Hupel.

Abstract

Scala 2.10 used to (and still has, to some extent), huge gravitas in the Scala ecosystem. To large parts, this was due to Spark and sbt supporting only 2.10. Spark has migrated to 2.11, and sbt 1.0.x is already there (the RCs are binary compatible).

@larsrh
larsrh / lambda.fst
Created May 18, 2017
F* code from Munich Lambda meetup, 2017-05-17
View lambda.fst
module Lambda
open FStar.Mul
val factorial: n:nat -> Tot (y:nat{y >= 1 /\ y >= n})
let rec factorial n =
if n = 0 then
1
else
n * factorial (n - 1)
@larsrh
larsrh / build.sbt
Created Mar 15, 2017
Packaging a compiler plugin with dependencies (requires sbt-assembly)
View build.sbt
// can be used like this:
// addCompilerPlugin("local.whatever" %% "whatever-plugin" % "0.1-SNAPSHOT" classifier "assembly" cross CrossVersion.patch)
name := "whatever-plugin"
organization := "local.whatever"
scalaVersion := "2.12.0"
crossScalaVersions := Seq("2.12.0", "2.12.1", "2.11.8", "2.11.7", "2.11.6")
@larsrh
larsrh / build.sbt
Last active Nov 21, 2016
scodec/remotely codec problem
View build.sbt
scalaVersion := "2.11.8"
resolvers += Resolver.bintrayRepo("oncue", "releases")
libraryDependencies += "oncue.remotely" %% "core" % "1.4.5"
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value
@larsrh
larsrh / tut-cli.sh
Created Oct 1, 2016
Running tut on the command line with coursier
View tut-cli.sh
# Uses Alex Archambault's coursier launcher
# Download as follows:
# $ curl -L -o coursier https://git.io/vgvpD && chmod +x coursier
# ... or refer to instructions here: <https://github.com/alexarchambault/coursier>
# list any dependencies here
COURSIER_CLASSPATH="$(coursier fetch -p com.chuusai:shapeless_2.11:2.3.1)"
# this downloads and launches tut in a seperate step
# the 'classpath' argument is being interpreted by scalac
You can’t perform that action at this time.