Skip to content

Instantly share code, notes, and snippets.

View jto's full-sized avatar
🏠
Working from home

Julien Tournay jto

🏠
Working from home
View GitHub Profile
trait Foo[A]
type Alias[A] = List[Foo[A]]
trait Test1[C[_]]
implicit def test1[C[_]]: Test1[C] = new Test1[C]{}
implicitly[Test1[Alias]] // Compiles fine
implicitly[Test1[λ[α => List[Foo[α]]]]] // Does not compile: could not find implicit value for parameter e: Test1[[α]List[Foo[α]]]
package commons
import scala.concurrent.ExecutionContext
import akka.actor.ActorSystem
case class Contexts(val actorSystem: ActorSystem) {
import Contexts._
implicit val defaultCtx = DefaultExeCtx(play.api.libs.concurrent.Execution.defaultContext)
implicit val ctrlsCtx = CtrlExeCtx(defaultCtx.underlying)
@jto
jto / seqpar.scala
Last active January 17, 2017 11:00
object Test {
import scalaz._, Scalaz._
type FA[F[_], S, A] = FreeAp[λ[α => S => F[(S, α)]], A]
type Precepte[F[_], S, A] = Free[({ type L[A] = FA[F, S, A] })#L, A]
type UnmanagedState = List[String]
trait PreBuilder[F[_]]{
type Pre[A] = Precepte[F, UnmanagedState, A]
type St0[A] = UnmanagedState => F[(UnmanagedState, A)]
type St[A] = FA[F, UnmanagedState, A]
/*
def run = {
import com.mfglabs.precepte._, default._, Macros.callee, corescalaz._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import default._
import scalaz.std.scalaFuture._
type Pre[A] = DefaultPre[Future, Unit, A]
type ST = default.ST[Unit]
@jto
jto / pre2.scala
Last active January 11, 2017 17:05
import scalaz._
import Scalaz._
type Step0[F[_], S, A] = S => (S, F[A])
type Precepte[F[_], S, A] = Free[({ type L[A] = Step0[F, S, A] })#L, A]
type UnmanagedState = List[String]
type Pre[A] = Precepte[Id, UnmanagedState, A]
object Pre {
type St[A] = Step0[Id, UnmanagedState, A]
@jto
jto / _Fun.scala
Last active November 22, 2016 15:34
final class Compose1[T1, R] private (val fs: Vector[(Any => Any, Int)]) extends (T1 => R) {
val MAX_DEPTH = 1000
private def append(gs: Vector[(Any => Any, Int)], fd: (Any => Any, Int)) = {
val (fl, dl) = gs.last
val (f, d) = fd
if(d + dl > MAX_DEPTH) {
fd +: gs
} else {
@jto
jto / 0_hfix.scala
Last active November 11, 2016 19:18
case class Fix[F[_]](f: F[Fix[F]])
@jto
jto / hfix.scala
Last active October 31, 2016 16:56
package test
trait ListF[+A, +S]
trait Nil extends ListF[Nothing, Nothing]
object Nil extends Nil
case class Cons[A, +S](x: A, xs: S) extends ListF[A, S]
case class Fix[F[_]](f: F[Fix[F]])
package fix
import cats._
object fix {
trait ExprF[A]
case class Const[A](value: Int) extends ExprF[A]
case class Add[A](left: A, right: A) extends ExprF[A]
case class Mul[A](left: A, right: A) extends ExprF[A]
@jto
jto / Demo.scala
Created August 26, 2016 12:38
Automatic case class to CSV derivation using shapeless
case class Foo(i: Int)
case class Bar(foo: Foo, g: String)
val b = Bar(Foo(1), "toto")
val h = ToHList(b) // List[shapeless.::[Int, shapeless.::[String, shapeless.HNil]]] = List(1 :: toto :: HNil)
Ser.toCSV(h) // "1,toto"