Skip to content

Instantly share code, notes, and snippets.

View juanjovazquez's full-sized avatar

Juan José Vázquez juanjovazquez

  • Legálitas
  • España
View GitHub Profile
@juanjovazquez
juanjovazquez / Quill.scala
Created February 26, 2016 09:19
Streaming to Cassandra with Quill and Akka Streams
package com.tecsisa.wr
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source
import io.getquill._
import io.getquill.naming._
import scala.concurrent.ExecutionContext.Implicits.global
@juanjovazquez
juanjovazquez / validation.scala
Created March 29, 2016 15:43
Translation of Raul Raja's article `FP for the average Joe - I - ScalaZ Validation` for using cats library instead of scalaz. @see http://bit.ly/1UzKBEW
/**
Translation of Raul Raja's article
`FP for the average Joe - I - ScalaZ Validation`
for using cats library instead of scalaz.
@see http://bit.ly/1UzKBEW
*/
package joe
@juanjovazquez
juanjovazquez / monadt.scala
Created March 29, 2016 17:45
Translation of Raul Raja's article `FP for the average Joe - II - ScalaZ Monad Transformers` for using cats library instead of scalaz. @see http://bit.ly/1SkmOTe
/**
Translation of Raul Raja's article
`FP for the average Joe - II - ScalaZ Monad Transformers`
for using cats library instead of scalaz.
@see http://bit.ly/1SkmOTe
*/
package joe
@juanjovazquez
juanjovazquez / AnyToCoproduct.scala
Last active September 27, 2016 10:45
Approach for casting Any to Shapeless Coproduct
/*
* Copyright 2016 TECNOLOGIA, SISTEMAS Y APLICACIONES S.L.
*/
import org.scalatest.FunSuite
import shapeless.{ CNil, Coproduct, Inl, Inr, Typeable, :+: }
import shapeless.syntax.typeable.typeableOps
class AnyToCoproduct extends FunSuite with AnyToCoproductTypeableInstances {
@juanjovazquez
juanjovazquez / raptureXmlTest.scala
Last active March 5, 2017 12:12
Rapture: XML extraction problem
object RaptureXmlOk {
import rapture.xml._
case class Foo(bar: Bar)
case class Bar(baz: Baz)
case class Baz(qux: Qux)
case class Qux(value: String)
implicitly[Extractor[Bar, Xml]] // works
implicitly[Extractor[Foo, Xml]] // works
import cats.~>
import cats.data.State
import cats.syntax.all._
import org.atnos.eff.{ |=, <=, Eff, Fx, Member }
import org.atnos.eff.state.get
import org.atnos.eff.either.fromEither
import org.atnos.eff.Eff.send
import org.atnos.eff.Interpret.translateNat
import org.atnos.eff.syntax.all._
@juanjovazquez
juanjovazquez / iotaGen.scala
Last active February 5, 2018 09:34
Scalacheck generator for iota coproduct (No longer necessary after this http://bit.ly/2EFdY4k)
// This is an ammonite scala script see: http://bit.ly/2FyQf58
// Dependencies
import $ivy.`org.typelevel::cats-core:1.0.1`
import $ivy.`com.chuusai::shapeless:2.3.3`
import $ivy.`io.frees::iota-core:0.3.4`
import $ivy.`org.scalacheck::scalacheck:1.13.5`
// Regular imports
import iota.{ Cop, TNil }

Keybase proof

I hereby claim:

  • I am juanjovazquez on github.
  • I am juanjovazquez (https://keybase.io/juanjovazquez) on keybase.
  • I have a public key ASA_XoOdzNnmX2_GFOJ-PXZKlDlhZg6iuTiQGYNIGTdq-Ao

To claim this, I am signing this object:

@juanjovazquez
juanjovazquez / shape1.scala
Last active March 8, 2020 07:51
Records à la shapeless in dotty
object labelled {
opaque type Field[K <: String, +V] = V
object Field {
def apply[K <: String, V](v: V): Field[K, V] = v
extension on [K <: String, V](field: Field[K, V]) {
def value: V = field
}
}
// For educational purposes
object MyListModule {
trait MyList[+A]
object MyList {
case object Empty extends MyList[Nothing]
case class Cons[A](h: A, t: MyList[A]) extends MyList[A]
def head[A](l: MyList[A]): A =